azuremodels

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package azuremodels provides a client for interacting with the Azure models API.

Index

Constants

View Source
const NOTICE = "" /* 158-byte string literal not displayed */

NOTICE represents a legal notice to display to the user when they interact with Models.

Variables

This section is empty.

Functions

func SortModels added in v0.0.5

func SortModels(models []*ModelSummary)

SortModels sorts the given models in place, with featured models first, and then by friendly name.

Types

type AzureClient added in v0.0.5

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

AzureClient provides a client for interacting with the Azure models API.

func NewAzureClient added in v0.0.5

func NewAzureClient(httpClient *http.Client, authToken string, cfg *AzureClientConfig) *AzureClient

NewAzureClient returns a new Azure client using the given HTTP client, configuration, and auth token.

func NewDefaultAzureClient added in v0.0.5

func NewDefaultAzureClient(authToken string) (*AzureClient, error)

NewDefaultAzureClient returns a new Azure client using the given auth token using default API URLs.

func (*AzureClient) GetChatCompletionStream added in v0.0.5

func (c *AzureClient) GetChatCompletionStream(ctx context.Context, req ChatCompletionOptions, org string) (*ChatCompletionResponse, error)

GetChatCompletionStream returns a stream of chat completions using the given options.

func (*AzureClient) GetModelDetails added in v0.0.5

func (c *AzureClient) GetModelDetails(ctx context.Context, registry, modelName, version string) (*ModelDetails, error)

GetModelDetails returns the details of the specified model in a particular registry.

func (*AzureClient) ListModels added in v0.0.5

func (c *AzureClient) ListModels(ctx context.Context) ([]*ModelSummary, error)

ListModels returns a list of available models.

type AzureClientConfig added in v0.0.5

type AzureClientConfig struct {
	InferenceRoot    string
	InferencePath    string
	AzureAiStudioURL string
	ModelsURL        string
}

AzureClientConfig represents configurable settings for the Azure client.

func NewDefaultAzureClientConfig added in v0.0.5

func NewDefaultAzureClientConfig() *AzureClientConfig

NewDefaultAzureClientConfig returns a new AzureClientConfig with default values for API URLs.

type ChatChoice

type ChatChoice struct {
	Delta        *chatChoiceDelta   `json:"delta,omitempty"`
	FinishReason string             `json:"finish_reason"`
	Index        int32              `json:"index"`
	Message      *ChatChoiceMessage `json:"message,omitempty"`
}

ChatChoice represents a choice in a chat completion.

type ChatChoiceMessage added in v0.0.5

type ChatChoiceMessage struct {
	Content *string `json:"content,omitempty"`
	Role    *string `json:"role,omitempty"`
}

ChatChoiceMessage is a message from a choice in a chat conversation.

type ChatCompletion

type ChatCompletion struct {
	Choices []ChatChoice `json:"choices"`
}

ChatCompletion represents a chat completion.

type ChatCompletionOptions

type ChatCompletionOptions struct {
	MaxTokens      *int            `json:"max_tokens,omitempty"`
	Messages       []ChatMessage   `json:"messages"`
	Model          string          `json:"model"`
	Stream         bool            `json:"stream,omitempty"`
	Temperature    *float64        `json:"temperature,omitempty"`
	TopP           *float64        `json:"top_p,omitempty"`
	ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
}

ChatCompletionOptions represents available options for a chat completion request.

type ChatCompletionResponse

type ChatCompletionResponse struct {
	Reader sse.Reader[ChatCompletion]
}

ChatCompletionResponse represents a response to a chat completion request.

type ChatMessage

type ChatMessage struct {
	Content *string         `json:"content,omitempty"`
	Role    ChatMessageRole `json:"role"`
}

ChatMessage represents a message from a chat thread with a model.

type ChatMessageRole

type ChatMessageRole string

ChatMessageRole represents the role of a chat message.

const (
	// ChatMessageRoleAssistant represents a message from the model.
	ChatMessageRoleAssistant ChatMessageRole = "assistant"
	// ChatMessageRoleSystem represents a system message.
	ChatMessageRoleSystem ChatMessageRole = "system"
	// ChatMessageRoleUser represents a message from the user.
	ChatMessageRoleUser ChatMessageRole = "user"
)

type Client

type Client interface {
	// GetChatCompletionStream returns a stream of chat completions using the given options.
	GetChatCompletionStream(context.Context, ChatCompletionOptions, string) (*ChatCompletionResponse, error)
	// GetModelDetails returns the details of the specified model in a particular registry.
	GetModelDetails(ctx context.Context, registry, modelName, version string) (*ModelDetails, error)
	// ListModels returns a list of available models.
	ListModels(context.Context) ([]*ModelSummary, error)
}

