trygithubactions / api /routers /human_idea_refining.py
subashpoudel's picture
Implemented the analytics too in orchestrator
8ce97f0
import logging
from fastapi import APIRouter
from api.stored_data import stored_data
from src.genai.human_refined_ideation.agent import human_refined_idea
from api.schemas.human_idea_refining import RefineIdeationRequest
router= APIRouter()
human_refine_graph = human_refined_idea()
app_logger = logging.getLogger("app_logger")
error_logger = logging.getLogger("error_logger")
@router.get("/human-idea-refining")
def human_idea_refine_endpoint(query:str):
try:
stored_data['human_ideation_interactions'].append({"role": "user", "content": query})
response = human_refine_graph.invoke(
{
'query': stored_data['human_ideation_interactions'],
'business_details': stored_data["business_details"],
'final_ideation': stored_data.get('final_ideation',["","","",""]),
},config={"configurable": {"thread_id": "human-idea-refine-thread"}}
)
stored_data['human_ideation_interactions'].append({"role": "assistant", "content": response['result']})
stored_data['refined_ideation'] = stored_data['human_ideation_interactions'][-1]['content']
app_logger.info('Executed human ideation refining.')
return {'response' : stored_data['human_ideation_interactions'][-1]['content'] }
except Exception as e:
error_logger.error(f'Unable to execute human idea refining agent: {e}')
raise