azure

package
v0.0.0-...-63bdca9 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AzureOpenAIAPIVersion    = "2024-06-01"
	AzureOpenAIEndpoint      = ""
	ServerlessDeploymentInfo = make(map[string]ServerlessDeployment)
	AzureOpenAIModelMapper   = make(map[string]string)
)

Functions

func HandleToken

func HandleToken(req *http.Request)

func NewOpenAIReverseProxy

func NewOpenAIReverseProxy() *httputil.ReverseProxy

Types

type AudioTranscriptionRequest

type AudioTranscriptionRequest struct {
	Model    string `json:"model"`
	Audio    []byte `json:"audio"`
	Language string `json:"language,omitempty"`
}

AudioTranscriptionRequest represents the request structure for audio transcription

type AudioTranscriptionResponse

type AudioTranscriptionResponse struct {
	Text string `json:"text"`
}

AudioTranscriptionResponse represents the response structure from audio transcription

type AzureAIStudioDeployment

type AzureAIStudioDeployment struct {
	ModelName      string `json:"model_name"`
	DeploymentName string `json:"deployment_name"`
	Region         string `json:"region"`
}

AzureAIStudioDeployment represents a deployment in Azure AI Studio

type AzureConfig

type AzureConfig struct {
	APIVersion             string `json:"api_version"`
	Endpoint               string `json:"endpoint"`
	Token                  string `json:"token"`
	ModelMapperMode        string `json:"model_mapper_mode"`
	AIStudioDeploymentsRaw string `json:"ai_studio_deployments_raw"`
}

AzureConfig represents the configuration for Azure OpenAI

type Capabilities

type Capabilities struct {
	ChatCompletion bool `json:"chat_completion"`
	Completion     bool `json:"completion"`
	Embeddings     bool `json:"embeddings"`
	FineTune       bool `json:"fine_tune"`
	Inference      bool `json:"inference"`
}

Update if there are any changes to the capabilities

type ChatMessage

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ChatMessage represents a message in a chat conversation

type DeployedModel

type DeployedModel struct {
	ID                 string   `json:"id"`
	ModelID            string   `json:"model"`
	DeploymentID       string   `json:"deployment_id"`
	Status             string   `json:"status"`
	CreatedAt          string   `json:"created_at"`
	UpdatedAt          string   `json:"updated_at"`
	CapabilityVersions []string `json:"capability_versions,omitempty"`
}

DeployedModel represents a model deployed in Azure

type DeploymentCapability

type DeploymentCapability struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

DeploymentCapability represents the capabilities of a deployment

type DeploymentDetails

type DeploymentDetails struct {
	ID            string                 `json:"id"`
	ModelID       string                 `json:"model"`
	OwnerID       string                 `json:"owner"`
	Status        string                 `json:"status"`
	CreatedAt     string                 `json:"created_at"`
	UpdatedAt     string                 `json:"updated_at"`
	Capabilities  []DeploymentCapability `json:"capabilities"`
	ScaleSettings ScaleSettings          `json:"scale_settings"`
	RaiPolicy     string                 `json:"rai_policy"`
}

DeploymentDetails represents detailed information about a deployment

type Deprecation

type Deprecation struct {
	FineTune  int `json:"fine_tune,omitempty"`
	Inference int `json:"inference,omitempty"`
}

Update if there are any changes to the deprecation structure

type ImageData

type ImageData struct {
	URL string `json:"url"`
}

ImageData represents data of a generated image

type ImageGenerationRequest

type ImageGenerationRequest struct {
	Model          string `json:"model"`
	Prompt         string `json:"prompt"`
	NumImages      int    `json:"num_images,omitempty"`
	Size           string `json:"size,omitempty"`
	ResponseFormat string `json:"response_format,omitempty"`
}

ImageGenerationRequest represents the request structure for image generation

type ImageGenerationResponse

type ImageGenerationResponse struct {
	Created int64       `json:"created"`
	Data    []ImageData `json:"data"`
}

ImageGenerationResponse represents the response structure from image generation

type JSONChoice

