Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,21 +29,22 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
29 |
raise gr.Error("Use Agent is required.")
|
30 |
|
31 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
32 |
-
|
|
|
33 |
output = ""
|
34 |
|
35 |
try:
|
36 |
start_time_ms = round(time.time() * 1000)
|
37 |
|
38 |
if (agent_option == AGENT_LANGCHAIN):
|
39 |
-
|
40 |
config,
|
41 |
prompt
|
42 |
)
|
43 |
|
44 |
output = completion["output"]
|
45 |
elif (agent_option == AGENT_LLAMAINDEX):
|
46 |
-
|
47 |
config,
|
48 |
prompt
|
49 |
)
|
@@ -56,7 +57,7 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
56 |
temperature = config["temperature"]
|
57 |
)
|
58 |
|
59 |
-
|
60 |
except Exception as e:
|
61 |
err_msg = e
|
62 |
|
@@ -66,17 +67,16 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
66 |
|
67 |
trace_wandb(
|
68 |
config,
|
69 |
-
|
70 |
prompt,
|
71 |
completion,
|
72 |
result,
|
73 |
-
callback,
|
74 |
err_msg,
|
75 |
start_time_ms,
|
76 |
end_time_ms
|
77 |
)
|
78 |
|
79 |
-
return
|
80 |
|
81 |
gr.close_all()
|
82 |
|
|
|
29 |
raise gr.Error("Use Agent is required.")
|
30 |
|
31 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
32 |
+
|
33 |
+
completion = ""
|
34 |
output = ""
|
35 |
|
36 |
try:
|
37 |
start_time_ms = round(time.time() * 1000)
|
38 |
|
39 |
if (agent_option == AGENT_LANGCHAIN):
|
40 |
+
result = agent_langchain(
|
41 |
config,
|
42 |
prompt
|
43 |
)
|
44 |
|
45 |
output = completion["output"]
|
46 |
elif (agent_option == AGENT_LLAMAINDEX):
|
47 |
+
result = agent_llamaindex(
|
48 |
config,
|
49 |
prompt
|
50 |
)
|
|
|
57 |
temperature = config["temperature"]
|
58 |
)
|
59 |
|
60 |
+
result = completion.choices[0].message.content
|
61 |
except Exception as e:
|
62 |
err_msg = e
|
63 |
|
|
|
67 |
|
68 |
trace_wandb(
|
69 |
config,
|
70 |
+
agent_option,
|
71 |
prompt,
|
72 |
completion,
|
73 |
result,
|
|
|
74 |
err_msg,
|
75 |
start_time_ms,
|
76 |
end_time_ms
|
77 |
)
|
78 |
|
79 |
+
return result
|
80 |
|
81 |
gr.close_all()
|
82 |
|