Solshine commited on
Commit
e9ea4f8
1 Parent(s): 4cf81ca

Added autogen agentics from gaiagraph

Browse files
Files changed (1) hide show
  1. app.py +47 -6
app.py CHANGED
@@ -42,12 +42,53 @@ team = [
42
 
43
 
44
  # Prompt and data flow refinement
45
- combined_data = f"{user_prompt}\n{generate_synthetic_data(f'Simulate scenarios for {user_prompt}')}"
46
-
47
- # [TONIC PLEASE HELP LOL]
48
- for agent in team:
49
- combined_data = agent.process(combined_data)
50
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  # Multimedia output production (using Langchain's Text-Davinci-003 as default) because I don't know how to implement DSPy properly yet [TONIC PLEASE HELP LOL]
53
  def produce_outputs(processed_data):
 
42
 
43
 
44
  # Prompt and data flow refinement
45
+ message = f"{user_prompt}\n{generate_synthetic_data(f'Simulate scenarios for {user_prompt}')}"
46
+
47
+ # Agents Group Chat Finite State Machine
48
+ class GroupChatFSM:
49
+ def __init__(self, teams_config):
50
+ """
51
+ Initialize with configurations for teams.
52
+ """
53
+ self.teams = {team_name: self.Team(team_agents) for team_name, team_agents in teams_config.items()}
54
+ self.states = ["waiting", "interacting", "finalizing"]
55
+ self.current_state = "waiting"
56
+
57
+ def transition(self, to_state):
58
+ """
59
+ Transition the state of the group chat based on FSM rules.
60
+ """
61
+ if to_state in self.states:
62
+ self.current_state = to_state
63
+ else:
64
+ raise ValueError("Invalid state transition attempted.")
65
+
66
+ def broadcast(self, message):
67
+ """
68
+ Broadcast a message to all teams based on the current FSM state.
69
+ """
70
+ if self.current_state == "interacting":
71
+ responses = {team_name: team.broadcast(message) for team_name, team in self.teams.items()}
72
+ return responses
73
+ else:
74
+ return "The group chat is not in an interacting state."
75
+
76
+ class Team:
77
+ def __init__(self, agents_config):
78
+ self.agents = [self.Agent(agent_config) for agent_config in agents_config]
79
+
80
+ def broadcast(self, message):
81
+ responses = [agent.respond(message) for agent in self.agents]
82
+ return responses
83
+
84
+ class Agent:
85
+ def __init__(self, config):
86
+ self.agent_name = config['agent_name']
87
+ self.api_key = config['api_key']
88
+ self.model = config['model']
89
+
90
+ def respond(self, message):
91
+ return f"{self.agent_name} responding with {self.model}"
92
 
93
  # Multimedia output production (using Langchain's Text-Davinci-003 as default) because I don't know how to implement DSPy properly yet [TONIC PLEASE HELP LOL]
94
  def produce_outputs(processed_data):