import openai import gradio as gr openai.api_key = "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" messages = [{"role": "system", "content": "You are a Customer Service expert that specializes in BioTrack and New Mexico Cannabis Regulatory Compliance"}] def CustomChatGPT(category, user_input): user_input = f"In the context of BioTrack and cannabis regulations in New Mexico, and specifically about {category}, " + user_input messages.append({"role": "user", "content": user_input}) response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=messages ) ChatGPT_reply = response["choices"][0]["message"]["content"] messages.append({"role": "assistant", "content": ChatGPT_reply}) return ChatGPT_reply iface = gr.Interface( fn=CustomChatGPT, inputs=[gr.inputs.Dropdown(choices=['Biotrack', 'Regulations', 'Best Practices', 'General Question'], label='Category'), gr.inputs.Textbox(lines=5, placeholder='Type here...', label='Your Question')], outputs=gr.outputs.Textbox(label='AI Response'), title="CannaAssist AI Assistant", description="Welcome to the CannaAssist AI Assistant. This tool is designed to provide expert guidance on BioTrack and cannabis regulations in New Mexico. DISCLAIMER: This is a proof of concept and not an official product.", examples=[ ["Biotrack", "How to add wholesale flower into my inventory?"], ["Regulations", "Tell me about cannabis regulations in New Mexico."], ["Best Practices", "What are the best practices for managing inventory?"], ["General Question", "What is BioTrack?"] ], theme="huggingface" ) iface.launch()