tessl install tessl/golang-github-com-azure-azure-sdk-for-go-sdk-ai-azopenai@0.9.0Azure OpenAI extensions module for Go providing models and convenience functions to simplify integration with Azure OpenAI features.
This document provides comprehensive type definitions for Azure OpenAI extension types used throughout the azopenai package.
The azopenai package provides wrapper types that extend OpenAI response types with Azure-specific functionality. These wrappers allow you to access Azure-specific data while preserving all original OpenAI fields and methods.
type ChatCompletion openai.ChatCompletion
func (c ChatCompletion) PromptFilterResults() ([]ContentFilterResultsForPrompt, error)Wraps openai.ChatCompletion to provide access to prompt-level content filtering results. All original ChatCompletion fields remain accessible.
type ChatCompletionChoice openai.ChatCompletionChoice
func (c ChatCompletionChoice) ContentFilterResults() (*ContentFilterResultsForChoice, error)Wraps openai.ChatCompletionChoice to provide access to choice-level content filtering results.
type ChatCompletionMessage openai.ChatCompletionMessage
func (c ChatCompletionMessage) Context() (*AzureChatExtensionsMessageContext, error)Wraps openai.ChatCompletionMessage to provide access to Azure chat extensions context (citations, retrieved documents, intent).
type ChatCompletionChunk openai.ChatCompletionChunk
func (c ChatCompletionChunk) PromptFilterResults() ([]ContentFilterResultsForPrompt, error)Wraps openai.ChatCompletionChunk for streaming responses, providing access to prompt filtering results.
type ChatCompletionChunkChoiceDelta openai.ChatCompletionChunkChoiceDelta
func (c ChatCompletionChunkChoiceDelta) Context() (*AzureChatExtensionsMessageContext, error)Wraps openai.ChatCompletionChunkChoiceDelta for streaming deltas with Azure extensions context.
type Completion openai.Completion
func (c Completion) PromptFilterResults() ([]ContentFilterResultsForPrompt, error)Wraps openai.Completion for legacy completions API with prompt filtering support.
type CompletionChoice openai.CompletionChoice
func (c CompletionChoice) ContentFilterResults() (*ContentFilterResultsForChoice, error)Wraps openai.CompletionChoice for legacy completions API with choice-level filtering.
type AzureChatEnhancementConfiguration struct {
Grounding *AzureChatGroundingEnhancementConfiguration
Ocr *AzureChatOCREnhancementConfiguration
}
func (a AzureChatEnhancementConfiguration) MarshalJSON() ([]byte, error)
func (a *AzureChatEnhancementConfiguration) UnmarshalJSON(data []byte) errorConfiguration for Azure-specific enhancements including grounding and OCR.
type AzureChatGroundingEnhancementConfiguration struct {
Enabled *bool // REQUIRED; Whether grounding enhancement is enabled
}
func (a AzureChatGroundingEnhancementConfiguration) MarshalJSON() ([]byte, error)
func (a *AzureChatGroundingEnhancementConfiguration) UnmarshalJSON(data []byte) errorEnables grounding enhancement which returns bounding boxes of detected objects in images.
type AzureChatOCREnhancementConfiguration struct {
Enabled *bool // REQUIRED; Whether OCR enhancement is enabled
}
func (a AzureChatOCREnhancementConfiguration) MarshalJSON() ([]byte, error)
func (a *AzureChatOCREnhancementConfiguration) UnmarshalJSON(data []byte) errorEnables optical character recognition enhancement for extracting text from images.
type AzureChatEnhancements struct {
Grounding *AzureGroundingEnhancement
}
func (a AzureChatEnhancements) MarshalJSON() ([]byte, error)
func (a *AzureChatEnhancements) UnmarshalJSON(data []byte) errorOutput results of Azure enhancements applied to chat completions.
type AzureGroundingEnhancement struct {
Lines []AzureGroundingEnhancementLine // REQUIRED; Lines of text detected by grounding
}
func (a AzureGroundingEnhancement) MarshalJSON() ([]byte, error)
func (a *AzureGroundingEnhancement) UnmarshalJSON(data []byte) errorGrounding enhancement results with detected text and bounding boxes.
type AzureGroundingEnhancementLine struct {
Spans []AzureGroundingEnhancementLineSpan // REQUIRED; Detected objects and their bounding boxes
Text *string // REQUIRED; Text within the line
}
func (a AzureGroundingEnhancementLine) MarshalJSON() ([]byte, error)
func (a *AzureGroundingEnhancementLine) UnmarshalJSON(data []byte) errorA content line consisting of an adjacent sequence of content elements.
type AzureGroundingEnhancementLineSpan struct {
Length *int32 // REQUIRED; Length in Unicode codepoints
Offset *int32 // REQUIRED; Character offset where span begins
Polygon []AzureGroundingEnhancementCoordinatePoint // REQUIRED; Polygon points enclosing detected object
Text *string // REQUIRED; Text content of the span
}
func (a AzureGroundingEnhancementLineSpan) MarshalJSON() ([]byte, error)
func (a *AzureGroundingEnhancementLineSpan) UnmarshalJSON(data []byte) errorA span representing a detected object and its bounding box information.
type AzureGroundingEnhancementCoordinatePoint struct {
X *float32 // REQUIRED; X-coordinate (horizontal axis)
Y *float32 // REQUIRED; Y-coordinate (vertical axis)
}
func (a AzureGroundingEnhancementCoordinatePoint) MarshalJSON() ([]byte, error)
func (a *AzureGroundingEnhancementCoordinatePoint) UnmarshalJSON(data []byte) errorA single polygon point for Azure grounding enhancement.
type OnYourDataVectorizationSourceClassification interface {
GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
}
type OnYourDataVectorizationSource struct {
Type *OnYourDataVectorizationSourceType // REQUIRED
}
func (o *OnYourDataVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataVectorizationSource) UnmarshalJSON(data []byte) errorAbstract representation of a vectorization source for vector search.
Implementing Types:
OnYourDataDeploymentNameVectorizationSourceOnYourDataEndpointVectorizationSourceOnYourDataIntegratedVectorizationSourceOnYourDataModelIDVectorizationSourcetype OnYourDataVectorizationSourceType string
const (
OnYourDataVectorizationSourceTypeDeploymentName OnYourDataVectorizationSourceType = "deployment_name"
OnYourDataVectorizationSourceTypeEndpoint OnYourDataVectorizationSourceType = "endpoint"
OnYourDataVectorizationSourceTypeIntegrated OnYourDataVectorizationSourceType = "integrated"
OnYourDataVectorizationSourceTypeModelID OnYourDataVectorizationSourceType = "model_id"
)
func PossibleOnYourDataVectorizationSourceTypeValues() []OnYourDataVectorizationSourceTypeTypes:
type OnYourDataDeploymentNameVectorizationSource struct {
DeploymentName *string // REQUIRED; Embedding model deployment name
Type *OnYourDataVectorizationSourceType // REQUIRED
Dimensions *int32 // Optional; number of dimensions (text-embedding-3+)
}
func (o *OnYourDataDeploymentNameVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataDeploymentNameVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataDeploymentNameVectorizationSource) UnmarshalJSON(data []byte) errorVectorization based on internal embeddings model deployment in the same Azure OpenAI resource.
type OnYourDataEndpointVectorizationSource struct {
Authentication OnYourDataVectorSearchAuthenticationOptionsClassification // REQUIRED
Endpoint *string // REQUIRED; Resource endpoint URL
Type *OnYourDataVectorizationSourceType // REQUIRED
}
func (o *OnYourDataEndpointVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataEndpointVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataEndpointVectorizationSource) UnmarshalJSON(data []byte) errorVectorization based on public Azure OpenAI endpoint. Endpoint should be in format:
https://RESOURCENAME.openai.azure.com/openai/deployments/DEPLOYMENTNAME/embeddings
type OnYourDataIntegratedVectorizationSource struct {
Type *OnYourDataVectorizationSourceType // REQUIRED
}
func (o *OnYourDataIntegratedVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataIntegratedVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataIntegratedVectorizationSource) UnmarshalJSON(data []byte) errorRepresents the integrated vectorizer defined within the search resource.
type OnYourDataModelIDVectorizationSource struct {
ModelID *string // REQUIRED; Embedding model ID
Type *OnYourDataVectorizationSourceType // REQUIRED
}
func (o *OnYourDataModelIDVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataModelIDVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataModelIDVectorizationSource) UnmarshalJSON(data []byte) errorVectorization based on search service model ID. Currently only supported by Elasticsearch.
type OnYourDataContextProperty string
const (
OnYourDataContextPropertyAllRetrievedDocuments OnYourDataContextProperty = "all_retrieved_documents"
OnYourDataContextPropertyCitations OnYourDataContextProperty = "citations"
OnYourDataContextPropertyIntent OnYourDataContextProperty = "intent"
)
func PossibleOnYourDataContextPropertyValues() []OnYourDataContextPropertySpecifies which context properties to include in Azure OpenAI On Your Data responses:
type Error struct {
Code *string // REQUIRED; Server-defined error code
Message *string // REQUIRED; Human-readable error message
}
func (e Error) MarshalJSON() ([]byte, error)
func (e *Error) UnmarshalJSON(data []byte) errorRepresents an error from the content filtering system or Azure OpenAI service.
type MongoDBChatExtensionParametersEmbeddingDependency struct {
// Has unexported fields
}
func NewMongoDBChatExtensionParametersEmbeddingDependency[T OnYourDataDeploymentNameVectorizationSource | OnYourDataEndpointVectorizationSource](value T) *MongoDBChatExtensionParametersEmbeddingDependency
func (c MongoDBChatExtensionParametersEmbeddingDependency) MarshalJSON() ([]byte, error)Type-safe embedding dependency for MongoDB chat extensions. Create using NewMongoDBChatExtensionParametersEmbeddingDependency with either deployment name or endpoint vectorization source.
Example:
deploymentSource := azopenai.OnYourDataDeploymentNameVectorizationSource{
DeploymentName: to.Ptr("my-embedding-deployment"),
Type: to.Ptr(azopenai.OnYourDataVectorizationSourceTypeDeploymentName),
}
embeddingDep := azopenai.NewMongoDBChatExtensionParametersEmbeddingDependency(deploymentSource)
params := &azopenai.MongoDBChatExtensionParameters{
EmbeddingDependency: embeddingDep,
// ... other fields
}All wrapper types are used by converting OpenAI response types:
// Convert OpenAI ChatCompletion to Azure wrapper
resp, err := client.Chat.Completions.New(ctx, params)
azureResp := azopenai.ChatCompletion(*resp)
// Extract Azure-specific data
promptFilters, err := azureResp.PromptFilterResults()
// Convert individual choices
for _, choice := range resp.Choices {
azureChoice := azopenai.ChatCompletionChoice(choice)
filterResults, err := azureChoice.ContentFilterResults()
// Convert messages
azureMsg := azopenai.ChatCompletionMessage(choice.Message)
context, err := azureMsg.Context()
}The azopenai package uses these type conversion patterns:
Type Aliasing: Response wrappers use type aliasing (e.g., type ChatCompletion openai.ChatCompletion) to preserve the original structure while adding methods.
Explicit Conversion: Convert between types using explicit type conversion: azopenai.ChatCompletion(*openaiResp)
Interface Implementations: Polymorphic types implement "Classification" interfaces with getter methods.
Generic Constraints: Some constructors like NewMongoDBChatExtensionParametersEmbeddingDependency use Go generics with type constraints for type safety.
All wrapper types preserve the original OpenAI structure, so all fields from the OpenAI SDK remain accessible after conversion.