Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,9 @@ _assistant, _thread = None, None
|
|
10 |
|
11 |
def create_assistant(client):
|
12 |
assistant = client.beta.assistants.create(
|
13 |
-
name="
|
14 |
-
instructions="You are a
|
15 |
-
model="gpt-
|
16 |
tools=[{"type": "code_interpreter"}],
|
17 |
)
|
18 |
show_json("assistant", assistant)
|
@@ -58,7 +58,6 @@ def list_run_steps(client, thread, run):
|
|
58 |
)
|
59 |
for step in run_steps.data:
|
60 |
step_details = step.step_details
|
61 |
-
#print(json.dumps(show_json("step_details", step_details), indent=4))
|
62 |
show_json("step_details", step_details)
|
63 |
return run_steps
|
64 |
|
@@ -101,14 +100,19 @@ def chat(message, history, openai_api_key):
|
|
101 |
gr.ChatInterface(
|
102 |
chat,
|
103 |
chatbot=gr.Chatbot(height=300),
|
104 |
-
textbox=gr.Textbox(placeholder="
|
105 |
-
title="
|
106 |
-
description="
|
107 |
-
retry_btn=None,
|
108 |
-
undo_btn=None,
|
109 |
clear_btn="Clear",
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
cache_examples=False,
|
113 |
additional_inputs=[
|
114 |
gr.Textbox("sk-", label="OpenAI API Key", type = "password"),
|
|
|
10 |
|
11 |
def create_assistant(client):
|
12 |
assistant = client.beta.assistants.create(
|
13 |
+
name="Python Code Generator & Executor",
|
14 |
+
instructions="You are a Python programming language expert that generates Pylint-compliant code and explains it. Only execute code when expicitly asked to.",
|
15 |
+
model="gpt-4o",
|
16 |
tools=[{"type": "code_interpreter"}],
|
17 |
)
|
18 |
show_json("assistant", assistant)
|
|
|
58 |
)
|
59 |
for step in run_steps.data:
|
60 |
step_details = step.step_details
|
|
|
61 |
show_json("step_details", step_details)
|
62 |
return run_steps
|
63 |
|
|
|
100 |
gr.ChatInterface(
|
101 |
chat,
|
102 |
chatbot=gr.Chatbot(height=300),
|
103 |
+
textbox=gr.Textbox(placeholder="Ask anything", container=False, scale=7),
|
104 |
+
title="Python Code Generator & Executor",
|
105 |
+
description="Generate, explain, fix, optimize, document, test, help, execute, ...",
|
|
|
|
|
106 |
clear_btn="Clear",
|
107 |
+
retry_btn="Retry",
|
108 |
+
undo_btn="Undo",
|
109 |
+
examples=[
|
110 |
+
["Generate: NumPy/Pandas/Matplotlib & yfinance trading app", "sk-<BringYourOwn>"],
|
111 |
+
["Explain: r'^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\\W]).{8,}$'", "sk-<BringYourOwn>"],
|
112 |
+
["Fix: x = [5, 2, 1, 3, 4]; print(x.sort())", "sk-<BringYourOwn>"],
|
113 |
+
["Optimize: x = []; for i in range(0, 10000): x.append(i)", "sk-<BringYourOwn>"],
|
114 |
+
["Execute: Code to generate the first 20 fibbonaci numbers", "sk-<BringYourOwn>"],
|
115 |
+
],
|
116 |
cache_examples=False,
|
117 |
additional_inputs=[
|
118 |
gr.Textbox("sk-", label="OpenAI API Key", type = "password"),
|