Spaces:
Sleeping
Sleeping
| 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") | |
| def human_idea_refine_endpoint(request:RefineIdeationRequest): | |
| try: | |
| stored_data['human_ideation_interactions'].append({"role": "user", "content": request.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": request.thread_id}} | |
| ) | |
| 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('Unable to execute human idea refining agent:', e) | |
| raise | |