Spaces:
Runtime error
Runtime error
import os | |
from getpass import getpass | |
import openai | |
import gradio as gr | |
from huggingface_hub import HfApi | |
# Get API key from Hugging Face secret repository | |
# Make sure to replace 'CannaTech' and 'OPENAI_API_KEY' with your Hugging Face username and the name of your secret repository | |
# You will be prompted to enter your Hugging Face password | |
api = HfApi() | |
password = getpass("Enter your Hugging Face password: ") | |
token = api.login(username="CannaTech", password=password) | |
api.create_repo(token=token, name="OPENAI_API_KEY", exist_ok=True) | |
openai.api_key = api.get_secret(token=token, repo_id="CannaTech/OPENAI_API_KEY", secret_name="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 = "In the context of {category} specifically and using your expertise and 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 | |
examples = [ | |
["BioTrack", "What is the process to register for BioTrack in New Mexico?"], | |
["BioTrack", "How to add a new product in BioTrack?"], | |
["BioTrack", "What are the steps to update inventory in BioTrack?"], | |
["BioTrack", "How to generate sales reports in BioTrack?"], | |
["BioTrack", "Can I integrate BioTrack with my existing POS system?"], | |
["BioTrack", "What are the data backup options in BioTrack?"], | |
["BioTrack", "How to handle product returns in BioTrack?"], | |
["BioTrack", "What are the security features of BioTrack?"], | |
["BioTrack", "How to train my staff to use BioTrack?"], | |
["BioTrack", "What are the system requirements to run BioTrack?"], | |
["Regulations", "What is the legal age to purchase cannabis in New Mexico?"], | |
["Regulations", "What are the packaging and labeling requirements for cannabis in New Mexico?"], | |
["Regulations", "What are the limits on cannabis possession in New Mexico?"], | |
["Regulations", "Can I grow my own cannabis in New Mexico?"], | |
["Regulations", "What are the regulations for cannabis edibles in New Mexico?"], | |
["Regulations", "What are the licensing requirements for opening a dispensary in New Mexico?"], | |
["Regulations", "What are the regulations for cannabis advertising in New Mexico?"], | |
["Regulations", "What are the penalties for non-compliance with cannabis regulations in New Mexico?"], | |
["Regulations", "Can I use medical cannabis in public in New Mexico?"], | |
["Regulations", "What are the regulations for transporting cannabis in New Mexico?"], | |
["BioTrack", "How to report a lost or stolen product in BioTrack?"], | |
["Regulations", "What are the regulations for cannabis waste disposal in New Mexico?"], | |
["BioTrack", "How to handle customer complaints in BioTrack?"], | |
["Regulations", "What are the regulations for cannabis testing in New Mexico?"], | |
["BioTrack", "How to manage multiple locations in BioTrack?"] | |
] | |
iface = gr.Interface( | |
fn=CustomChatGPT, | |
inputs=[ | |
gr.inputs.Dropdown(choices=['BioTrack', 'Regulations', 'Best Practices', 'General Question'], label='Category', type='value'), | |
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=examples, | |
theme="upscale" | |
) | |
iface.launch() | |