Skip to content

Instantly share code, notes, and snippets.

@kfsone
Created December 1, 2023 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfsone/4db4156fc77eb7a9ce6c09ae59278764 to your computer and use it in GitHub Desktop.
Save kfsone/4db4156fc77eb7a9ce6c09ae59278764 to your computer and use it in GitHub Desktop.
Product-Research-Agent-Team
import autogen
from textwrap import dedent
import os
try:
del os.environ['OPENAI_API_BASE']
except:
pass
os.putenv("OPENAI_API_BASE", "http://localhost:5000")
os.putenv("OPENAI_API_KEY", "None")
model_list = [
{ 'model': 'mistral-16k', 'base_url': 'http://localhost:5000/v1', 'api_key': "None", 'max_tokens': '16384' }
]
gpt4_config = {
"cache_seed": 185, # change the cache_seed for different trials
"temperature": .6,
"config_list": model_list,
"timeout": 250,
}
common_text = "Since all team members are AIs you do not use platitudes, small talk, banter or pleasantries in your responses."
titles = {
'adm': "Admin",
'jr': "Junior",
'exp': "Expert",
'lib': "Librarian",
'rsc': "Researcher",
'an': "Analyst",
'prd': "Producer",
'rev': "Reviewer",
}
def textproc(text):
return dedent(text.format(**titles)).strip()
def assistant(ident, role, **kwargs):
name = titles[ident]
role = role.strip().rstrip(".")
message = f"{name.strip()}. {textproc(role)}. {textproc(common_text)}".strip()
print(f"{name:15s} -> {message}")
return autogen.UserProxyAgent(name, system_message=message, **kwargs)
user_proxy = autogen.UserProxyAgent(
name=titles['adm'],
system_message=f"{titles['adm']}. A human admin. Interact with the {titles['prd']} to discuss the plan. Plan execution needs to be approved by this admin.",
code_execution_config=False,
)
junior = assistant(
'jr', """
You assist the {exp} by fetching content from multiple websites related to each request, extracting important knowledge about technologies or products, such as key terms, insights, indicators, factors, etc. Indicate the urls where information originated from. You may require the assistance of the {lib} to identify lists of useful sites to retrieve data from.
"""
)
expert = assistant(
'exp', """
You assist the {prd} and other team members by directing the {jr} to fetch relevant summaries from multiple sites regarding specified subject matter. You correlate findings from the {jr} to determine reliable sources and useful data, being mindful of excessive marketing pitch or sponsored posts. You may additionally cross check against sites like reddit, quora, etc. You may advise the {lib} of sites with reliable/robust sources of data, or which appear low quality/stale/unreliable. Your emphasis is on domain knowledge/information rather than specific products.
"""
)
librarian = assistant(
'lib', """
You assist the {prd}, {jr}, {rsc} and {an} by searching the web for viable sources of subject data specific to their requests and provide links to several candidates. You select a subset of the potential candidates that appear to be relatively current, factual, well written, and free of obvious search-engine manipulation. You do not try to judge the suitability of the requested subject matter or sites beyond the degree of relevance to the requested subject. You do not present data from the sites themselves. Avoid sites that appear to be facades or aliases for each other, and try to ensure that you offer links that are relatively varied in style/content.
""")
researcher = assistant(
'rsc', """
You assist the {prd} in developing a plan by gathering data from the {exp} to identify product and search criteria.
When executing the plan, you focus on gathering data about specific products/manufacturers/vendors from sites suggested by the {lib}, specified by the {prd}, focusing on product specs/data, and available reviews. You may advise the {lib} of sites that appear low quality or unreliable.
""")
analyst = assistant(
'an', """
You are responsible for applying the plan provided by the {prd} to data the {rsc} gathers provide regarding potentially suitable products, and coordinate with the {exp} and {lib} to find articles, guides and advisory articles that provide reviews.
During execution of the plan you use data in the plan to gather reviews about products and provide initial conclusions and recommendations to the {rev}. You extract and summarize data with manufacturer name, product name/summary, model, with links. Look for key words/markers identified in the plan by the {exp} and discard products that do not align well with that or the plan itself have largely negative reviews.
""")
producer = assistant(
'prd', """
You are responsible for developing a plan to comply with the Admin's request. Coordinate with the {exp}, {lib} and {rsc} to develop the plan and when these all agree with the plan, confirm it with the {adm}. {adm} confirmation is required before proceeding with execution. You do not attempt to fulfil the request directly yourself, only coordinate.
The plan may involve the {exp} and {rsc} gathering and preparing data for the {an} to process into a table of product reviews and shopping guidance.
Explain the plan first. Be clear which step is to be performed by {exp}, {rsc}, {an} or {rev}.
""")
reviewer = assistant(
'rev', """
You follow a plan provided by the {prd} to work in conjunction with the {an} to process summary recommendations and shopping guidance. Ensure the {an} provides links to 3 or more reviews for each product, confirm that descriptions/summary/review information includes any key terms etc provided by the {exp}. Also summarize any significant findings about the subject domain that might consumers of your data in improving subject requests or making more information shopping decisions.
""")
groupchat = autogen.GroupChat(agents=[user_proxy, producer, junior, expert, librarian, researcher, analyst, reviewer], messages=[], max_round=5000)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=gpt4_config)
user_proxy.initiate_chat(
manager,
message="""
Develop and execute a plan to evaluate and recommend 5 consumer 3D fdm printers that use 1.75mm filament that have been released within the last 3 years. Primary factors should be ease of use, simplicity of maintenance and low maintenance, durability, reliability and quality of prints. Restrict to printers with a print volume having at one or more axis that is 10in/250mm or greater.
"""
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment