CannaTech commited on
Commit
7332f83
·
1 Parent(s): 45e162e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -1,25 +1,20 @@
 
1
  import openai
2
  import gradio as gr
3
- import os
4
 
5
  openai.api_key = os.getenv("OPENAI_API_KEY")
6
 
 
7
 
8
  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
- 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,10 +25,11 @@ 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
 
 
 
1
+ import os
2
  import openai
3
  import gradio as gr
 
4
 
5
  openai.api_key = os.getenv("OPENAI_API_KEY")
6
 
7
+ 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"}]
8
 
9
  def CustomChatGPT(category, user_input):
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
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
 
 
 
 
 
18
  return ChatGPT_reply
19
 
20
  iface = gr.Interface(
 
25
  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.",
26
  examples=[
27
  ["BioTrack", "How to add wholesale flower into my inventory?"],
28
+ ["Regulations", "How much cannabis can I buy in New Mexico."],
29
  ["Best Practices", "What are the best practices for managing inventory?"],
30
+ ["General Question", "How to increase sales for my dispensary?"]
31
  ],
32
+ theme="upscale"
33
  )
34
 
35
+ iface.launch()