Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -226,7 +226,7 @@ def fetch_news(query, num_results=20):
|
|
226 |
else:
|
227 |
return []
|
228 |
|
229 |
-
|
230 |
def analyze_news(query):
|
231 |
news_data = fetch_news(query)
|
232 |
|
@@ -245,7 +245,6 @@ def analyze_news(query):
|
|
245 |
return messages
|
246 |
|
247 |
@app.post("/news-assistant")
|
248 |
-
@cache(expire=3600)
|
249 |
async def news_assistant(query: NewsQueryModel, api_key: str = Depends(verify_api_key)):
|
250 |
"""
|
251 |
News assistant endpoint that provides summaries and analysis of recent news based on user queries.
|
@@ -255,7 +254,8 @@ async def news_assistant(query: NewsQueryModel, api_key: str = Depends(verify_ap
|
|
255 |
|
256 |
if not messages:
|
257 |
raise HTTPException(status_code=500, detail="Failed to fetch news data")
|
258 |
-
|
|
|
259 |
def process_response():
|
260 |
for content in chat_with_llama_stream(messages, model="google/gemini-pro-1.5"):
|
261 |
yield content
|
|
|
226 |
else:
|
227 |
return []
|
228 |
|
229 |
+
@cache(expire=3600)
|
230 |
def analyze_news(query):
|
231 |
news_data = fetch_news(query)
|
232 |
|
|
|
245 |
return messages
|
246 |
|
247 |
@app.post("/news-assistant")
|
|
|
248 |
async def news_assistant(query: NewsQueryModel, api_key: str = Depends(verify_api_key)):
|
249 |
"""
|
250 |
News assistant endpoint that provides summaries and analysis of recent news based on user queries.
|
|
|
254 |
|
255 |
if not messages:
|
256 |
raise HTTPException(status_code=500, detail="Failed to fetch news data")
|
257 |
+
|
258 |
+
@cache(expire=3600)
|
259 |
def process_response():
|
260 |
for content in chat_with_llama_stream(messages, model="google/gemini-pro-1.5"):
|
261 |
yield content
|