Skip to content

Instantly share code, notes, and snippets.

View john-adeojo's full-sized avatar

John Adeojo john-adeojo

View GitHub Profile
import autogen
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
llm_config=llm_config_user_proxy,
is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),
max_consecutive_auto_reply=10,
code_execution_config=False,
system_message=system_message_user_proxy,
How many Germans live in the colonial
holding in Aruba’s continent that was governed by Prazeres’s country?
--------------------------------------------------------------------------------
analyst (to chat_manager):
***** Suggested function Call: search_and_index_wikipedia *****
Arguments:
{"hops":["Germans","colonial holding in Aruba","Aruba's continent","Prazeres's country"]}
***************************************************************
chat_manager (to chat_manager):
What were the key points raised in the 2023 AI safety Summit?
--------------------------------------------------------------------------------
analyst (to chat_manager):
***** Suggested function Call: search_and_index_wikipedia *****
Arguments:
{"hops":["2023 AI safety Summit","Key points raised in the 2023 AI safety Summit"]}
manager.initiate_chat(
manager,
message='''What were the key points raised in the 2023 AI safety Summit?'''
)
# Assign the tools to the user proxy agent
user_proxy.register_function(
function_map={
"search_and_index_wikipedia": search_and_index_wikipedia,
"query_wiki_index":query_wiki_index,
}
)
# Assign all the agents to the group chat
groupchat = autogen.GroupChat(
moderator = autogen.AssistantAgent(
name="moderator",
system_message='''
As the Moderator, your task is to review the Reporter's answers to ensure they meet the required criteria:
- Assess the Reporter's answers after the "PLEASE REVIEW" prompt for alignment with the following criteria:
A. Precision: Directly addressed the user's question.
B. Depth: Provided comprehensive information using indexed content.
C. Citing: Citations should be encorporated using the Vancouver citation style.
reporter = autogen.AssistantAgent(
name="reporter",
system_message='''
As the Reporter, you are responsible for formulating an answer to the user's
query using the information provided by the Information Gatherer.
1. Wait for the Information Gatherer to complete their task and
present you with the indexed information.
2. Using the gathered data, create a comprehensive and precise response that adheres
to the criteria of precision, depth, clarity, and proper citation.
analyst = autogen.AssistantAgent(
name="analyst",
system_message='''
As the Information Gatherer, you must start by using the `search_and_index_wikipedia`
function to gather relevant data about the user's query. Follow these steps:
1. Upon receiving a query, immediately invoke the `search_and_index_wikipedia`
function to find and index Wikipedia pages related to the query. Do not proceed without completing this step.
2. After successfully indexing, utilize the `query_wiki_index` to extract detailed
information from the indexed content.
openai:
api_key: <Add your API Key>
class CreateCandidateAnswers(dspy.Signature):
"""Generate a candidate answer"""
question = dspy.InputField(desc="Initial question")
candidate = dspy.OutputField(desc="Generate a candidate answer to the initial question")
class SelectCandidateResponse(dspy.Signature):
"""Select the best candidate response"""
question = dspy.InputField(desc="Initial question")
context = dspy.InputField(desc="The candidate answers")
answer = dspy.OutputField(desc="Use the candidate answers to generate a response to the initial question")