Coverage for examples/cli/main_console.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-19 12:16 +0000

1import os 1bacde

2from typing import Any 1bacde

3 

4from autogen import ConversableAgent, LLMConfig 1bacde

5 

6from fastagency import UI, FastAgency 1bacde

7from fastagency.runtimes.ag2 import Workflow 1bacde

8from fastagency.ui.console import ConsoleUI 1bacde

9 

10llm_config = LLMConfig( 1bacde

11 model="gpt-4o-mini", 

12 api_key=os.getenv("OPENAI_API_KEY"), 

13 temperature=0.8, 

14) 

15 

16 

17wf = Workflow() 1bacde

18 

19 

20@wf.register(name="simple_learning", description="Student and teacher learning chat") 1bacde

21def simple_workflow(ui: UI, params: dict[str, Any]) -> str: 1bacde

22 initial_message = ui.text_input( 1a

23 sender="Workflow", 

24 recipient="User", 

25 prompt="I can help you learn about mathematics. What subject you would like to explore?", 

26 ) 

27 

28 with llm_config: 1a

29 student_agent = ConversableAgent( 1a

30 name="Student_Agent", 

31 system_message="You are a student willing to learn.", 

32 ) 

33 teacher_agent = ConversableAgent( 1a

34 name="Teacher_Agent", 

35 system_message="You are a math teacher.", 

36 ) 

37 

38 response = student_agent.run( 1a

39 teacher_agent, 

40 message=initial_message, 

41 summary_method="reflection_with_llm", 

42 max_turns=5, 

43 ) 

44 

45 return ui.process(response) 1a

46 

47 

48app = FastAgency(provider=wf, ui=ConsoleUI()) 1bacde