BaşlayınÜcretsiz Başlayın

Integrating custom tools with agents

Now that you have your tools at-hand, it's time to set up your agentic workflow! You'll again be using a ReAct agent, which, recall, reasons on the steps it should take, and selects tools using this context and the tool descriptions. An llm has already been defined for you that uses OpenAI's gpt-4o-mini model

Bu egzersiz

Developing LLM Applications with LangChain

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a ReAct agent using create_react_agent() with llm and a list containing your retrieve_customer_info tool.
  • Invoke the agent with agent.invoke() on the input provided.
  • Print the content from the final message.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

@tool
def retrieve_customer_info(name: str) -> str:
    """Retrieve customer information based on their name."""
    customer_info = customers[customers['name'] == name]
    return customer_info.to_string()

# Create a ReAct agent
agent = create_react_agent(____, [____])

# Invoke the agent on the input
messages = agent.____({"messages": [("human", "Create a summary of our customer: Peak Performance Co.")]})
print(messages['messages'][-1].____)
Kodu Düzenle ve Çalıştır