Client represents a client for interacting with an API about models.

type MockClient added in v0.0.5

type MockClient struct {
	MockGetChatCompletionStream func(context.Context, ChatCompletionOptions, string) (*ChatCompletionResponse, error)
	MockGetModelDetails         func(context.Context, string, string, string) (*ModelDetails, error)
	MockListModels              func(context.Context) ([]*ModelSummary, error)
}

MockClient provides a client for interacting with the Azure models API in tests.

func NewMockClient added in v0.0.5

func NewMockClient() *MockClient

NewMockClient returns a new mock client for stubbing out interactions with the models API.

func (*MockClient) GetChatCompletionStream added in v0.0.5

func (c *MockClient) GetChatCompletionStream(ctx context.Context, opt ChatCompletionOptions, org string) (*ChatCompletionResponse, error)

GetChatCompletionStream calls the mocked function for getting a stream of chat completions for the given request.

func (*MockClient) GetModelDetails added in v0.0.5

func (c *MockClient) GetModelDetails(ctx context.Context, registry, modelName, version string) (*ModelDetails, error)

GetModelDetails calls the mocked function for getting the details of the specified model in a particular registry.

func (*MockClient) ListModels added in v0.0.5

func (c *MockClient) ListModels(ctx context.Context) ([]*ModelSummary, error)

ListModels calls the mocked function for getting a list of available models.

type ModelDetails

type ModelDetails struct {
	Description               string   `json:"description"`
	Evaluation                string   `json:"evaluation"`
	License                   string   `json:"license"`
	LicenseDescription        string   `json:"license_description"`
	Notes                     string   `json:"notes"`
	Tags                      []string `json:"tags"`
	SupportedInputModalities  []string `json:"supported_input_modalities"`
	SupportedOutputModalities []string `json:"supported_output_modalities"`
	SupportedLanguages        []string `json:"supported_languages"`
	MaxOutputTokens           int      `json:"max_output_tokens"`
	MaxInputTokens            int      `json:"max_input_tokens"`
	RateLimitTier             string   `json:"rateLimitTier"`
}

ModelDetails includes detailed information about a model.

func (*ModelDetails) ContextLimits

func (m *ModelDetails) ContextLimits() string

ContextLimits returns a summary of the context limits for the model.

type ModelSummary

type ModelSummary struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Registry     string `json:"registry"`
	FriendlyName string `json:"friendly_name"`
	Task         string `json:"task"`
	Publisher    string `json:"publisher"`
	Summary      string `json:"summary"`
	Version      string `json:"version"`
}

ModelSummary includes basic information about a model.

func (*ModelSummary) HasName

func (m *ModelSummary) HasName(name string) bool

HasName checks if the model has the given name.

func (*ModelSummary) IsChatModel added in v0.0.5

func (m *ModelSummary) IsChatModel() bool

IsChatModel returns true if the model is for chat completions.

type ResponseFormat added in v0.0.20

type ResponseFormat struct {
	Type       string                  `json:"type"`
	JsonSchema *map[string]interface{} `json:"json_schema,omitempty"`
}

ResponseFormat represents the response format specification

type UnauthenticatedClient added in v0.0.5

type UnauthenticatedClient struct {
}

UnauthenticatedClient is for use by anonymous viewers to talk to the models API.

func NewUnauthenticatedClient added in v0.0.5

func NewUnauthenticatedClient() *UnauthenticatedClient

NewUnauthenticatedClient contructs a new models API client for an anonymous viewer.

func (*UnauthenticatedClient) GetChatCompletionStream added in v0.0.5

func (c *UnauthenticatedClient) GetChatCompletionStream(ctx context.Context, opt ChatCompletionOptions, org string) (*ChatCompletionResponse, error)

GetChatCompletionStream returns an error because this functionality requires authentication.

func (*UnauthenticatedClient) GetModelDetails added in v0.0.5

func (c *UnauthenticatedClient) GetModelDetails(ctx context.Context, registry, modelName, version string) (*ModelDetails, error)

GetModelDetails returns an error because this functionality requires authentication.

func (*UnauthenticatedClient) ListModels added in v0.0.5

func (c *UnauthenticatedClient) ListModels(ctx context.Context) ([]*ModelSummary, error)

ListModels returns an error because this functionality requires authentication.

Jump to

Keyboard shortcuts

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