Tool calling

AiBrow supports tool calling; you need to ensure you use a model and prompt that both support tool calling

const session = await aibrow.LanguageModel.create({
  model: "https://huggingface.co/unsloth/Qwen3-8B-GGUF/resolve/main/Qwen3-8B-UD-Q4_K_XL.gguf",
  tools: [
    {
      name: "getWeather",
      description: "Get the weather in a location.",
      inputSchema: {
        type: "object",
        properties: {
          location: {
            type: "string",
            description: "The city to check for the weather condition.",
          },
        },
        required: ["location"],
      },
      async execute({ location }) {
        // Mock a http weather call
        await new Promise((resolve) => setTimeout(resolve,1000))
        return JSON.stringify({
          location,
          forecast: "Sunny, with a low chance of rain in the afternoon"
        })
      }
    }
  ]
})

await session.prompt("What is the weather in London?");

Last updated