Update app.py
Browse files
app.py
CHANGED
|
@@ -36,8 +36,8 @@ def call_openai_api(user_prompt):
|
|
| 36 |
{"role": "system", "content": "You are a research assistant. Provide factual short answers."},
|
| 37 |
{"role": "user", "content": f"{text}\n\n{user_prompt}"},
|
| 38 |
]
|
| 39 |
-
|
| 40 |
-
response.choices[0].message['content']
|
| 41 |
except Exception as e:
|
| 42 |
if attempt < max_retries - 1: # if it's not the last attempt
|
| 43 |
time.sleep(1) # wait for 1 seconds before retrying
|
|
@@ -45,6 +45,7 @@ def call_openai_api(user_prompt):
|
|
| 45 |
else:
|
| 46 |
return str(e) # return the exception message after the last attempt
|
| 47 |
|
|
|
|
| 48 |
iface = gr.Interface(fn=call_openai_api,
|
| 49 |
inputs=gr.inputs.Textbox(label="User Prompt For Cognitive Agent"),
|
| 50 |
outputs=gr.outputs.Textbox(label="Cognitive Agent Response"),
|
|
|
|
| 36 |
{"role": "system", "content": "You are a research assistant. Provide factual short answers."},
|
| 37 |
{"role": "user", "content": f"{text}\n\n{user_prompt}"},
|
| 38 |
]
|
| 39 |
+
)
|
| 40 |
+
return response.choices[0].message['content']
|
| 41 |
except Exception as e:
|
| 42 |
if attempt < max_retries - 1: # if it's not the last attempt
|
| 43 |
time.sleep(1) # wait for 1 seconds before retrying
|
|
|
|
| 45 |
else:
|
| 46 |
return str(e) # return the exception message after the last attempt
|
| 47 |
|
| 48 |
+
|
| 49 |
iface = gr.Interface(fn=call_openai_api,
|
| 50 |
inputs=gr.inputs.Textbox(label="User Prompt For Cognitive Agent"),
|
| 51 |
outputs=gr.outputs.Textbox(label="Cognitive Agent Response"),
|