azure_tools

command
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 9 Imported by: 0

README

Azure OpenAI — Tool Calling

Multi-round tool calling against an Azure OpenAI deployment. The model is given two tools and Chronos drives the full tool-call loop until a final answer is produced.

What it demonstrates

  • Wiring tool.Registry definitions into a provider-agnostic model.ChatRequest.Tools slice
  • The tool-call loop: detect StopReason == model.StopReasonToolCall, execute each requested tool, append RoleTool result messages, and re-ask — bounded by maxToolRounds
  • Two tools: a calculator (add/sub/mul/div) and a lookup (canned facts)

The loop is identical to the one in examples/graph_with_llm; only the provider construction is Azure-specific.

Run

export AZURE_OPENAI_API_KEY=<your-azure-api-key>
export AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
export AZURE_OPENAI_DEPLOYMENT=<your-deployment-name>   # must support function calling
export AZURE_OPENAI_API_VERSION=2024-10-21

go run ./examples/azure_tools/main.go

Without AZURE_OPENAI_API_KEY the example prints the required variables and exits 0 — no network call.

Tests

main_test.go is fully offline: it unit-tests the pure calculate and lookup helpers and the tool.Registry wiring. It never contacts Azure.

go test ./examples/azure_tools/...

See also: examples/azure (chat/streaming) and examples/azure_rag (RAG).

Documentation

Overview

Azure OpenAI tool-calling example for Chronos.

This example shows how to drive multi-round tool calling against an Azure OpenAI deployment. The model is given two tools — a calculator and a small knowledge lookup — and the example runs the full tool-call loop: it sends the request with tool definitions, and whenever the model responds with StopReasonToolCall it executes the requested tools, feeds the results back, and asks again, repeating until the model produces a final answer.

The same loop pattern works for any provider (see examples/graph_with_llm), because tools are wired through the provider-agnostic model.ChatRequest.

Prerequisites:

  • An Azure OpenAI resource with a chat model deployment (e.g. gpt-4o-mini) that supports function calling
  • Go 1.24+

Set the following environment variables before running:

export AZURE_OPENAI_API_KEY=<your-azure-api-key>
export AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
export AZURE_OPENAI_DEPLOYMENT=<your-deployment-name>
export AZURE_OPENAI_API_VERSION=2024-10-21

Run:

go run ./examples/azure_tools/main.go

If AZURE_OPENAI_API_KEY is not set the example prints the required variables and exits cleanly (0) without making any network call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL