azure

package
v0.0.0-...-dc26227 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AzureOpenAIToken       = ""
	AzureOpenAIAPIVersion  = "2024-05-01-preview"
	AzureOpenAIEndpoint    = ""
	AzureOpenAIModelMapper = map[string]string{
		"gpt-3.5-turbo":               "gpt-35-turbo",
		"gpt-3.5-turbo-0125":          "gpt-35-turbo-0125",
		"gpt-3.5-turbo-0613":          "gpt-35-turbo-0613",
		"gpt-3.5-turbo-1106":          "gpt-35-turbo-1106",
		"gpt-3.5-turbo-16k-0613":      "gpt-35-turbo-16k-0613",
		"gpt-3.5-turbo-instruct-0914": "gpt-35-turbo-instruct-0914",
		"gpt-4":                       "gpt-4-0613",
		"gpt-4-32k":                   "gpt-4-32k",
		"gpt-4-32k-0613":              "gpt-4-32k-0613",
		"gpt-4o":                      "gpt-4o",
		"gpt-4o-2024-05-13":           "gpt-4o-2024-05-13",
		"gpt-4-turbo":                 "gpt-4-turbo",
		"gpt-4-vision-preview":        "gpt-4-vision-preview",
		"gpt-4-turbo-2024-04-09":      "gpt-4-turbo-2024-04-09",
		"gpt-4-1106-preview":          "gpt-4-1106-preview",
		"text-embedding-ada-002":      "text-embedding-ada-002",
		"dall-e-2":                    "dall-e-2",
		"dall-e-3":                    "dall-e-3",
		"babbage-002":                 "babbage-002",
		"davinci-002":                 "davinci-002",
		"whisper-1":                   "whisper",
		"tts-1":                       "tts",
		"tts-1-hd":                    "tts-hd",
		"text-embedding-3-small":      "text-embedding-3-small-1",
		"text-embedding-3-large":      "text-embedding-3-large-1",
	}
)

Functions

func GetDeploymentByModel

func GetDeploymentByModel(model string) string

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 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"`
}

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"`
}

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"`
}

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 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