This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]} | |
*************************************************************** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manager.initiate_chat( | |
manager, | |
message='''What were the key points raised in the 2023 AI safety Summit?''' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openai: | |
api_key: <Add your API Key> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |