Spaces:
Sleeping
Sleeping
James MacQuillan
commited on
Commit
Β·
f313407
1
Parent(s):
d460134
push
Browse files
app.py
CHANGED
@@ -91,7 +91,8 @@ def search(query):
|
|
91 |
return all_results
|
92 |
|
93 |
def process_query(user_input, history):
|
94 |
-
|
|
|
95 |
|
96 |
# Step 1: Generate a search term based on the user query
|
97 |
stream_search = client.chat_completion(
|
@@ -108,7 +109,8 @@ def process_query(user_input, history):
|
|
108 |
search_query += content
|
109 |
|
110 |
# Step 2: Perform the web search with the generated term
|
111 |
-
|
|
|
112 |
search_results = search(search_query)
|
113 |
|
114 |
# Format results as a JSON string for model input
|
@@ -122,14 +124,14 @@ def process_query(user_input, history):
|
|
122 |
stream=True
|
123 |
)
|
124 |
|
125 |
-
yield "Analyzing the search results and crafting a response π"
|
126 |
|
|
|
127 |
# Stream final response
|
128 |
final_response = ""
|
129 |
for chunk in response:
|
130 |
content = chunk.choices[0].delta.content or ''
|
131 |
final_response += content
|
132 |
-
yield final_response
|
133 |
|
134 |
theme = gr.themes.Citrus(
|
135 |
primary_hue="blue",
|
|
|
91 |
return all_results
|
92 |
|
93 |
def process_query(user_input, history):
|
94 |
+
|
95 |
+
yield {"role": "assistant", "content": 'Preparing your request π οΈ'}
|
96 |
|
97 |
# Step 1: Generate a search term based on the user query
|
98 |
stream_search = client.chat_completion(
|
|
|
109 |
search_query += content
|
110 |
|
111 |
# Step 2: Perform the web search with the generated term
|
112 |
+
|
113 |
+
yield {"role": "assistant", "content": 'Searching the web for relevant information π'}
|
114 |
search_results = search(search_query)
|
115 |
|
116 |
# Format results as a JSON string for model input
|
|
|
124 |
stream=True
|
125 |
)
|
126 |
|
|
|
127 |
|
128 |
+
yield {"role": "assistant", "content": 'Analyzing the search results and crafting a response π'}
|
129 |
# Stream final response
|
130 |
final_response = ""
|
131 |
for chunk in response:
|
132 |
content = chunk.choices[0].delta.content or ''
|
133 |
final_response += content
|
134 |
+
yield {"role": "assistant", "content": final_response}
|
135 |
|
136 |
theme = gr.themes.Citrus(
|
137 |
primary_hue="blue",
|