Spaces:
Sleeping
Sleeping
| import logging | |
| from fastapi import APIRouter | |
| from api.stored_data import stored_data | |
| from src.genai.orchestration_agent.agent import OrchestrationAgent | |
| from api.schemas.orchestration import OrchestrationRequest | |
| app_logger = logging.getLogger("app_logger") | |
| error_logger = logging.getLogger("error_logger") | |
| router= APIRouter() | |
| agent = OrchestrationAgent() | |
| def orchestration_endpoint(request:OrchestrationRequest): | |
| try: | |
| result = agent.chat(request.message , request.image_base64) | |
| if result.image_caption != '': stored_data['image_caption']=result.image_caption | |
| if result.video_idea !='' or result.video_idea != 'null': stored_data['refined_ideation']= result.video_idea | |
| if result.video_story!='' or result.video_story!='null': stored_data['final_story']= result.video_story | |
| app_logger.info('Orchestrator executed') | |
| return {'tool_response': result.tool , | |
| 'message_response': result.query_response, | |
| 'image_caption':result.image_caption, | |
| 'video_idea': result.video_idea, | |
| 'video_story': result.video_story} | |
| except Exception as e: | |
| error_logger.error('Unable to run orchestration:', e) | |
| raise | |