Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,11 +23,13 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
23 |
if (agent_option is None):
|
24 |
raise gr.Error("Use Agent is required.")
|
25 |
|
|
|
|
|
26 |
output = ""
|
27 |
|
28 |
try:
|
29 |
if (agent_option == AGENT_OFF):
|
30 |
-
client = OpenAI(
|
31 |
|
32 |
completion = client.chat.completions.create(
|
33 |
messages = [{"role": "user", "content": prompt}],
|
@@ -38,8 +40,7 @@ def invoke(openai_api_key, prompt, agent_option):
|
|
38 |
else:
|
39 |
completion = invoke_agent(
|
40 |
config["model"],
|
41 |
-
config["temperature"]
|
42 |
-
openai_api_key,
|
43 |
prompt)
|
44 |
|
45 |
output = completion["output"]
|
|
|
23 |
if (agent_option is None):
|
24 |
raise gr.Error("Use Agent is required.")
|
25 |
|
26 |
+
os.environ["OPENAI_API_KEY"] = openai_api_key
|
27 |
+
|
28 |
output = ""
|
29 |
|
30 |
try:
|
31 |
if (agent_option == AGENT_OFF):
|
32 |
+
client = OpenAI()
|
33 |
|
34 |
completion = client.chat.completions.create(
|
35 |
messages = [{"role": "user", "content": prompt}],
|
|
|
40 |
else:
|
41 |
completion = invoke_agent(
|
42 |
config["model"],
|
43 |
+
config["temperature"]
|
|
|
44 |
prompt)
|
45 |
|
46 |
output = completion["output"]
|