openagi
0.2.9.8

Openagi的目标是使每个人都可以使用类似人类的代理商,从而为开放代理商铺平了道路,并最终为所有人铺平了AGI。我们坚信AI的变革力量,并有信心这项倡议将有助于解决许多现实生活中的问题。目前,OpenAgi旨在为开发人员提供一个创建自主类人类代理的框架。
加入我们的Discord社区! # For Mac and Linux users
python3 -m venv venv
source venv/bin/activate
# For Windows users
python -m venv venv
venv/scripts/activatepip install openagi或者
git clone https://github.com/aiplanethub/openagi.git
pip install -e .
工人用于创建多代理体系结构。
请按照此示例创建一个旅行计划代理,该示例可以帮助您计划SF的行程。
from openagi . agent import Admin
from openagi . planner . task_decomposer import TaskPlanner
from openagi . actions . tools . ddg_search import DuckDuckGoSearch
from openagi . llms . openai import OpenAIModel
from openagi . worker import Worker
plan = TaskPlanner ( human_intervene = False )
action = DuckDuckGoSearch
import os
os . environ [ 'OPENAI_API_KEY' ] = "sk-xxxx"
config = OpenAIModel . load_from_env_config ()
llm = OpenAIModel ( config = config )
trip_plan = Worker (
role = "Trip Planner" ,
instructions = """
User loves calm places, suggest the best itinerary accordingly.
""" ,
actions = [ action ],
max_iterations = 10 )
admin = Admin (
llm = llm ,
actions = [ action ],
planner = plan ,
)
admin . assign_workers ([ trip_plan ])
res = admin . run (
query = "Give me total 3 Days Trip to San francisco Bay area" ,
description = "You are a knowledgeable local guide with extensive information about the city, it's attractions and customs" ,
)
print ( res )现在,让我们建立一个体育代理,可以在没有任何工人的情况下自主运行。
from openagi . planner . task_decomposer import TaskPlanner
from openagi . actions . tools . tavilyqasearch import TavilyWebSearchQA
from openagi . agent import Admin
from openagi . llms . gemini import GeminiModel
import os
os . environ [ 'TAVILY_API_KEY' ] = "<replace with Tavily key>"
os . environ [ 'GOOGLE_API_KEY' ] = "<replace with Gemini key>"
os . environ [ 'Gemini_MODEL' ] = "gemini-1.5-flash"
os . environ [ 'Gemini_TEMP' ] = "0.1"
gemini_config = GeminiModel . load_from_env_config ()
llm = GeminiModel ( config = gemini_config )
# define the planner
plan = TaskPlanner ( autonomous = True , human_intervene = True )
admin = Admin (
actions = [ TavilyWebSearchQA ],
planner = plan ,
llm = llm ,
)
res = admin . run (
query = "I need cricket updates from India vs Sri lanka 2024 ODI match in Sri Lanka" ,
description = f"give me the results of India vs Sri Lanka ODI and respective Man of the Match" ,
)
print ( res )使用LTM,Openagi代理现在可以:
import os
from openagi . agent import Admin
from openagi . llms . openai import OpenAIModel
from openagi . memory import Memory
from openagi . planner . task_decomposer import TaskPlanner
from openagi . worker import Worker
from openagi . actions . tools . ddg_search import DuckDuckGoSearch
memory = Memory ( long_term = True )
os . environ [ 'OPENAI_API_KEY' ] = "-"
config = OpenAIModel . load_from_env_config ()
llm = OpenAIModel ( config = config )
web_searcher = Worker (
role = "Web Researcher" ,
instructions = """
You are tasked with conducting web searches using DuckDuckGo.
Find the most relevant and accurate information based on the user's query.
""" ,
actions = [ DuckDuckGoSearch ],
)
admin = Admin (
actions = [ DuckDuckGoSearch ],
planner = TaskPlanner ( human_intervene = False ),
memory = memory ,
llm = llm ,
)
admin . assign_workers ([ web_searcher ])
query = input ( "Enter your search query: " )
description = f"Find accurate and relevant information for the query: { query } "
res = admin . run ( query = query , description = description )
print ( res )有关更多查询
有关任何查询/建议/支持
Openagi在开源项目的快速发展的景观中蓬勃发展。我们全心全意地欢迎各种能力,无论是通过创新功能,增强的基础设施还是精致文档。
有关贡献过程的综合指南,请单击此处。