BotConnector
Masuk Workspace Buka Aplikasi

TypeScript tools

Beta

Tool calling berstatus Experimental di level runtime (lihat Tool use); dukungan bergantung model/template. Source SDK sudah diimplementasikan, tetapi paket npm belum dipublikasikan.

Desain target SDK

typescript
import { BotConnectorClient } from "@botconnector/sdk";

const client = new BotConnectorClient();
const model = await client.llm("<publisher>/<model>");

const tools = [{
  type: "function",
  function: {
    name: "get_weather",
    description: "Get current weather",
    parameters: {
      type: "object",
      properties: { city: { type: "string" } },
      required: ["city"],
    },
  },
}];

const reply = await model.chat("What is the weather in Jakarta?", { tools });
if (reply.toolCalls?.length) {
  const result = await myWeatherImpl(reply.toolCalls[0].arguments.city);
  // berikan hasil kembali dan lanjutkan percakapan
}
Keandalan tool-call bergantung model + chat template. Gunakan source SDK atau API kompatibel OpenAI — lihat Tool use — dengan catatan yang tercantum di sana.