Skip to content

Commit 1d9d820

Browse files
refactor(docs): update agent integration examples for Serpex in JavaScript and Python
1 parent 5073ceb commit 1d9d820

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

src/oss/javascript/integrations/tools/serpex_search_js.mdx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ console.log(toolMsg.content.substring(0, 500));
8787

8888
## Use within an agent
8989

90-
We can use our tools directly with an agent executor by binding the tool to the agent. This gives the agent the ability to dynamically search for information.
90+
We can use our tools directly with an agent by creating an agent with the tool. This gives the agent the ability to dynamically search for information.
9191

9292
```typescript
9393
import { ChatOpenAI } from "@langchain/openai";
94-
import { AgentExecutor, createOpenAIFunctionsAgent } from "langchain/agents";
95-
import { ChatPromptTemplate } from "@langchain/core/prompts";
94+
import { createAgent } from "langchain";
9695
import { Serpex } from "langchain-serpex-js";
9796

9897
// Initialize the search tool
@@ -105,26 +104,14 @@ const searchTool = new Serpex("your-serpex-api-key", {
105104
const llm = new ChatOpenAI({ model: "gpt-4", temperature: 0 });
106105

107106
// Create an agent with the search tool
108-
const prompt = ChatPromptTemplate.fromMessages([
109-
["system", "You are a helpful assistant."],
110-
["human", "{input}"],
111-
["human", "{agent_scratchpad}"]
112-
]);
113-
114-
const agent = await createOpenAIFunctionsAgent({
115-
llm,
107+
const agent = createAgent({
108+
model: llm,
116109
tools: [searchTool],
117-
prompt
118-
});
119-
120-
const executor = new AgentExecutor({
121-
agent,
122-
tools: [searchTool]
123110
});
124111

125112
// Run the agent
126-
const result = await executor.invoke({
127-
input: "What are the latest developments in renewable energy?"
113+
const result = await agent.invoke({
114+
messages: [{ role: "user", content: "What are the latest developments in renewable energy?" }]
128115
});
129116

130117
console.log(result);

src/oss/python/integrations/providers/serpex-python.mdx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,3 @@ This page covers how to use the Serpex search APIs within LangChain.
1313
### Tool
1414

1515
For usage examples and reference for the Serpex wrappers and tools, see [the Serpex tools page](/oss/python/integrations/tools/serpex_search_python).
16-
17-
### Tool (Agent)
18-
19-
You can also load Serpex as a Tool to use with an Agent:
20-
21-
```python
22-
from langchain_community.agent_toolkits.load_tools import load_tools
23-
tools = load_tools(["serpex_search_python"])
24-
```
25-
26-
For more information on loading tools, see [the tools documentation](/oss/integrations/tools).

0 commit comments

Comments
 (0)