Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,20 +2,6 @@ import gradio as gr
|
|
2 |
import json, openai, os, time
|
3 |
from openai import OpenAI
|
4 |
|
5 |
-
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
6 |
-
|
7 |
-
assistant = client.beta.assistants.create(
|
8 |
-
name="Math Tutor",
|
9 |
-
instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
|
10 |
-
model="gpt-4-1106-preview",
|
11 |
-
)
|
12 |
-
|
13 |
-
show_json(assistant)
|
14 |
-
|
15 |
-
thread = client.beta.threads.create()
|
16 |
-
|
17 |
-
show_json(thread)
|
18 |
-
|
19 |
def show_json(obj):
|
20 |
print("###")
|
21 |
print(json.loads(obj.model_dump_json()))
|
@@ -37,7 +23,21 @@ def extract_content_value(data):
|
|
37 |
if content.type == 'text':
|
38 |
content_values.append(content.text.value)
|
39 |
return content_values
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def chat(message, history):
|
42 |
history_openai_format = []
|
43 |
for human, assistant in history:
|
|
|
2 |
import json, openai, os, time
|
3 |
from openai import OpenAI
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def show_json(obj):
|
6 |
print("###")
|
7 |
print(json.loads(obj.model_dump_json()))
|
|
|
23 |
if content.type == 'text':
|
24 |
content_values.append(content.text.value)
|
25 |
return content_values
|
26 |
+
|
27 |
+
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
28 |
+
|
29 |
+
assistant = client.beta.assistants.create(
|
30 |
+
name="Math Tutor",
|
31 |
+
instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
|
32 |
+
model="gpt-4-1106-preview",
|
33 |
+
)
|
34 |
+
|
35 |
+
show_json(assistant)
|
36 |
+
|
37 |
+
thread = client.beta.threads.create()
|
38 |
+
|
39 |
+
show_json(thread)
|
40 |
+
|
41 |
def chat(message, history):
|
42 |
history_openai_format = []
|
43 |
for human, assistant in history:
|