Spaces:
Sleeping
Sleeping
Update main.py
Browse files88 unmodified lines89909192939492939495969779 unmodified lines17717817918018018118218316 unmodified lines20020120220320320420520620720720820921010 unmodified lines22122222322422422522622722622722822923017 unmodified lines24824925025125225325125225325425525624 unmodified lines2812822832842842852862876 unmodified lines294295296297297298299300156 unmodified lines45745845946046146246046146246346446524 unmodified lines4904914924934944954934944954964974983 unmodified lines50250350450550550650750847 unmodified lines55655755855956055956056156256388 unmodified lines# ββ Request / Response Models βββββββββββββββββββββββββββββββββββββββββββββββββclass ProblemInput(BaseModel): content: str intern_name: Optional[str] = "Intern" intern_role: Optional[str] = "AI Developer Intern" intern_goal: Optional[str] = "" user_name: Optional[str] = "Anonymous" user_role: Optional[str] = "" user_goal: Optional[str] = ""
class AgentOutput(BaseModel):79 unmodified lines
AGENT_ACTION_PLANNER = """You are the Action Planner Agent.You receive the full analysis. Your job: give the intern 3 concrete next actions.You receive the full analysis. Your job: give the person 3 concrete next actions.
Output format:## Your Next Steps16 unmodified lines**Success looks like**: How you'll know it worked**Time needed**: X hours
Be specific enough that the intern can start immediately. No vague advice."""Be specific enough that the person can start immediately. No vague advice."""
AGENT_THINKING_COACH = """You are the Thinking Coach Agent.You are an encouraging but honest coach helping an intern grow.You are an encouraging but honest coach helping the person think more clearly.You receive the original problem input + full analysis.
Output format:10 unmodified linesOne honest assessment with evidence from their input.
### One Big ShiftThe single most important mindset or approach shift that will help this intern most.The single most important mindset or approach shift for this person.
### For Your Next Meeting3 specific things to do differently next time you face this type of problem.### For Next Time3 specific things to do differently next time this type of problem comes up.
Keep it encouraging but honest. Max 250 words."""
17 unmodified lines """Run all 5 agents in sequence, passing outputs forward."""
context_header = f"""Intern Name: {name}Intern Role: {role}Current Goal: {goal if goal else 'Not specified'}Name: {name}Role: {role if role else "Not specified"}Goal: {goal if goal else "Not specified"}
--- INPUT ---{content[:8000]}24 unmodified lines # Agent 4: Action Planner (receives everything so far) action_plan = run_agent( AGENT_ACTION_PLANNER, f"""Intern Role: {role}\nIntern Goal: {goal} f"""Role: {role}\nGoal: {goal}
Problem Statement:\n{problem_statement}
6 unmodified lines # Agent 5: Thinking Coach (sees original input + full analysis) thinking_feedback = run_agent( AGENT_THINKING_COACH, f"""Original Input from Intern:\n{content[:3000]} f"""Original Input:\n{content[:3000]}
Problem Analysis:\n{problem_statement}
156 unmodified lines try: result = run_pipeline( content=content, name=body.intern_name or "Intern", role=body.intern_role or "AI Developer Intern", goal=body.intern_goal or "", name=body.user_name or "Anonymous", role=body.user_role or "", goal=body.user_goal or "", ) return result except anthropic.AuthenticationError:24 unmodified lines
context = { "content": resolved_content[:8000], "name": body.intern_name or "Intern", "role": body.intern_role or "AI Developer Intern", "goal": body.intern_goal or "", "name": body.user_name or "Anonymous", "role": body.user_role or "", "goal": body.user_goal or "", } accumulated = {}
3 unmodified lines
# Build context-aware prompt for this agent if key == "analyst": user_msg = f"Intern: {context['name']} | Role: {context['role']} | Goal: {context['goal']}\n\nAnalyze this content:\n{context['content']}" user_msg = f"Name: {context['name']} | Role: {context['role']} | Goal: {context['goal']}\n\nAnalyze this content:\n{context['content']}" elif key == "root_cause": user_msg = f"Problem:\n{accumulated.get('analyst','')}\n\nOriginal:\n{context['content'][:2000]}" elif key == "solutions":47 unmodified lines ) pdf_bytes = build_pdf( analysis, name=body.intern_name or "Intern", role=body.intern_role or "AI Developer Intern", name=body.user_name or "Anonymous", role=body.user_role or "", ) filename = f"problem_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf" return StreamingResponse(main.py+23-23