forked from marc-shade/TeamForgeAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_workflow.py
38 lines (33 loc) · 2.07 KB
/
search_workflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# TeamForgeAI/search_workflow.py
from autogen.agentchat import GroupChat, GroupChatManager
from ollama_llm import OllamaLLM
from skills.web_search import gather_search_results, synthesize_search_results # Import the functions
def initiate_search_workflow(query: str, create_autogen_agent, OllamaGroupChatManager, update_discussion_and_whiteboard, teachability=True): # Accept teachability
"""Initiates the multi-agent search workflow."""
# Create agents, passing the teachability object
search_agent = create_autogen_agent({
"config": {"name": "Search Agent", "system_message": "You are a helpful search agent."},
"model": "mistral:7b-instruct-v0.2-fp16",
"enable_memory": True,
"db_path": "./db/search_agent"
}, teachability=teachability) # Pass teachability to create_autogen_agent
analyst_agent = create_autogen_agent({
"config": {"name": "Analyst Agent", "system_message": "You are a helpful analyst agent."},
"model": "mistral:7b-instruct-v0.3-q8_0",
"enable_memory": True,
"db_path": "./db/analyst_agent"
}, teachability=teachability) # Pass teachability to create_autogen_agent
synthesizer_agent = create_autogen_agent({
"config": {"name": "Synthesizer Agent", "system_message": "You are a helpful synthesizer agent."},
"model": "mistral:7b-instruct-v0.3-q8_0",
"enable_memory": True,
"db_path": "./db/synthesizer_agent"
}, teachability=teachability) # Pass teachability to create_autogen_agent
# Ensure discussion history is retrieved from session state
discussion_history = st.session_state.get("discussion_history", "")
# Gather search results
search_results = gather_search_results(query, discussion_history, [search_agent, analyst_agent, synthesizer_agent], teachability=teachability)
# Synthesize search results
synthesized_summary = synthesize_search_results(search_results, discussion_history, teachability)
# Update discussion history with synthesized summary
update_discussion_and_whiteboard("Synthesizer Agent", synthesized_summary, "")