From c3f6378dbc7a7347589c3676251d4de02fd1019d Mon Sep 17 00:00:00 2001 From: Aquibpy Date: Wed, 29 May 2024 15:42:38 +0530 Subject: [PATCH] MODIFIED: due to some issue in pip disabling news_agent route --- api.py | 54 ++++++++++++++++++++++++------------------------ requirements.txt | 6 +++--- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/api.py b/api.py index 3942e62..e8119f1 100644 --- a/api.py +++ b/api.py @@ -29,7 +29,7 @@ from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail from uuid import uuid4 -from tech_news_agent.crew import run_crew +# from tech_news_agent.crew import run_crew os.environ["LANGCHAIN_TRACING_V2"]="true" @@ -628,32 +628,32 @@ async def get_data(endpoint_name: str, token: str = Depends(oauth2_scheme)): return data -@app.post("/news_agent",description=""" - This endpoint leverages AI agents to conduct research and generate articles on various tech topics. - The agents are designed to uncover groundbreaking technologies and narrate compelling tech stories - """) -async def run_news_agent(topic: str = Form("AI in healthcare")): - try: - cache_key = f"news_agent:{topic}" - cached_response = redis.get(cache_key) - if cached_response: - print("Retrieving response from Redis cache") - return ResponseText(response=cached_response.decode("utf-8")) - - output = run_crew(topic=topic) - redis.set(cache_key, output, ex=10) - db = MongoDB() - payload = { - "endpoint": "/news_agent", - "topic" : topic, - "output": output - } - mongo_data = {"Document": payload} - result = db.insert_data(mongo_data) - print(result) - return ResponseText(response=output) - except Exception as e: - return {"error": str(e)} +# @app.post("/news_agent",description=""" +# This endpoint leverages AI agents to conduct research and generate articles on various tech topics. +# The agents are designed to uncover groundbreaking technologies and narrate compelling tech stories +# """) +# async def run_news_agent(topic: str = Form("AI in healthcare")): +# try: +# cache_key = f"news_agent:{topic}" +# cached_response = redis.get(cache_key) +# if cached_response: +# print("Retrieving response from Redis cache") +# return ResponseText(response=cached_response.decode("utf-8")) + +# output = run_crew(topic=topic) +# redis.set(cache_key, output, ex=10) +# db = MongoDB() +# payload = { +# "endpoint": "/news_agent", +# "topic" : topic, +# "output": output +# } +# mongo_data = {"Document": payload} +# result = db.insert_data(mongo_data) +# print(result) +# return ResponseText(response=output) +# except Exception as e: +# return {"error": str(e)} if __name__ == '__main__': import uvicorn diff --git a/requirements.txt b/requirements.txt index 2c2515d..13f570c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,6 +24,6 @@ python-jose sendgrid llama-index-llms-groq llama-index-embeddings-langchain -crewai -crewai[tools] -proto-plus \ No newline at end of file +# crewai +# crewai-tools +# proto-plus \ No newline at end of file