Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -310,7 +310,7 @@ class QueryModel(BaseModel):
|
|
310 |
}
|
311 |
}
|
312 |
|
313 |
-
def assistant_api(query, data_type):
|
314 |
logger.info(f"Received {data_type} assistant query: {query}")
|
315 |
messages = analyze_data(query, data_type)
|
316 |
|
@@ -321,7 +321,7 @@ def assistant_api(query, data_type):
|
|
321 |
def process_response():
|
322 |
logger.info(f"Generating response using LLM: {messages}")
|
323 |
full_response = ""
|
324 |
-
for content in chat_with_llama_stream(messages, model=
|
325 |
full_response += content
|
326 |
yield content
|
327 |
logger.info(f"Completed {data_type} assistant response for query: {query}")
|
@@ -335,7 +335,7 @@ async def news_assistant(query: QueryModel, api_key: str = Depends(verify_api_ke
|
|
335 |
News assistant endpoint that provides summaries and analysis of recent news based on user queries.
|
336 |
Requires API Key authentication via X-API-Key header.
|
337 |
"""
|
338 |
-
return assistant_api(query.query, "news")
|
339 |
|
340 |
@app.post("/search-assistant")
|
341 |
async def search_assistant(query: QueryModel, api_key: str = Depends(verify_api_key)):
|
@@ -343,7 +343,7 @@ async def search_assistant(query: QueryModel, api_key: str = Depends(verify_api_
|
|
343 |
Search assistant endpoint that provides summaries and analysis of web search results based on user queries.
|
344 |
Requires API Key authentication via X-API-Key header.
|
345 |
"""
|
346 |
-
return assistant_api(query.query, "search")
|
347 |
|
348 |
from pydantic import BaseModel, Field
|
349 |
import yaml
|
|
|
310 |
}
|
311 |
}
|
312 |
|
313 |
+
def assistant_api(query, data_type,model = "openai/gpt-4o-mini"):
|
314 |
logger.info(f"Received {data_type} assistant query: {query}")
|
315 |
messages = analyze_data(query, data_type)
|
316 |
|
|
|
321 |
def process_response():
|
322 |
logger.info(f"Generating response using LLM: {messages}")
|
323 |
full_response = ""
|
324 |
+
for content in chat_with_llama_stream(messages, model=model):
|
325 |
full_response += content
|
326 |
yield content
|
327 |
logger.info(f"Completed {data_type} assistant response for query: {query}")
|
|
|
335 |
News assistant endpoint that provides summaries and analysis of recent news based on user queries.
|
336 |
Requires API Key authentication via X-API-Key header.
|
337 |
"""
|
338 |
+
return assistant_api(query.query, "news",model=query.model_id)
|
339 |
|
340 |
@app.post("/search-assistant")
|
341 |
async def search_assistant(query: QueryModel, api_key: str = Depends(verify_api_key)):
|
|
|
343 |
Search assistant endpoint that provides summaries and analysis of web search results based on user queries.
|
344 |
Requires API Key authentication via X-API-Key header.
|
345 |
"""
|
346 |
+
return assistant_api(query.query, "search",model=query.model_id)
|
347 |
|
348 |
from pydantic import BaseModel, Field
|
349 |
import yaml
|