CannaTech commited on
Commit
45e162e
·
1 Parent(s): 9d174c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -9,11 +9,17 @@ def CustomChatGPT(category, user_input):
9
  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"}]
10
  user_input = f"In the context of {category} specifically and using your expertise and knowledge of cannabis regulations in New Mexico and BioTrack, " + user_input
11
  messages.append({"role": "user", "content": user_input})
12
- response = openai.ChatCompletion.create(
13
- model="gpt-3.5-turbo",
14
- messages=messages
15
- )
16
- ChatGPT_reply = response.choices[0].message["content"]
 
 
 
 
 
 
17
  return ChatGPT_reply
18
 
19
  iface = gr.Interface(
@@ -24,17 +30,10 @@ iface = gr.Interface(
24
  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.",
25
  examples=[
26
  ["BioTrack", "How to add wholesale flower into my inventory?"],
27
- ["BioTrack", "How do I update inventory quantities in BioTrack?"],
28
  ["Regulations", "How much cannabis can I buy in New Mexico?"],
29
- ["Regulations", "What are the packaging requirements for cannabis products in New Mexico?"],
30
  ["Best Practices", "What are the best practices for managing inventory?"],
31
- ["Best Practices", "How can I improve my dispensary's customer service?"],
32
  ["General Question", "How to increase sales for my dispensary?"],
33
- ["General Question", "What are the benefits of offering delivery service for my dispensary?"],
34
-
35
  ],
36
  theme=gr.themes.Monochrome()
37
  )
38
 
39
- iface.launch()
40
-
 
9
  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"}]
10
  user_input = f"In the context of {category} specifically and using your expertise and knowledge of cannabis regulations in New Mexico and BioTrack, " + user_input
11
  messages.append({"role": "user", "content": user_input})
12
+ try:
13
+ response = openai.ChatCompletion.create(
14
+ model="gpt-3.5-turbo",
15
+ messages=messages
16
+ )
17
+ ChatGPT_reply = response.choices[0].message["content"]
18
+ except openai.api_resources.abstract.api_error.APIError as e:
19
+ if e.type == 'rate_limit':
20
+ ChatGPT_reply = "Rate limit exceeded. Please try again later."
21
+ else:
22
+ ChatGPT_reply = "An error occurred. Please try again later."
23
  return ChatGPT_reply
24
 
25
  iface = gr.Interface(
 
30
  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.",
31
  examples=[
32
  ["BioTrack", "How to add wholesale flower into my inventory?"],
 
33
  ["Regulations", "How much cannabis can I buy in New Mexico?"],
 
34
  ["Best Practices", "What are the best practices for managing inventory?"],
 
35
  ["General Question", "How to increase sales for my dispensary?"],
 
 
36
  ],
37
  theme=gr.themes.Monochrome()
38
  )
39