Last active
January 5, 2024 22:16
-
-
Save heaversm/da3e9cc4be408df71342037bd02ac109 to your computer and use it in GitHub Desktop.
Run a langchain agent that scrapes google
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
import { OpenAI } from 'langchain/llms'; | |
import { initializeAgentExecutorWithOptions } from 'langchain/agents'; | |
import { SerpAPI } from 'langchain/tools'; | |
const tools = [ | |
new SerpAPI( | |
'[YOUR_API_KEY]' | |
), | |
]; | |
const llm = new OpenAI({ | |
openAIApiKey: '[YOUR_API_KEY]', | |
temperature: 0.9, | |
}); | |
const agent = await initializeAgentExecutorWithOptions(tools, llm, { | |
agentType: 'zero-shot-react-description', | |
verbose: true, | |
}); | |
agent.run('which club is Cristiano Ronaldo playing right now?'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment