mirror of
https://github.com/langchain-ai/docs.git
synced 2026-08-27 21:00:00 -04:00
177 lines
5.3 KiB
Plaintext
177 lines
5.3 KiB
Plaintext
<CodeGroup>
|
|
```python Google
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="google_genai:gemini-3.6-flash",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python OpenAI
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="openai:gpt-5.5",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python Anthropic
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="anthropic:claude-sonnet-4-6",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python OpenRouter
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="openrouter:z-ai/glm-5.2",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python Fireworks
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="fireworks:accounts/fireworks/models/glm-5p2",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python Baseten
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="baseten:zai-org/GLM-5.2",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
|
|
```python Ollama
|
|
from langchain.agents import create_agent
|
|
from langchain_core.utils.uuid import uuid7
|
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
|
|
agent = create_agent(
|
|
model="ollama:north-mini-code-1.0",
|
|
tools=[],
|
|
checkpointer=InMemorySaver(),
|
|
)
|
|
|
|
config = {"configurable": {"thread_id": str(uuid7())}}
|
|
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
|
|
config=config,
|
|
)
|
|
|
|
# A follow-up turn on the same conversation: reuse the same thread_id to keep history
|
|
result = agent.invoke(
|
|
{"messages": [{"role": "user", "content": "What about tomorrow?"}]},
|
|
config=config,
|
|
)
|
|
```
|
|
</CodeGroup>
|