Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,11 +61,13 @@ async def perform_tavily_search(query: str):
|
|
| 61 |
def _search():
|
| 62 |
try:
|
| 63 |
client = TavilyClient(api_key=TAVILY_API_KEY)
|
| 64 |
-
#
|
|
|
|
|
|
|
| 65 |
response = client.search(
|
| 66 |
query=query,
|
| 67 |
search_depth="basic",
|
| 68 |
-
max_results=
|
| 69 |
include_answer=True
|
| 70 |
)
|
| 71 |
text = ""
|
|
@@ -73,7 +75,7 @@ async def perform_tavily_search(query: str):
|
|
| 73 |
text += f"Summary: {response['answer']}\n"
|
| 74 |
|
| 75 |
for i, res in enumerate(response.get("results", [])):
|
| 76 |
-
text += f"[{i+1}] {res['content'][:
|
| 77 |
return text
|
| 78 |
except: return None
|
| 79 |
return await asyncio.to_thread(_search)
|
|
@@ -158,7 +160,6 @@ async def chat_endpoint(request: ChatRequest):
|
|
| 158 |
if search_results:
|
| 159 |
status = "Search on web"
|
| 160 |
# === SPEED OPTIMIZED INSTRUCTION ===
|
| 161 |
-
# Instruction ko 3 simple steps me tod diya hai
|
| 162 |
modified_user_msg = (
|
| 163 |
f"### CONTEXT FROM WEB SEARCH:\n"
|
| 164 |
f"{search_results}\n\n"
|
|
|
|
| 61 |
def _search():
|
| 62 |
try:
|
| 63 |
client = TavilyClient(api_key=TAVILY_API_KEY)
|
| 64 |
+
# === OPTIMIZED VALUES FOR SPEED ===
|
| 65 |
+
# max_results: 4 (Balanced)
|
| 66 |
+
# Content length: 500 chars (Faster processing)
|
| 67 |
response = client.search(
|
| 68 |
query=query,
|
| 69 |
search_depth="basic",
|
| 70 |
+
max_results=4,
|
| 71 |
include_answer=True
|
| 72 |
)
|
| 73 |
text = ""
|
|
|
|
| 75 |
text += f"Summary: {response['answer']}\n"
|
| 76 |
|
| 77 |
for i, res in enumerate(response.get("results", [])):
|
| 78 |
+
text += f"[{i+1}] {res['content'][:500]}...\n"
|
| 79 |
return text
|
| 80 |
except: return None
|
| 81 |
return await asyncio.to_thread(_search)
|
|
|
|
| 160 |
if search_results:
|
| 161 |
status = "Search on web"
|
| 162 |
# === SPEED OPTIMIZED INSTRUCTION ===
|
|
|
|
| 163 |
modified_user_msg = (
|
| 164 |
f"### CONTEXT FROM WEB SEARCH:\n"
|
| 165 |
f"{search_results}\n\n"
|