Spaces:
Sleeping
Sleeping
Commit
·
95fdea8
1
Parent(s):
faede02
done
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from huggingface_hub import InferenceClient
|
|
5 |
import os
|
6 |
import openai
|
7 |
from openai.error import OpenAIError
|
|
|
8 |
|
9 |
# Set page configuration
|
10 |
st.set_page_config(
|
@@ -199,22 +200,10 @@ if uploaded_file is not None:
|
|
199 |
# Healthier Alternatives
|
200 |
st.subheader("💡 Healthier Alternatives")
|
201 |
try:
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
"role": "system",
|
207 |
-
"content": "You are a helpful assistant specializing in providing healthy alternatives to various dishes."
|
208 |
-
},
|
209 |
-
{
|
210 |
-
"role": "user",
|
211 |
-
"content": f"What's a healthy {top_food} recipe, and why is it healthy?"
|
212 |
-
}
|
213 |
-
],
|
214 |
-
max_tokens=200,
|
215 |
-
temperature=0.7,
|
216 |
-
)
|
217 |
-
result = response['choices'][0]['message']['content'].strip()
|
218 |
st.write(result)
|
219 |
except OpenAIError as e:
|
220 |
st.error(f"OpenAI API error: {e}")
|
|
|
5 |
import os
|
6 |
import openai
|
7 |
from openai.error import OpenAIError
|
8 |
+
from gradio_client import Client
|
9 |
|
10 |
# Set page configuration
|
11 |
st.set_page_config(
|
|
|
200 |
# Healthier Alternatives
|
201 |
st.subheader("💡 Healthier Alternatives")
|
202 |
try:
|
203 |
+
# ONLY THIS PART CHANGED:
|
204 |
+
# Use the RAG calling method instead of the OpenAI function
|
205 |
+
client_rag = Client("https://66cd04274e7fd11327.gradio.live/")
|
206 |
+
result = client_rag.predict(query=f"What's a healthy {top_food} recipe, and why is it healthy?", api_name="/get_response")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
st.write(result)
|
208 |
except OpenAIError as e:
|
209 |
st.error(f"OpenAI API error: {e}")
|