CannaAssist / app.py
CannaTech's picture
Update app.py
d812f9f
raw
history blame
1.78 kB
import openai
import gradio as gr
import os
openai.api_key = os.environ["openai_api_key"]
messages = [{"role": "system", "content": "You are an expert in Technical Support and Customer Service that specializes in New Mexico Cannabis Regulatory Compliance and training people how to use software called BioTrack"}]
def CustomChatGPT(category, user_input):
user_input = f"In the context of {category} specifically and using your expert knowledge of cannabis regulations in New Mexico and BioTrack" + 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=1, 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", "How much cannabis can I buy in New Mexico."],
["Best Practices", "What are the best practices for managing inventory?"],
["General Question", "How to increase sales for my dispensary?"]
],
theme="huggingface"
)
iface.launch()