Spaces:
Sleeping
Sleeping
| from fastapi import APIRouter | |
| from pydantic import BaseModel | |
| from typing import Optional | |
| from api.stored_data import stored_data | |
| from src.genai.human_refined_ideation.agent import human_refined_idea | |
| router= APIRouter() | |
| human_refine_graph = human_refined_idea() | |
| class RefineIdeationRequest(BaseModel): | |
| query: str | |
| thread_id: Optional[str]="refine_ideas_thread" | |
| def human_idea_refine_endpoint(request:RefineIdeationRequest): | |
| 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'] | |
| return {'response' : stored_data['human_ideation_interactions'][-1]['content'] } |