0aff31e2d3
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
772 B
772 B
layout
| layout |
|---|
| default |
Tools: Definiendo Herramientas
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const weatherTool = tool(
async ({ location }) => {
// Llamar a API del tiempo
return `El tiempo en ${location} es soleado, 22°C`;
},
{
name: "get_weather",
description: "Obtiene el tiempo actual de una ubicación",
schema: z.object({
location: z.string().describe("Ciudad o ubicación"),
}),
}
);
// El agente decide automáticamente cuándo usar cada tool
const agent = createAgent({
model: "mistral:mistral-large-latest",
tools: [weatherTool, calculatorTool, searchTool],
});