Coverage for docs/docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/workflow.py: 100%
10 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-19 12:16 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-19 12:16 +0000
1import os 1a
2from typing import Any 1a
4from autogen import ConversableAgent, LLMConfig 1a
5from fastagency import UI 1a
6from fastagency.runtimes.ag2 import Workflow 1a
8llm_config = LLMConfig( 1a
9 model="gpt-4o-mini",
10 api_key=os.getenv("OPENAI_API_KEY"),
11 temperature=0.8,
12)
14wf = Workflow() 1a
17@wf.register(name="simple_learning", description="Student and teacher learning chat") # type: ignore[misc] 1a
18def simple_workflow(ui: UI, params: dict[str, Any]) -> str: 1a
19 initial_message = ui.text_input( 1a
20 sender="Workflow",
21 recipient="User",
22 prompt="I can help you learn about mathematics. What subject you would like to explore?",
23 )
25 with llm_config: 1a
26 student_agent = ConversableAgent( 1a
27 name="Student_Agent",
28 system_message="You are a student willing to learn.",
29 )
30 teacher_agent = ConversableAgent( 1a
31 name="Teacher_Agent",
32 system_message="You are a math teacher.",
33 )
35 response = student_agent.run( 1a
36 teacher_agent,
37 message=initial_message,
38 summary_method="reflection_with_llm",
39 max_turns=3,
40 )
42 return ui.process(response) # type: ignore[no-any-return] 1a