Documentation
¶
Index ¶
- Variables
- func HandleToken(req *http.Request)
- func NewOpenAIReverseProxy() *httputil.ReverseProxy
- type AnthropicStreamingConverter
- type AudioTranscriptionRequest
- type AudioTranscriptionResponse
- type AzureAIStudioDeployment
- type AzureConfig
- type Capabilities
- type ChatMessage
- type DeployedModel
- type DeploymentCapability
- type DeploymentDetails
- type Deprecation
- type ImageData
- type ImageGenerationRequest
- type ImageGenerationResponse
- type IncompleteDetails
- type InputItemsList
- type JSONChoice
- type JSONModeRequest
- type JSONModeResponse
- type ListDeployedModelsResponse
- type ListModelResponse
- type ListVoicesResponse
- type Model
- type ModelList
- type ModelPermission
- type Response
- type ResponseContent
- type ResponseError
- type ResponseFormat
- type ResponseOutput
- type ResponseOutputTokenDetail
- type ResponseTool
- type ResponseUsage
- type ResponsesCreateRequest
- type ScaleSettings
- type ServerlessDeployment
- type SpeechRequest
- type SpeechResponse
- type StreamingResponseConverter
- type ToolContainer
- type Usage
- type VoiceInfo
Constants ¶
This section is empty.
Variables ¶
var ( AzureOpenAIAPIVersion = "2024-08-01-preview" // API version for proxying requests - supports Azure Foundry features AzureOpenAIModelsAPIVersion = "2024-10-21" // API version for fetching models AzureOpenAIResponsesAPIVersion = "2024-08-01-preview" // API version for Responses API - supports O-series models AnthropicAPIVersion = "2023-06-01" // Anthropic API version for Claude models AzureOpenAIEndpoint = "" ServerlessDeploymentInfo = make(map[string]ServerlessDeployment) AzureOpenAIModelMapper = make(map[string]string) )
Functions ¶
func HandleToken ¶
func NewOpenAIReverseProxy ¶
func NewOpenAIReverseProxy() *httputil.ReverseProxy
Types ¶
type AnthropicStreamingConverter ¶
type AnthropicStreamingConverter struct {
// contains filtered or unexported fields
}
AnthropicStreamingConverter handles the conversion of Anthropic Messages API SSE to OpenAI Chat Completions SSE
func NewAnthropicStreamingConverter ¶
func NewAnthropicStreamingConverter(reader io.Reader, writer io.Writer, model string) *AnthropicStreamingConverter
NewAnthropicStreamingConverter creates a new Anthropic streaming converter
func (*AnthropicStreamingConverter) Convert ¶
func (c *AnthropicStreamingConverter) Convert() error
Convert performs the Anthropic streaming conversion
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 ¶
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 ¶
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 IncompleteDetails ¶
type IncompleteDetails struct {
Reason string `json:"reason"`
}
IncompleteDetails for incomplete responses
type InputItemsList ¶
type InputItemsList struct {
Data []ResponseOutput `json:"data"`
HasMore bool `json:"has_more"`
Object string `json:"object"`
FirstID string `json:"first_id"`
LastID string `json:"last_id"`
}
InputItemsList represents a list of input items
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 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 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 Response ¶
type Response struct {
ID string `json:"id"`
Object string `json:"object"`
CreatedAt float64 `json:"created_at"`
Error *ResponseError `json:"error,omitempty"`
IncompleteDetails *IncompleteDetails `json:"incomplete_details,omitempty"`
Instructions string `json:"instructions,omitempty"`
Metadata map[string]interface{} `json:"metadata"`
Model string `json:"model"`
Output []ResponseOutput `json:"output"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
Temperature float64 `json:"temperature"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
Tools []ResponseTool `json:"tools"`
TopP float64 `json:"top_p"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Reasoning interface{} `json:"reasoning,omitempty"`
Status string `json:"status"`
Text string `json:"text,omitempty"`
Truncation interface{} `json:"truncation,omitempty"`
Usage *ResponseUsage `json:"usage,omitempty"`
User string `json:"user,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
}
Response represents a response from the Responses API
type ResponseContent ¶
type ResponseContent struct {
Annotations []interface{} `json:"annotations,omitempty"`
Text string `json:"text,omitempty"`
Type string `json:"type"`
}
ResponseContent represents content in a response output
type ResponseError ¶
ResponseError represents an error in a response
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 ResponseOutput ¶
type ResponseOutput struct {
ID string `json:"id"`
Content []ResponseContent `json:"content,omitempty"`
Role string `json:"role,omitempty"`
Status string `json:"status,omitempty"`
Type string `json:"type"`
Name string `json:"name,omitempty"`
CallID string `json:"call_id,omitempty"`
Arguments map[string]interface{} `json:"arguments,omitempty"`
Result string `json:"result,omitempty"`
ServerLabel string `json:"server_label,omitempty"`
}
ResponseOutput represents output from a response
type ResponseOutputTokenDetail ¶
type ResponseOutputTokenDetail struct {
ReasoningTokens int `json:"reasoning_tokens"`
}
ResponseOutputTokenDetail represents detailed output token usage
type ResponseTool ¶
type ResponseTool struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Container *ToolContainer `json:"container,omitempty"`
ServerLabel string `json:"server_label,omitempty"`
ServerURL string `json:"server_url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
RequireApproval string `json:"require_approval,omitempty"`
}
ResponseTool represents a tool in the Responses API
type ResponseUsage ¶
type ResponseUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
OutputTokenDetails *ResponseOutputTokenDetail `json:"output_tokens_details,omitempty"`
}
ResponseUsage represents usage statistics
type ResponsesCreateRequest ¶
type ResponsesCreateRequest struct {
Model string `json:"model"`
Input interface{} `json:"input"`
Instructions string `json:"instructions,omitempty"`
Tools []ResponseTool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Store bool `json:"store,omitempty"`
Stream bool `json:"stream,omitempty"`
Background bool `json:"background,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Include []string `json:"include,omitempty"`
}
ResponsesCreateRequest represents the request to create a response
type ScaleSettings ¶
ScaleSettings represents the scale settings for a deployment
type ServerlessDeployment ¶
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 ¶
SpeechResponse represents the response structure from text-to-speech
type StreamingResponseConverter ¶
type StreamingResponseConverter struct {
// contains filtered or unexported fields
}
StreamingResponseConverter handles the conversion of Responses API SSE to Chat Completions SSE
func NewStreamingResponseConverter ¶
func NewStreamingResponseConverter(reader io.Reader, writer io.Writer, model string) *StreamingResponseConverter
NewStreamingResponseConverter creates a new streaming converter
func (*StreamingResponseConverter) Convert ¶
func (c *StreamingResponseConverter) Convert() error
Convert performs the streaming conversion
type ToolContainer ¶
ToolContainer for code interpreter