Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ def invoke(openai_api_key, prompt):
|
|
26 |
if (prompt == ""):
|
27 |
raise gr.Error("Prompt is required.")
|
28 |
|
29 |
-
|
30 |
|
31 |
try:
|
32 |
llm = ChatOpenAI(model_name = config["model_name"],
|
@@ -39,15 +39,15 @@ def invoke(openai_api_key, prompt):
|
|
39 |
handle_parsing_errors = True,
|
40 |
verbose = True)
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
except Exception as e:
|
46 |
err_msg = e
|
47 |
|
48 |
raise gr.Error(e)
|
49 |
|
50 |
-
return
|
51 |
|
52 |
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> API
|
53 |
with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
|
|
|
26 |
if (prompt == ""):
|
27 |
raise gr.Error("Prompt is required.")
|
28 |
|
29 |
+
output = ""
|
30 |
|
31 |
try:
|
32 |
llm = ChatOpenAI(model_name = config["model_name"],
|
|
|
39 |
handle_parsing_errors = True,
|
40 |
verbose = True)
|
41 |
|
42 |
+
completion = agent(prompt)
|
43 |
|
44 |
+
output = completion.output
|
45 |
except Exception as e:
|
46 |
err_msg = e
|
47 |
|
48 |
raise gr.Error(e)
|
49 |
|
50 |
+
return output
|
51 |
|
52 |
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> API
|
53 |
with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
|