or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai@v0.9.0

docs

authentication.mdazure-on-your-data.mdcontent-filtering.mdindex.mdtypes.md
tile.json

tessl/golang-github-com-azure-azure-sdk-for-go-sdk-ai-azopenai

tessl install tessl/golang-github-com-azure-azure-sdk-for-go-sdk-ai-azopenai@0.9.0

Azure OpenAI extensions module for Go providing models and convenience functions to simplify integration with Azure OpenAI features.

types.mddocs/

Type Definitions

This document provides comprehensive type definitions for Azure OpenAI extension types used throughout the azopenai package.

Response Wrapper Types

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.

Chat Completion Wrappers

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.

Legacy Completion Wrappers

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.

Enhancement Types

Enhancement Configuration

type AzureChatEnhancementConfiguration struct {
    Grounding *AzureChatGroundingEnhancementConfiguration
    Ocr       *AzureChatOCREnhancementConfiguration
}

func (a AzureChatEnhancementConfiguration) MarshalJSON() ([]byte, error)
func (a *AzureChatEnhancementConfiguration) UnmarshalJSON(data []byte) error

Configuration 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) error

Enables 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) error

Enables optical character recognition enhancement for extracting text from images.

Enhancement Results

type AzureChatEnhancements struct {
    Grounding *AzureGroundingEnhancement
}

func (a AzureChatEnhancements) MarshalJSON() ([]byte, error)
func (a *AzureChatEnhancements) UnmarshalJSON(data []byte) error

Output 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) error

Grounding 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) error

A 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) error

A 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) error

A single polygon point for Azure grounding enhancement.

Vectorization Source Types

Base Vectorization Source

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

Abstract representation of a vectorization source for vector search.

Implementing Types:

  • OnYourDataDeploymentNameVectorizationSource
  • OnYourDataEndpointVectorizationSource
  • OnYourDataIntegratedVectorizationSource
  • OnYourDataModelIDVectorizationSource

Vectorization Source Type Constants

type OnYourDataVectorizationSourceType string

const (
    OnYourDataVectorizationSourceTypeDeploymentName OnYourDataVectorizationSourceType = "deployment_name"
    OnYourDataVectorizationSourceTypeEndpoint       OnYourDataVectorizationSourceType = "endpoint"
    OnYourDataVectorizationSourceTypeIntegrated     OnYourDataVectorizationSourceType = "integrated"
    OnYourDataVectorizationSourceTypeModelID        OnYourDataVectorizationSourceType = "model_id"
)

func PossibleOnYourDataVectorizationSourceTypeValues() []OnYourDataVectorizationSourceType

Types:

  • DeploymentName: Uses Ada model deployment via internal call (enables vector search in private networks)
  • Endpoint: Uses public Azure OpenAI embedding endpoint
  • Integrated: Uses integrated vectorizer defined within search resource
  • ModelID: Uses specific embedding model ID in search service (Elasticsearch only)

Deployment Name Vectorization Source

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

Vectorization based on internal embeddings model deployment in the same Azure OpenAI resource.

Endpoint Vectorization Source

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

Vectorization based on public Azure OpenAI endpoint. Endpoint should be in format: https://RESOURCENAME.openai.azure.com/openai/deployments/DEPLOYMENTNAME/embeddings

Integrated Vectorization Source

type OnYourDataIntegratedVectorizationSource struct {
    Type *OnYourDataVectorizationSourceType // REQUIRED
}

func (o *OnYourDataIntegratedVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
func (o OnYourDataIntegratedVectorizationSource) MarshalJSON() ([]byte, error)
func (o *OnYourDataIntegratedVectorizationSource) UnmarshalJSON(data []byte) error

Represents the integrated vectorizer defined within the search resource.

Model ID Vectorization Source

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

Vectorization based on search service model ID. Currently only supported by Elasticsearch.

Context Property Type

type OnYourDataContextProperty string

const (
    OnYourDataContextPropertyAllRetrievedDocuments OnYourDataContextProperty = "all_retrieved_documents"
    OnYourDataContextPropertyCitations             OnYourDataContextProperty = "citations"
    OnYourDataContextPropertyIntent                OnYourDataContextProperty = "intent"
)

func PossibleOnYourDataContextPropertyValues() []OnYourDataContextProperty

Specifies which context properties to include in Azure OpenAI On Your Data responses:

  • AllRetrievedDocuments: All documents retrieved from the data source
  • Citations: Citation references from data sources
  • Intent: Detected intent from the chat history

Error Types

Error

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

Represents an error from the content filtering system or Azure OpenAI service.

MongoDB-Specific Types

MongoDB Embedding Dependency

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
}

Using Wrapper Types

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()
}

Type Conversion Patterns

The azopenai package uses these type conversion patterns:

  1. Type Aliasing: Response wrappers use type aliasing (e.g., type ChatCompletion openai.ChatCompletion) to preserve the original structure while adding methods.

  2. Explicit Conversion: Convert between types using explicit type conversion: azopenai.ChatCompletion(*openaiResp)

  3. Interface Implementations: Polymorphic types implement "Classification" interfaces with getter methods.

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