Skip to content

Instantly share code, notes, and snippets.

@heaversm
Last active January 5, 2024 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save heaversm/da3e9cc4be408df71342037bd02ac109 to your computer and use it in GitHub Desktop.
Save heaversm/da3e9cc4be408df71342037bd02ac109 to your computer and use it in GitHub Desktop.
Run a langchain agent that scrapes google
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