type JSONChoice struct {
	Index        int         `json:"index"`
	Message      ChatMessage `json:"message"`
	FinishReason string      `json:"finish_reason"`
}

JSONChoice represents a choice in the JSON mode response

type JSONModeRequest

type JSONModeRequest struct {
	Model          string          `json:"model"`
	Messages       []ChatMessage   `json:"messages"`
	Temperature    float64         `json:"temperature,omitempty"`
	MaxTokens      int             `json:"max_tokens,omitempty"`
	ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
}

JSONModeRequest represents a request with JSON mode enabled

type JSONModeResponse

type JSONModeResponse struct {
	ID      string       `json:"id"`
	Object  string       `json:"object"`
	Created int64        `json:"created"`
	Model   string       `json:"model"`
	Choices []JSONChoice `json:"choices"`
	Usage   Usage        `json:"usage"`
}

JSONModeResponse represents a response when JSON mode is enabled

type ListDeployedModelsResponse

type ListDeployedModelsResponse struct {
	Data []DeployedModel `json:"data"`
}

ListDeployedModelsResponse represents the response for listing deployed models

type ListModelResponse

type ListModelResponse struct {
	Object string  `json:"object"`
	Data   []Model `json:"data"`
}

type ListVoicesResponse

type ListVoicesResponse struct {
	Voices []VoiceInfo `json:"voices"`
}

ListVoicesResponse represents the response structure for listing available voices

type Model

type Model struct {
	ID              string            `json:"id"`
	Object          string            `json:"object"`
	CreatedAt       int64             `json:"created_at"`
	Capabilities    Capabilities      `json:"capabilities"`
	LifecycleStatus string            `json:"lifecycle_status"`
	Status          string            `json:"status"`
	Deprecation     Deprecation       `json:"deprecation,omitempty"`
	FineTune        string            `json:"fine_tune,omitempty"`
	Created         int               `json:"created"`
	OwnedBy         string            `json:"owned_by"`
	Permission      []ModelPermission `json:"permission"`
	Root            string            `json:"root"`
	Parent          any               `json:"parent"`
}

Update Model struct to include new fields if necessary

type ModelList

type ModelList struct {
	Object string  `json:"object"`
	Data   []Model `json:"data"`
}

type ModelPermission

type ModelPermission struct {
	ID                 string `json:"id"`
	Object             string `json:"object"`
	Created            int    `json:"created"`
	AllowCreateEngine  bool   `json:"allow_create_engine"`
	AllowSampling      bool   `json:"allow_sampling"`
	AllowLogprobs      bool   `json:"allow_logprobs"`
	AllowSearchIndices bool   `json:"allow_search_indices"`
	AllowView          bool   `json:"allow_view"`
	AllowFineTuning    bool   `json:"allow_fine_tuning"`
	Organization       string `json:"organization"`
	Group              any    `json:"group"`
	IsBlocking         bool   `json:"is_blocking"`
}

type ResponseFormat

type ResponseFormat struct {
	Type string `json:"type"` // Can be "text" or "json_object"
}

ResponseFormat specifies the desired format for the model's output

type ScaleSettings

type ScaleSettings struct {
	ScaleType string `json:"scale_type"`
	Capacity  int    `json:"capacity"`
}

ScaleSettings represents the scale settings for a deployment

type ServerlessDeployment

type ServerlessDeployment struct {
	Name   string
	Region string
	Key    string
}

type SpeechRequest

type SpeechRequest struct {
	Model          string  `json:"model"`
	Input          string  `json:"input"`
	Voice          string  `json:"voice"`
	ResponseFormat string  `json:"response_format,omitempty"`
	Speed          float64 `json:"speed,omitempty"`
}

SpeechRequest represents the request structure for text-to-speech

type SpeechResponse

type SpeechResponse struct {
	Type string `json:"type"`
	Data []byte `json:"data"`
}

SpeechResponse represents the response structure from text-to-speech

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage represents token usage information

type VoiceInfo

type VoiceInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Language string `json:"language"`
	Gender   string `json:"gender"`
}

VoiceInfo represents information about available voices

Jump to

Keyboard shortcuts

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