#atom

AI systems that use language models to determine which actions to take and in what sequence

Core Idea: Agents are systems that leverage language models as reasoning engines to decide which actions to perform, determine the inputs for those actions, execute them, and make further decisions based on the results.

Key Elements

Implementation Approaches

from langchain_anthropic import ChatAnthropic
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_core.messages import HumanMessage
from langgraph.checkpoint.memory import MemorySaver
from langgraph.prebuilt import create_react_agent

# Create the components
memory = MemorySaver()
model = ChatAnthropic(model_name="claude-3-sonnet-20240229")
search = TavilySearchResults(max_results=2)
tools = [search]

# Build the agent
agent_executor = create_react_agent(model, tools, checkpointer=memory)

# Use the agent
config = {"configurable": {"thread_id": "abc123"}}
response = agent_executor.invoke(
    {"messages": [HumanMessage(content="What's the weather in San Francisco?")]},
    config
)

Common Use Cases

Connections

References

  1. LangChain documentation on agents (https://python.langchain.com/docs/concepts/agents/)
  2. LangGraph documentation for agent orchestration

#langchain #agents #llm #tool-use #ai-systems


Connections:


Sources: