Spaces:
Sleeping
Sleeping
Update main.py
Browse files88 unmodified lines89909192939495969779 unmodified lines17717817918018118218316 unmodified lines20020120220320420520620720820921010 unmodified lines22122222322422522622722822923017 unmodified lines24824925025125225325425525624 unmodified lines2812822832842852862876 unmodified lines294295296297298299300156 unmodified lines45745845946046146246346446524 unmodified lines4904914924934944954964974983 unmodified lines50250350450550650750847 unmodified lines55655755855956056156256388 unmodified lines# ββ Request / Response Models βββββββββββββββββββββββββββββββββββββββββββββββββclass ProblemInput(BaseModel):content: strintern_name: Optional[str] = "Intern"intern_role: Optional[str] = "AI Developer Intern"intern_goal: Optional[str] = ""class AgentOutput(BaseModel):79 unmodified linesAGENT_ACTION_PLANNER = """You are the Action Planner Agent.You receive the full analysis. Your job: give the intern 3 concrete next actions.Output format:## Your Next Steps16 unmodified lines**Success looks like**: How you'll know it worked**Time needed**: X hoursBe specific enough that the intern 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 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.### For Your Next Meeting3 specific things to do differently next time you face this type of problem.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'}--- 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}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]}Problem Analysis:\n{problem_statement}156 unmodified linestry:result = run_pipeline(content=content,name=body.intern_name or "Intern",role=body.intern_role or "AI Developer Intern",goal=body.intern_goal or "",)return resultexcept anthropic.AuthenticationError:24 unmodified linescontext = {"content": resolved_content[:8000],"name": body.intern_name or "Intern","role": body.intern_role or "AI Developer Intern","goal": body.intern_goal or "",}accumulated = {}3 unmodified lines# Build context-aware prompt for this agentif key == "analyst":user_msg = f"Intern: {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",)filename = f"problem_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"return StreamingResponse(88 unmodified lines89909192939495969779 unmodified lines17717817918018118218316 unmodified lines20020120220320420520620720820921010 unmodified lines22122222322422522622722822923017 unmodified lines24824925025125225325425525624 unmodified lines2812822832842852862876 unmodified lines294295296297298299300156 unmodified lines45745845946046146246346446524 unmodified lines4904914924934944954964974983 unmodified lines50250350450550650750847 unmodified lines55655755855956056156256388 unmodified lines# ββ Request / Response Models βββββββββββββββββββββββββββββββββββββββββββββββββclass ProblemInput(BaseModel):content: struser_name: Optional[str] = "Anonymous"user_role: Optional[str] = ""user_goal: Optional[str] = ""class AgentOutput(BaseModel):79 unmodified linesAGENT_ACTION_PLANNER = """You are the Action Planner Agent.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 hoursBe 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 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 for this person.### 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"""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"""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:\n{content[:3000]}Problem Analysis:\n{problem_statement}156 unmodified linestry:result = run_pipeline(content=content,name=body.user_name or "Anonymous",role=body.user_role or "",goal=body.user_goal or "",)return resultexcept anthropic.AuthenticationError:24 unmodified linescontext = {"content": resolved_content[:8000],"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 agentif key == "analyst":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.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