Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,9 @@ import openai
|
|
3 |
from dotenv import load_dotenv
|
4 |
import os
|
5 |
import time
|
|
|
|
|
6 |
|
7 |
-
current_thread_id = None
|
8 |
|
9 |
title = "# Welcome to 🙋🏻♂️Tonic's🕵🏻♂️Bulbi🪴Plant👩🏻⚕️Doctor!"
|
10 |
description = """Here you can use Bulbi - an OpenAI agent that helps you save your plants!
|
@@ -29,6 +30,8 @@ openai.api_key = os.getenv('OPENAI_API_KEY')
|
|
29 |
assistant_id = os.getenv('ASSISTANT_ID')
|
30 |
client = openai.OpenAI(api_key=openai.api_key)
|
31 |
thread_ids = {}
|
|
|
|
|
32 |
|
33 |
def ask_openai(question, start_new_thread=True, selected_thread_id=None):
|
34 |
global thread_ids
|
@@ -89,10 +92,6 @@ def ask_openai(question, start_new_thread=True, selected_thread_id=None):
|
|
89 |
else:
|
90 |
return "No response."
|
91 |
|
92 |
-
# Initialize Gradio client
|
93 |
-
gradio_client = Client("https://tonic1-tulu.hf.space/--replicas/t5vxm/")
|
94 |
-
|
95 |
-
# Pass the response text to the Gradio client and get the prediction
|
96 |
final_result = gradio_client.predict(
|
97 |
response_text,
|
98 |
"I am Tulu, an Expert Plant Doctor, I will exactly summarize the information you provide to me.",
|
@@ -104,6 +103,9 @@ def ask_openai(question, start_new_thread=True, selected_thread_id=None):
|
|
104 |
except Exception as e:
|
105 |
return f"An error occurred: {str(e)}"
|
106 |
|
|
|
|
|
|
|
107 |
iface = gr.Interface(
|
108 |
title=title,
|
109 |
description=description,
|
|
|
3 |
from dotenv import load_dotenv
|
4 |
import os
|
5 |
import time
|
6 |
+
from gradio_client import Client
|
7 |
+
|
8 |
|
|
|
9 |
|
10 |
title = "# Welcome to 🙋🏻♂️Tonic's🕵🏻♂️Bulbi🪴Plant👩🏻⚕️Doctor!"
|
11 |
description = """Here you can use Bulbi - an OpenAI agent that helps you save your plants!
|
|
|
30 |
assistant_id = os.getenv('ASSISTANT_ID')
|
31 |
client = openai.OpenAI(api_key=openai.api_key)
|
32 |
thread_ids = {}
|
33 |
+
current_thread_id = None
|
34 |
+
gradio_client = Client("https://tonic1-tulu.hf.space/--replicas/t5vxm/")
|
35 |
|
36 |
def ask_openai(question, start_new_thread=True, selected_thread_id=None):
|
37 |
global thread_ids
|
|
|
92 |
else:
|
93 |
return "No response."
|
94 |
|
|
|
|
|
|
|
|
|
95 |
final_result = gradio_client.predict(
|
96 |
response_text,
|
97 |
"I am Tulu, an Expert Plant Doctor, I will exactly summarize the information you provide to me.",
|
|
|
103 |
except Exception as e:
|
104 |
return f"An error occurred: {str(e)}"
|
105 |
|
106 |
+
except Exception as e:
|
107 |
+
return f"An error occurred: {str(e)}"
|
108 |
+
|
109 |
iface = gr.Interface(
|
110 |
title=title,
|
111 |
description=description,
|