Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
import openai, os, time
|
3 |
|
4 |
-
client = openai.OpenAI(api_key = os.getenv("OPENAI_API_KEY"))
|
5 |
-
|
6 |
def show_json(obj):
|
7 |
display(json.loads(obj.model_dump_json()))
|
8 |
|
9 |
def chat(message, history):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
for i in range(len(message)):
|
11 |
time.sleep(0.5)
|
12 |
yield "You typed: " + message[: i+1]
|
|
|
1 |
import gradio as gr
|
2 |
import openai, os, time
|
3 |
|
|
|
|
|
4 |
def show_json(obj):
|
5 |
display(json.loads(obj.model_dump_json()))
|
6 |
|
7 |
def chat(message, history):
|
8 |
+
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
9 |
+
|
10 |
+
assistant = client.beta.assistants.create(
|
11 |
+
name="Math Tutor",
|
12 |
+
instructions="You are a personal math tutor. Answer questions briefly, in a sentence or less.",
|
13 |
+
model="gpt-4-1106-preview",
|
14 |
+
)
|
15 |
+
show_json(assistant)
|
16 |
+
|
17 |
for i in range(len(message)):
|
18 |
time.sleep(0.5)
|
19 |
yield "You typed: " + message[: i+1]
|