-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...Fascinating World of Autonomous Agents: A Closer Look at AutoGPT and BabyAGI/1_babyagi.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from langchain.embeddings import OpenAIEmbeddings | ||
import faiss | ||
from langchain.vectorstores import FAISS | ||
from langchain.docstore import InMemoryDocstore | ||
|
||
# Define the embedding model | ||
embeddings_model = OpenAIEmbeddings(model="text-embedding-ada-002") | ||
|
||
# Initialize the vectorstore | ||
embedding_size = 1536 | ||
index = faiss.IndexFlatL2(embedding_size) | ||
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {}) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
from langchain import OpenAI | ||
from langchain_experimental.autonomous_agents import BabyAGI | ||
|
||
# set the goal | ||
goal = "Plan a trip to the Grand Canyon" | ||
|
||
# create thebabyagi agent | ||
# If max_iterations is None, the agent may go on forever if stuck in loops | ||
baby_agi = BabyAGI.from_llm( | ||
llm=OpenAI(model="gpt-3.5-turbo-instruct", temperature=0), | ||
vectorstore=vectorstore, | ||
verbose=False, | ||
max_iterations=3 | ||
) | ||
response = baby_agi({"objective": goal}) |
1 change: 1 addition & 0 deletions
1
...inating World of Autonomous Agents: A Closer Look at AutoGPT and BabyAGI/requirements.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
faiss-cpu |
59 changes: 59 additions & 0 deletions
59
...nguage Model as Reasoning Engines with Agents/3 Using AutoGPT with LangChain/1_autogpt.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from langchain.utilities import GoogleSearchAPIWrapper | ||
from langchain.agents import Tool | ||
from langchain.tools.file_management.write import WriteFileTool | ||
from langchain.tools.file_management.read import ReadFileTool | ||
|
||
#Set up the tools | ||
search = GoogleSearchAPIWrapper() | ||
tools = [ | ||
Tool( | ||
name = "search", | ||
func=search.run, | ||
description="Useful for when you need to answer questions about current events. You should ask targeted questions", | ||
return_direct=True | ||
), | ||
WriteFileTool(), | ||
ReadFileTool(), | ||
] | ||
|
||
|
||
|
||
# Set up the memory | ||
from langchain.vectorstores import FAISS | ||
from langchain.docstore import InMemoryDocstore | ||
from langchain.embeddings import OpenAIEmbeddings | ||
|
||
embeddings_model = OpenAIEmbeddings(model="text-embedding-ada-002") | ||
embedding_size = 1536 | ||
|
||
import faiss | ||
index = faiss.IndexFlatL2(embedding_size) | ||
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {}) | ||
|
||
|
||
|
||
|
||
|
||
# Set up the model and AutoGPT | ||
from langchain_experimental.autonomous_agents import AutoGPT | ||
from langchain.chat_models import ChatOpenAI | ||
|
||
agent = AutoGPT.from_llm_and_tools( | ||
ai_name="Jim", | ||
ai_role="Assistant", | ||
tools=tools, | ||
llm=ChatOpenAI(model="gpt-3.5-turbo", temperature=0), | ||
memory=vectorstore.as_retriever() | ||
) | ||
|
||
# Set verbose to be true | ||
agent.chain.verbose = True | ||
|
||
|
||
|
||
|
||
task = "Provide an analysis of the major historical events that led to the French Revolution" | ||
|
||
agent.run([task]) | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
...Reasoning Engines with Agents/3 Using AutoGPT with LangChain/French_Revolution_Events.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1. Lead-in To War: 1763 to 1774 - The Treaty of Paris ends the Seven Years War (French and Indian War) but leaves France in financial crisis. | ||
2. 1789 - France declares war on Austria. | ||
3. April 20, 1792 - France declares war on Austria. | ||
4. April 25, 1792 - First use of the guillotine. | ||
5. June 13, 1792 - Prussia declares war on France. | ||
6. Coup of 18–19 Brumaire - Napoleon Bonaparte seizes power in France, marking the end of the French Revolution and the beginning of the Napoleonic era. |