Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,28 +5,15 @@ from agents import create_triage_agent, create_sales_agent, create_issues_repair
|
|
5 |
from openai import OpenAI
|
6 |
from utils import show_json
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
issues_repairs_agent = create_issues_repairs_agent(_client)
|
18 |
-
show_json("issues_repairs_agent", issues_repairs_agent)
|
19 |
-
###
|
20 |
-
|
21 |
-
def create_assistant(client):
|
22 |
-
assistant = client.beta.assistants.create(
|
23 |
-
name="Math Tutor",
|
24 |
-
instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
|
25 |
-
model="gpt-4-1106-preview",
|
26 |
-
tools=[{"type": "code_interpreter"}],
|
27 |
-
)
|
28 |
-
show_json("assistant", assistant)
|
29 |
-
return assistant
|
30 |
|
31 |
def create_thread(client):
|
32 |
thread = client.beta.threads.create()
|
@@ -87,14 +74,37 @@ def extract_content_values(data):
|
|
87 |
content_values.append(content.text.value)
|
88 |
return content_values
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
def chat(message, history, openai_api_key):
|
91 |
global _client, _assistant, _thread
|
92 |
|
93 |
-
if _assistant == None:
|
94 |
-
|
95 |
|
96 |
-
if _thread == None:
|
97 |
-
|
98 |
|
99 |
create_message(_client, _thread, message)
|
100 |
|
|
|
5 |
from openai import OpenAI
|
6 |
from utils import show_json
|
7 |
|
8 |
+
#def create_assistant(client):
|
9 |
+
# assistant = client.beta.assistants.create(
|
10 |
+
# name="Math Tutor",
|
11 |
+
# instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
|
12 |
+
# model="gpt-4-1106-preview",
|
13 |
+
# tools=[{"type": "code_interpreter"}],
|
14 |
+
# )
|
15 |
+
# show_json("assistant", assistant)
|
16 |
+
# return assistant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def create_thread(client):
|
19 |
thread = client.beta.threads.create()
|
|
|
74 |
content_values.append(content.text.value)
|
75 |
return content_values
|
76 |
|
77 |
+
_client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
78 |
+
|
79 |
+
#_assistant, _thread = None, None
|
80 |
+
|
81 |
+
###
|
82 |
+
triage_agent = create_triage_agent(_client)
|
83 |
+
show_json("triage_agent", triage_agent)
|
84 |
+
sales_agent = create_sales_agent(_client)
|
85 |
+
show_json("sales_agent", sales_agent)
|
86 |
+
issues_repairs_agent = create_issues_repairs_agent(_client)
|
87 |
+
show_json("issues_repairs_agent", issues_repairs_agent)
|
88 |
+
|
89 |
+
triage_thread = create_thread(_client)
|
90 |
+
show_json("triage_thread", triage_thread)
|
91 |
+
sales_thread = create_thread(_client)
|
92 |
+
show_json("sales_thread", sales_thread)
|
93 |
+
issues_repairs_thread = create_thread(_client)
|
94 |
+
show_json("issues_repairs_thread", issues_repairs_thread)
|
95 |
+
|
96 |
+
_assistant = triage_agent
|
97 |
+
_thread = triage_thread
|
98 |
+
###
|
99 |
+
|
100 |
def chat(message, history, openai_api_key):
|
101 |
global _client, _assistant, _thread
|
102 |
|
103 |
+
#if _assistant == None:
|
104 |
+
# _assistant = create_assistant(_client)
|
105 |
|
106 |
+
#if _thread == None:
|
107 |
+
# _thread = create_thread(_client)
|
108 |
|
109 |
create_message(_client, _thread, message)
|
110 |
|