Spaces:
Running
Running
Update response_modes.py
Browse files- response_modes.py +25 -23
response_modes.py
CHANGED
|
@@ -86,28 +86,6 @@ def parse_ddgs_date(date_str: str):
|
|
| 86 |
except:
|
| 87 |
return now
|
| 88 |
|
| 89 |
-
# Setup for the second AI model (Qwen-3-32B)
|
| 90 |
-
client_qwen = Groq() # For using the Qwen-3-32B model
|
| 91 |
-
|
| 92 |
-
async def qwen_reasoning(message: str, context: str) -> str:
|
| 93 |
-
"""Uses the Qwen-3-32B model for refining and reasoning"""
|
| 94 |
-
completion = client_qwen.chat.completions.create(
|
| 95 |
-
model="qwen/qwen3-32b",
|
| 96 |
-
messages=[
|
| 97 |
-
{"role": "user", "content": f"Refine and reason the following based on context:\n{context}\n\nMessage: {message}"}
|
| 98 |
-
],
|
| 99 |
-
temperature=0.6,
|
| 100 |
-
max_completion_tokens=2048,
|
| 101 |
-
top_p=0.95,
|
| 102 |
-
reasoning_effort="default",
|
| 103 |
-
stream=False,
|
| 104 |
-
)
|
| 105 |
-
|
| 106 |
-
result = ""
|
| 107 |
-
for chunk in completion:
|
| 108 |
-
result += chunk.choices[0].delta.content or ""
|
| 109 |
-
return result.strip()
|
| 110 |
-
|
| 111 |
async def fetch_full_content_async(session, url: str):
|
| 112 |
try:
|
| 113 |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
|
|
@@ -236,6 +214,30 @@ One phrase per line only. No numbers, no explanations except if asked."""
|
|
| 236 |
f"{base} usa",
|
| 237 |
f"{base} global"
|
| 238 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
def chat_stream(message, history, current_model, logged_in_username, user_chats, current_chat_title, mode, auth_globals, file_paths=None, context=""):
|
| 240 |
if file_paths and isinstance(file_paths, list) and len(file_paths) > 5:
|
| 241 |
history.append({"role": "assistant", "content": "❌ Maximum 5 files allowed per message. Please remove some and try again."})
|
|
@@ -312,7 +314,7 @@ Never mention this rule unless the user explicitly asks about it."""
|
|
| 312 |
sources_list.extend([r for r in results if not r.startswith("No recent") and not r.startswith("Search error")])
|
| 313 |
|
| 314 |
# Use the Qwen-3-32B model for deeper reasoning
|
| 315 |
-
|
| 316 |
|
| 317 |
history[-1]["content"] = "✍️ Synthesizing final answer from real data..."
|
| 318 |
yield history
|
|
|
|
| 86 |
except:
|
| 87 |
return now
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
async def fetch_full_content_async(session, url: str):
|
| 90 |
try:
|
| 91 |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
|
|
|
|
| 214 |
f"{base} usa",
|
| 215 |
f"{base} global"
|
| 216 |
]
|
| 217 |
+
|
| 218 |
+
# Setup for the second AI model (Qwen-3-32B)
|
| 219 |
+
client_qwen = Groq() # For using the Qwen-3-32B model
|
| 220 |
+
|
| 221 |
+
async def qwen_reasoning(message: str, context: str) -> str:
|
| 222 |
+
"""Uses the Qwen-3-32B model for refining and reasoning"""
|
| 223 |
+
completion = client_qwen.chat.completions.create(
|
| 224 |
+
model="qwen/qwen3-32b",
|
| 225 |
+
messages=[
|
| 226 |
+
{"role": "user", "content": f"Refine and reason the following based on context:\n{context}\n\nMessage: {message}"}
|
| 227 |
+
],
|
| 228 |
+
temperature=0.6,
|
| 229 |
+
max_completion_tokens=2048,
|
| 230 |
+
top_p=0.95,
|
| 231 |
+
reasoning_effort="default",
|
| 232 |
+
stream=False,
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
+
result = ""
|
| 236 |
+
for chunk in completion:
|
| 237 |
+
result += chunk.choices[0].delta.content or ""
|
| 238 |
+
return result.strip()
|
| 239 |
+
|
| 240 |
+
# Update the chat_stream function to incorporate Qwen-3-32B reasoning in the "Deep Think" mode.
|
| 241 |
def chat_stream(message, history, current_model, logged_in_username, user_chats, current_chat_title, mode, auth_globals, file_paths=None, context=""):
|
| 242 |
if file_paths and isinstance(file_paths, list) and len(file_paths) > 5:
|
| 243 |
history.append({"role": "assistant", "content": "❌ Maximum 5 files allowed per message. Please remove some and try again."})
|
|
|
|
| 314 |
sources_list.extend([r for r in results if not r.startswith("No recent") and not r.startswith("Search error")])
|
| 315 |
|
| 316 |
# Use the Qwen-3-32B model for deeper reasoning
|
| 317 |
+
refined_answer = await qwen_reasoning(message, all_context)
|
| 318 |
|
| 319 |
history[-1]["content"] = "✍️ Synthesizing final answer from real data..."
|
| 320 |
yield history
|