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在開源項目的快速發展的景觀中蓬勃發展。我們全心全意地歡迎各種能力,無論是通過創新功能,增強的基礎設施還是精緻文檔。
有關貢獻過程的全面指南,請單擊此處。