azure

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMResponse

type LLMResponse = protocoltypes.LLMResponse

type Message

type Message = protocoltypes.Message

type Option

type Option func(*Provider)

Option configures the Azure Provider.

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) Option

WithRequestTimeout sets the HTTP request timeout.

func WithTokenSource

func WithTokenSource(ts func(ctx context.Context) (string, error)) Option

WithTokenSource sets a callback that returns a bearer token per request. When set, it takes precedence over the static api key.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent sets the User-Agent header for requests.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements the LLM provider interface for Azure OpenAI endpoints. It handles Azure-specific authentication (Bearer token), URL construction (Responses API), and request/response formatting.

func NewProvider

func NewProvider(apiKey, apiBase, proxy, userAgent string, opts ...Option) *Provider

NewProvider creates a new Azure OpenAI provider.

func NewProviderWithIdentity

func NewProviderWithIdentity(apiBase, proxy, userAgent string, opts ...Option) (*Provider, error)

NewProviderWithIdentity returns an error in the default build.

func NewProviderWithIdentityAndTimeout

func NewProviderWithIdentityAndTimeout(
	apiBase, proxy, userAgent string,
	requestTimeoutSeconds int,
) (*Provider, error)

NewProviderWithIdentityAndTimeout returns an error in the default build.

func NewProviderWithTimeout

func NewProviderWithTimeout(apiKey, apiBase, proxy, userAgent string, requestTimeoutSeconds int) *Provider

NewProviderWithTimeout creates a new Azure OpenAI provider with a custom request timeout in seconds.

func NewProviderWithTokenSource

func NewProviderWithTokenSource(
	apiBase, proxy, userAgent string,
	tokenSource func(ctx context.Context) (string, error),
	opts ...Option,
) *Provider

NewProviderWithTokenSource creates a new Azure OpenAI provider that obtains its bearer token from the supplied callback on every request. Used for Entra ID auth where tokens are short-lived and refreshed by the underlying credential.

func (*Provider) Chat

func (p *Provider) Chat(
	ctx context.Context,
	messages []Message,
	tools []ToolDefinition,
	model string,
	options map[string]any,
) (*LLMResponse, error)

Chat sends a request to the Azure OpenAI Responses API endpoint. The model parameter is passed in the request body.

func (*Provider) GetDefaultModel

func (p *Provider) GetDefaultModel() string

GetDefaultModel returns an empty string as Azure deployments are user-configured.

type ToolDefinition

type ToolDefinition = protocoltypes.ToolDefinition

Jump to

Keyboard shortcuts

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