Skip to content

Commit

Permalink
feat: added proposal route
Browse files Browse the repository at this point in the history
  • Loading branch information
Luisotee committed Nov 19, 2024
1 parent df0f359 commit 9f7ff4a
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions apps/ai_api/eda_ai_api/api/routes/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,50 @@
from eda_ai_api.models.supervisor import SupervisorRequest, SupervisorResponse
from supervisor.crew import SupervisorCrew
from opportunity_finder.crew import OpportunityFinderCrew
from proposal_writer.crew import ProposalWriterCrew

router = APIRouter()


@router.post("/supervisor", response_model=SupervisorResponse)
async def supervisor_route(request: SupervisorRequest) -> SupervisorResponse:
decision = (
# Get crew decision
crew_response = (
SupervisorCrew().create_crew().kickoff(inputs={"message": request.message})
)

# Print input message
print("\n==================================================")
print(f" INPUT MESSAGE: { request.message} ")
print("==================================================")
# Extract decision from crew response
decision = str(crew_response).lower()

# Print supervisor decision
# Print input message and decision for debugging
print("\n==================================================")
print(f" DECISION: {decision} ")
print(f" INPUT MESSAGE: {request.message}")
print("==================================================")
print(f" DECISION: {decision}")
print("==================================================\n")

# Convert CrewOutput to string and then compare
if str(decision).lower() == "discovery":
topics = ["AI", "Technology"] # Extract topics from message
# Handle different decision paths
if decision == "discovery":
# TODO: Extract topics from the actual message
topics = ["AI", "Technology"]
result = (
OpportunityFinderCrew().crew().kickoff(inputs={"topics": ", ".join(topics)})
)
else:
elif decision == "proposal":
# Initialize ProposalWriterCrew with context from the message
# TODO: Extract project and grant details from message
community_project = "sample_project" # This should come from message parsing
grant_call = "sample_grant" # This should come from message parsing
result = (
ProposalWriterCrew(
community_project=community_project, grant_call=grant_call
)
.crew()
.kickoff()
)
elif decision == "heartbeat":
result = {"is_alive": True}
else:
result = {"error": f"Unknown decision type: {decision}"}

return SupervisorResponse(result=str(result))

0 comments on commit 9f7ff4a

Please sign in to comment.