[azopenaiextensions] Prepping for release tomorrow (#23551)
* Prepping for release tomorrow * Updating with required changelog section. * Updating to the 2024-08-01-preview API version. * Bump release date to probable Thursday release. * Skip some tests if we're not doing code generation. * Updating dependencies.
This commit is contained in:
Родитель
a230ef2f65
Коммит
8759ee622d
|
@ -1,5 +1,7 @@
|
|||
# Release History
|
||||
|
||||
## 0.1.0 (TBD)
|
||||
## 0.1.0 (2024-10-10)
|
||||
|
||||
- Initial release of the `azopenaiextensions` module, which can be used with the [OpenAI go module](https://github.com/openai/openai-go)
|
||||
### Features Added
|
||||
|
||||
- Initial release of the `azopenaiextensions` module, which can be used with the [OpenAI go module](https://github.com/openai/openai-go). This module supports `2024-08-01-preview` API surface for Azure OpenAI.
|
||||
|
|
|
@ -22,7 +22,7 @@ rawjson-as-bytes: true
|
|||
|
||||
## Transformations
|
||||
|
||||
Fix deployment and endpoint parameters so they show up in the right spots
|
||||
Keep only "Azure OpenAI On Your Data" models, or enhancements.
|
||||
|
||||
``` yaml
|
||||
directive:
|
||||
|
@ -43,7 +43,7 @@ directive:
|
|||
const keep = {};
|
||||
|
||||
// this'll catch the Azure "on your data" models.
|
||||
const oydModelRegex = /^(OnYour|Azure|Pinecone|ContentFilter).+$/;
|
||||
const oydModelRegex = /^(OnYour|Azure|Pinecone|ContentFilter|Mongo|Elasticsearch).+$/;
|
||||
|
||||
for (const key in $.definitions) {
|
||||
if (!(key in keep) && !key.match(oydModelRegex)) {
|
||||
|
@ -74,3 +74,22 @@ directive:
|
|||
$["Azure.Core.Foundations.ErrorResponse"]["x-ms-external"] = true;
|
||||
return $;
|
||||
```
|
||||
|
||||
## Unions
|
||||
|
||||
Update MongoDBChatExtensionParameters.embedding_dependency to use its custom type.
|
||||
|
||||
```yaml
|
||||
directive:
|
||||
- from: swagger-document
|
||||
where: $.definitions
|
||||
transform: |
|
||||
$["MongoDBChatExtensionParametersEmbeddingDependency"] = {
|
||||
"x-ms-external": true,
|
||||
"type": "object", "properties": { "stub": { "type": "string" }}
|
||||
};
|
||||
return $;
|
||||
- from: swagger-document
|
||||
where: $.definitions.MongoDBChatExtensionParameters.properties.embedding_dependency
|
||||
transform: $["$ref"] = "#/definitions/MongoDBChatExtensionParametersEmbeddingDependency"; return $;
|
||||
```
|
||||
|
|
|
@ -10,4 +10,7 @@
|
|||
//go:generate go mod tidy
|
||||
//go:generate goimports -w .
|
||||
|
||||
// running the tests that check that generation went the way we expected to.
|
||||
//go:go test -v ./internal
|
||||
|
||||
package azopenaiextensions
|
||||
|
|
|
@ -190,9 +190,6 @@ func TestAssistantRun(t *testing.T) {
|
|||
AssistantID: openai.String(assistant.ID),
|
||||
Instructions: openai.String("Please address the user as Jane Doe. The user has a premium account."),
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for stream.Next() {
|
||||
evt := stream.Current()
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const apiVersion = "2024-07-01-preview"
|
||||
const apiVersion = "2024-08-01-preview"
|
||||
|
||||
type endpoint struct {
|
||||
URL string
|
||||
|
|
|
@ -36,13 +36,12 @@ type AzureChatExtensionType string
|
|||
const (
|
||||
// AzureChatExtensionTypeAzureCosmosDB - Represents the use of Azure Cosmos DB as an Azure OpenAI chat extension.
|
||||
AzureChatExtensionTypeAzureCosmosDB AzureChatExtensionType = "azure_cosmos_db"
|
||||
// AzureChatExtensionTypeAzureMachineLearningIndex - Represents the use of Azure Machine Learning index as an Azure OpenAI
|
||||
// chat extension.
|
||||
AzureChatExtensionTypeAzureMachineLearningIndex AzureChatExtensionType = "azure_ml_index"
|
||||
// AzureChatExtensionTypeAzureSearch - Represents the use of Azure AI Search as an Azure OpenAI chat extension.
|
||||
AzureChatExtensionTypeAzureSearch AzureChatExtensionType = "azure_search"
|
||||
// AzureChatExtensionTypeElasticsearch - Represents the use of Elasticsearch® index as an Azure OpenAI chat extension.
|
||||
AzureChatExtensionTypeElasticsearch AzureChatExtensionType = "elasticsearch"
|
||||
// AzureChatExtensionTypeMongoDB - Represents the use of a MongoDB chat extension.
|
||||
AzureChatExtensionTypeMongoDB AzureChatExtensionType = "mongo_db"
|
||||
// AzureChatExtensionTypePinecone - Represents the use of Pinecone index as an Azure OpenAI chat extension.
|
||||
AzureChatExtensionTypePinecone AzureChatExtensionType = "pinecone"
|
||||
)
|
||||
|
@ -51,9 +50,9 @@ const (
|
|||
func PossibleAzureChatExtensionTypeValues() []AzureChatExtensionType {
|
||||
return []AzureChatExtensionType{
|
||||
AzureChatExtensionTypeAzureCosmosDB,
|
||||
AzureChatExtensionTypeAzureMachineLearningIndex,
|
||||
AzureChatExtensionTypeAzureSearch,
|
||||
AzureChatExtensionTypeElasticsearch,
|
||||
AzureChatExtensionTypeMongoDB,
|
||||
AzureChatExtensionTypePinecone,
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +118,25 @@ func PossibleContentFilterSeverityValues() []ContentFilterSeverity {
|
|||
}
|
||||
}
|
||||
|
||||
// ElasticsearchQueryType - The type of Elasticsearch® retrieval query that should be executed when using it as an Azure OpenAI
|
||||
// chat extension.
|
||||
type ElasticsearchQueryType string
|
||||
|
||||
const (
|
||||
// ElasticsearchQueryTypeSimple - Represents the default, simple query parser.
|
||||
ElasticsearchQueryTypeSimple ElasticsearchQueryType = "simple"
|
||||
// ElasticsearchQueryTypeVector - Represents vector search over computed data.
|
||||
ElasticsearchQueryTypeVector ElasticsearchQueryType = "vector"
|
||||
)
|
||||
|
||||
// PossibleElasticsearchQueryTypeValues returns the possible values for the ElasticsearchQueryType const type.
|
||||
func PossibleElasticsearchQueryTypeValues() []ElasticsearchQueryType {
|
||||
return []ElasticsearchQueryType{
|
||||
ElasticsearchQueryTypeSimple,
|
||||
ElasticsearchQueryTypeVector,
|
||||
}
|
||||
}
|
||||
|
||||
// OnYourDataAuthenticationType - The authentication types supported with Azure OpenAI On Your Data.
|
||||
type OnYourDataAuthenticationType string
|
||||
|
||||
|
@ -137,6 +155,8 @@ const (
|
|||
OnYourDataAuthenticationTypeSystemAssignedManagedIdentity OnYourDataAuthenticationType = "system_assigned_managed_identity"
|
||||
// OnYourDataAuthenticationTypeUserAssignedManagedIdentity - Authentication via user-assigned managed identity.
|
||||
OnYourDataAuthenticationTypeUserAssignedManagedIdentity OnYourDataAuthenticationType = "user_assigned_managed_identity"
|
||||
// OnYourDataAuthenticationTypeUsernameAndPassword - Authentication via username and password.
|
||||
OnYourDataAuthenticationTypeUsernameAndPassword OnYourDataAuthenticationType = "username_and_password"
|
||||
)
|
||||
|
||||
// PossibleOnYourDataAuthenticationTypeValues returns the possible values for the OnYourDataAuthenticationType const type.
|
||||
|
@ -149,6 +169,7 @@ func PossibleOnYourDataAuthenticationTypeValues() []OnYourDataAuthenticationType
|
|||
OnYourDataAuthenticationTypeKeyAndKeyID,
|
||||
OnYourDataAuthenticationTypeSystemAssignedManagedIdentity,
|
||||
OnYourDataAuthenticationTypeUserAssignedManagedIdentity,
|
||||
OnYourDataAuthenticationTypeUsernameAndPassword,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,6 +225,8 @@ const (
|
|||
// OnYourDataVectorizationSourceTypeEndpoint - Represents vectorization performed by public service calls to an Azure OpenAI
|
||||
// embedding model.
|
||||
OnYourDataVectorizationSourceTypeEndpoint OnYourDataVectorizationSourceType = "endpoint"
|
||||
// OnYourDataVectorizationSourceTypeIntegrated - Represents the integrated vectorizer defined within the search resource.
|
||||
OnYourDataVectorizationSourceTypeIntegrated OnYourDataVectorizationSourceType = "integrated"
|
||||
// OnYourDataVectorizationSourceTypeModelID - Represents a specific embedding model ID as defined in the search service.
|
||||
// Currently only supported by Elasticsearch®.
|
||||
OnYourDataVectorizationSourceTypeModelID OnYourDataVectorizationSourceType = "model_id"
|
||||
|
@ -214,6 +237,7 @@ func PossibleOnYourDataVectorizationSourceTypeValues() []OnYourDataVectorization
|
|||
return []OnYourDataVectorizationSourceType{
|
||||
OnYourDataVectorizationSourceTypeDeploymentName,
|
||||
OnYourDataVectorizationSourceTypeEndpoint,
|
||||
OnYourDataVectorizationSourceTypeIntegrated,
|
||||
OnYourDataVectorizationSourceTypeModelID,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
package azopenaiextensions
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MongoDBChatExtensionParametersEmbeddingDependency contains the embedding dependency for the [MongoDBChatExtensionParameters].
|
||||
// NOTE: This should be created using [azopenai.NewMongoDBChatExtensionParametersEmbeddingDependency]
|
||||
type MongoDBChatExtensionParametersEmbeddingDependency struct {
|
||||
value any
|
||||
}
|
||||
|
||||
// NewMongoDBChatExtensionParametersEmbeddingDependency creates a [azopenai.MongoDBChatExtensionParametersEmbeddingDependency].
|
||||
func NewMongoDBChatExtensionParametersEmbeddingDependency[T OnYourDataDeploymentNameVectorizationSource | OnYourDataEndpointVectorizationSource](value T) *MongoDBChatExtensionParametersEmbeddingDependency {
|
||||
switch any(value).(type) {
|
||||
case OnYourDataDeploymentNameVectorizationSource:
|
||||
return &MongoDBChatExtensionParametersEmbeddingDependency{value: value}
|
||||
case OnYourDataEndpointVectorizationSource:
|
||||
return &MongoDBChatExtensionParametersEmbeddingDependency{value: value}
|
||||
default:
|
||||
panic(fmt.Sprintf("Invalid type %T for MongoDBChatExtensionParametersEmbeddingDependency", value))
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MongoDBChatExtensionParametersEmbeddingDependency.
|
||||
func (c MongoDBChatExtensionParametersEmbeddingDependency) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(c.value)
|
||||
}
|
|
@ -35,7 +35,7 @@ func Example_usingAzureOnYourData() {
|
|||
}
|
||||
|
||||
client := openai.NewClient(
|
||||
azure.WithEndpoint(endpoint, "2024-07-01-preview"),
|
||||
azure.WithEndpoint(endpoint, "2024-08-01-preview"),
|
||||
azure.WithTokenCredential(tokenCredential),
|
||||
)
|
||||
|
||||
|
@ -136,7 +136,7 @@ func Example_usingEnhancements() {
|
|||
}
|
||||
|
||||
client := openai.NewClient(
|
||||
azure.WithEndpoint(endpoint, "2024-07-01-preview"),
|
||||
azure.WithEndpoint(endpoint, "2024-08-01-preview"),
|
||||
azure.WithTokenCredential(tokenCredential),
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ require (
|
|||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
|
||||
github.com/openai/openai-go v0.1.0-alpha.23
|
||||
github.com/openai/openai-go v0.1.0-alpha.26
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -21,13 +21,13 @@ require (
|
|||
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/tidwall/gjson v1.17.3 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
@ -18,8 +18,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/openai/openai-go v0.1.0-alpha.23 h1:KDDR/z8jTrVgQd2Xpa55+Pzn4JWUYLmo67oQ/gj+vFE=
|
||||
github.com/openai/openai-go v0.1.0-alpha.23/go.mod h1:3SdE6BffOX9HPEQv8IL/fi3LYZ5TUpRYaqGQZbyk11A=
|
||||
github.com/openai/openai-go v0.1.0-alpha.26 h1:vDQF91WYAlhVifoa7bInwzwJyKQhE/ZgS0P8VQMudD0=
|
||||
github.com/openai/openai-go v0.1.0-alpha.26/go.mod h1:3SdE6BffOX9HPEQv8IL/fi3LYZ5TUpRYaqGQZbyk11A=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
@ -29,8 +29,8 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99
|
|||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
|
||||
github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
|
@ -38,15 +38,15 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
|||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
|
|
@ -11,8 +11,8 @@ package azopenaiextensions
|
|||
// AzureChatExtensionConfigurationClassification provides polymorphic access to related types.
|
||||
// Call the interface's GetAzureChatExtensionConfiguration() method to access the common type.
|
||||
// Use a type switch to determine the concrete type. The possible types are:
|
||||
// - *AzureChatExtensionConfiguration, *AzureCosmosDBChatExtensionConfiguration, *AzureMachineLearningIndexChatExtensionConfiguration,
|
||||
// - *AzureSearchChatExtensionConfiguration, *PineconeChatExtensionConfiguration
|
||||
// - *AzureChatExtensionConfiguration, *AzureCosmosDBChatExtensionConfiguration, *AzureSearchChatExtensionConfiguration, *ElasticsearchChatExtensionConfiguration,
|
||||
// - *MongoDBChatExtensionConfiguration, *PineconeChatExtensionConfiguration
|
||||
type AzureChatExtensionConfigurationClassification interface {
|
||||
// GetAzureChatExtensionConfiguration returns the AzureChatExtensionConfiguration content of the underlying type.
|
||||
GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration
|
||||
|
@ -23,7 +23,8 @@ type AzureChatExtensionConfigurationClassification interface {
|
|||
// Use a type switch to determine the concrete type. The possible types are:
|
||||
// - *OnYourDataAPIKeyAuthenticationOptions, *OnYourDataAccessTokenAuthenticationOptions, *OnYourDataAuthenticationOptions,
|
||||
// - *OnYourDataConnectionStringAuthenticationOptions, *OnYourDataEncodedAPIKeyAuthenticationOptions, *OnYourDataKeyAndKeyIDAuthenticationOptions,
|
||||
// - *OnYourDataSystemAssignedManagedIdentityAuthenticationOptions, *OnYourDataUserAssignedManagedIdentityAuthenticationOptions
|
||||
// - *OnYourDataSystemAssignedManagedIdentityAuthenticationOptions, *OnYourDataUserAssignedManagedIdentityAuthenticationOptions,
|
||||
// - *OnYourDataUsernameAndPasswordAuthenticationOptions
|
||||
type OnYourDataAuthenticationOptionsClassification interface {
|
||||
// GetOnYourDataAuthenticationOptions returns the OnYourDataAuthenticationOptions content of the underlying type.
|
||||
GetOnYourDataAuthenticationOptions() *OnYourDataAuthenticationOptions
|
||||
|
@ -41,8 +42,8 @@ type OnYourDataVectorSearchAuthenticationOptionsClassification interface {
|
|||
// OnYourDataVectorizationSourceClassification provides polymorphic access to related types.
|
||||
// Call the interface's GetOnYourDataVectorizationSource() method to access the common type.
|
||||
// Use a type switch to determine the concrete type. The possible types are:
|
||||
// - *OnYourDataDeploymentNameVectorizationSource, *OnYourDataEndpointVectorizationSource, *OnYourDataModelIDVectorizationSource,
|
||||
// - *OnYourDataVectorizationSource
|
||||
// - *OnYourDataDeploymentNameVectorizationSource, *OnYourDataEndpointVectorizationSource, *OnYourDataIntegratedVectorizationSource,
|
||||
// - *OnYourDataModelIDVectorizationSource, *OnYourDataVectorizationSource
|
||||
type OnYourDataVectorizationSourceClassification interface {
|
||||
// GetOnYourDataVectorizationSource returns the OnYourDataVectorizationSource content of the underlying type.
|
||||
GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
package internal_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const modelsGoFile = "../models.go"
|
||||
|
||||
var goModelRE = regexp.MustCompile(`(?m)^type\s+([^\s]+)\s+struct`)
|
||||
var byteFieldRE = regexp.MustCompile(`\s+([^\s]+)\s+\[\]byte`)
|
||||
|
||||
// Tests to see if any of our fields looks like one where the generator defaulted to
|
||||
// just accepting JSON, which is typical when TypeSpec uses a union type that is
|
||||
// not polymorphic (ie, string | someObject).
|
||||
func TestNoUntypedFields(t *testing.T) {
|
||||
// these types are allowed as they're intended to be []byte fields.
|
||||
allowed := map[string]bool{
|
||||
"AddUploadPartRequest.Data": true,
|
||||
"AudioTranscriptionOptions.File": true,
|
||||
"AudioTranslationOptions.File": true,
|
||||
"ChatCompletionsFunctionToolDefinitionFunction.Parameters": true, // user intentionally passes their own serialized JSON bytes
|
||||
"ChatCompletionsJSONSchemaResponseFormatJSONSchema.Schema": true, // user intentionally passes their own serialized JSON bytes
|
||||
"FunctionDefinition.Parameters": true, // user intentionally passes their own serialized JSON bytes
|
||||
"SpeechGenerationResponse.Audio": true,
|
||||
}
|
||||
|
||||
withByteFields, err := getGoModelsWithByteSliceFields(modelsGoFile, allowed)
|
||||
require.NoError(t, err)
|
||||
|
||||
// To fix this, you'll need manually create a union input type:
|
||||
//
|
||||
// 1. Create the union type and it's associated functions. Look at custom_models.go and [MongoDBChatExtensionParametersEmbeddingDependency]
|
||||
// to see what you'll need:
|
||||
// - MongoDBChatExtensionParametersEmbeddingDependency (the union type - naming is "object that has field" + "field name")
|
||||
// - NewMongoDBChatExtensionParametersEmbeddingDependency (the function the user calls to construct the MongoDBChatExtensionParametersEmbeddingDependency)
|
||||
// - MongoDBChatExtensionParametersEmbeddingDependency.MarshalJSON
|
||||
//
|
||||
// 2. Add in the an autorest.md snippet in "## Unions" section. This will make it so the Go emitter will reference
|
||||
// your custom type. See 'MongoDBChatExtensionParametersEmbeddingDependency's block within there for a sample.
|
||||
require.Empty(t, withByteFields, "no new []byte fields. If this test fails see the test for details on how to fix it.")
|
||||
}
|
||||
|
||||
func TestAllOYDModelsAreGenerated(t *testing.T) {
|
||||
if _, err := os.Stat("../testdata/generated/openapi.json"); err != nil {
|
||||
t.Skip("openapi.json isn't there, not doing codegen tests")
|
||||
}
|
||||
|
||||
// we do a little autorest hackery to trim out models that aren't used, just check that we didn't
|
||||
// miss something new. If we did, just add it to the "Keep only "Azure OpenAI On Your Data"
|
||||
// models, or enhancements."
|
||||
// yaml block.
|
||||
|
||||
// grab all the models that we have in our project as well
|
||||
goModels := map[string]bool{}
|
||||
|
||||
models, err := getFirstCaptureForRE("../models.go", goModelRE)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, model := range models {
|
||||
goModels[model] = true
|
||||
}
|
||||
|
||||
/*
|
||||
Example:
|
||||
|
||||
definitions.AzureCosmosDBChatExtensionConfiguration: {
|
||||
"allOf": [{
|
||||
"$ref": "#/definitions/AzureChatExtensionConfiguration"
|
||||
}],
|
||||
}
|
||||
*/
|
||||
|
||||
var openAPI *struct {
|
||||
Definitions map[string]struct {
|
||||
AllOf []*struct {
|
||||
Ref string `json:"$ref"`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("../testdata/generated/openapi.json")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = json.Unmarshal(data, &openAPI)
|
||||
require.NoError(t, err)
|
||||
|
||||
for name, defn := range openAPI.Definitions {
|
||||
if len(defn.AllOf) == 0 || len(defn.AllOf) > 1 || defn.AllOf[0].Ref != "#/definitions/AzureChatExtensionConfiguration" {
|
||||
continue
|
||||
}
|
||||
|
||||
assert.True(t, goModels[strings.ToLower(name)], "%s exists in the swagger, but didn't get generated", name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAPIVersionIsBumped(t *testing.T) {
|
||||
if _, err := os.Stat("../testdata/generated/openapi.json"); err != nil {
|
||||
t.Skip("openapi.json isn't there, not doing codegen tests")
|
||||
}
|
||||
|
||||
var openAPI *struct {
|
||||
Info struct {
|
||||
Version string
|
||||
}
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("../testdata/generated/openapi.json")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = json.Unmarshal(data, &openAPI)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("TestsUseNewAPIVersion", func(t *testing.T) {
|
||||
// ex: const apiVersion = "2024-07-01-preview"
|
||||
re := regexp.MustCompile(`const apiVersion = "(.+?)"`)
|
||||
|
||||
data, err := os.ReadFile("../client_shared_test.go")
|
||||
require.NoError(t, err)
|
||||
|
||||
matches := re.FindStringSubmatch(string(data))
|
||||
require.NotEmpty(t, matches)
|
||||
|
||||
require.Equal(t, openAPI.Info.Version, matches[1], "update the client_shared_test.go to use the API version we just generated from")
|
||||
})
|
||||
|
||||
// check examples
|
||||
t.Run("ExamplesUseNewAPIVersion", func(t *testing.T) {
|
||||
// ex: azure.WithEndpoint(endpoint, "2024-07-01-preview"),
|
||||
re := regexp.MustCompile(`azure\.WithEndpoint\(.+?, "(.+?)"\),`)
|
||||
|
||||
paths, err := filepath.Glob("../example*.go")
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, paths)
|
||||
|
||||
for _, path := range paths {
|
||||
t.Logf("Checking example %s", path)
|
||||
|
||||
file, err := os.ReadFile(path)
|
||||
require.NoError(t, err)
|
||||
|
||||
matches := re.FindAllStringSubmatch(string(file), -1)
|
||||
require.NotEmpty(t, matches)
|
||||
|
||||
for _, m := range matches {
|
||||
assert.Equalf(t, openAPI.Info.Version, m[1], "api-version out of date in %s", path)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func getGoModelsWithByteSliceFields(goFile string, allowed map[string]bool) ([]string, error) {
|
||||
file, err := os.Open(goFile)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
|
||||
var byteFields []string
|
||||
currentStruct := ""
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
||||
if matches := goModelRE.FindStringSubmatch(line); len(matches) > 0 {
|
||||
currentStruct = matches[1]
|
||||
continue
|
||||
}
|
||||
|
||||
if matches := byteFieldRE.FindStringSubmatch(line); len(matches) > 0 {
|
||||
key := fmt.Sprintf("%s.%s", currentStruct, matches[1])
|
||||
if allowed[key] {
|
||||
continue
|
||||
}
|
||||
|
||||
byteFields = append(byteFields, key)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(byteFields)
|
||||
return byteFields, nil
|
||||
}
|
||||
|
||||
func getFirstCaptureForRE(file string, re *regexp.Regexp) ([]string, error) {
|
||||
var modelNames []string
|
||||
|
||||
data, err := os.ReadFile(file)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, match := range re.FindAllStringSubmatch(string(data), -1) {
|
||||
modelName := strings.ToLower(match[1])
|
||||
modelNames = append(modelNames, modelName)
|
||||
}
|
||||
|
||||
return modelNames, nil
|
||||
}
|
|
@ -52,6 +52,9 @@ type AzureChatExtensionDataSourceResponseCitation struct {
|
|||
// The file path of the citation.
|
||||
Filepath *string
|
||||
|
||||
// The rerank score of the retrieved document.
|
||||
RerankScore *float64
|
||||
|
||||
// The title of the citation.
|
||||
Title *string
|
||||
|
||||
|
@ -180,11 +183,6 @@ type AzureCosmosDBChatExtensionParameters struct {
|
|||
// will decide the number of queries to send.
|
||||
MaxSearchQueries *int32
|
||||
|
||||
// Give the model instructions about how it should behave and any context it should reference when generating a response.
|
||||
// You can describe the assistant's personality and tell it how to format responses.
|
||||
// There's a 100 token limit for it, and it counts against the overall token limit.
|
||||
RoleInformation *string
|
||||
|
||||
// The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but
|
||||
// lower recall of the answer.
|
||||
Strictness *int32
|
||||
|
@ -256,73 +254,6 @@ type AzureGroundingEnhancementLineSpan struct {
|
|||
Text *string
|
||||
}
|
||||
|
||||
// AzureMachineLearningIndexChatExtensionConfiguration - A specific representation of configurable options for Azure Machine
|
||||
// Learning vector index when using it as an Azure OpenAI chat extension.
|
||||
type AzureMachineLearningIndexChatExtensionConfiguration struct {
|
||||
// REQUIRED; The parameters for the Azure Machine Learning vector index chat extension.
|
||||
Parameters *AzureMachineLearningIndexChatExtensionParameters
|
||||
|
||||
// REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure
|
||||
// chat extensions are only compatible with Azure OpenAI.
|
||||
Type *AzureChatExtensionType
|
||||
}
|
||||
|
||||
// GetAzureChatExtensionConfiguration implements the AzureChatExtensionConfigurationClassification interface for type AzureMachineLearningIndexChatExtensionConfiguration.
|
||||
func (a *AzureMachineLearningIndexChatExtensionConfiguration) GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration {
|
||||
return &AzureChatExtensionConfiguration{
|
||||
Type: a.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// AzureMachineLearningIndexChatExtensionParameters - Parameters for the Azure Machine Learning vector index chat extension.
|
||||
// The supported authentication types are AccessToken, SystemAssignedManagedIdentity and UserAssignedManagedIdentity.
|
||||
type AzureMachineLearningIndexChatExtensionParameters struct {
|
||||
// REQUIRED; The Azure Machine Learning vector index name.
|
||||
Name *string
|
||||
|
||||
// REQUIRED; The resource ID of the Azure Machine Learning project.
|
||||
ProjectResourceID *string
|
||||
|
||||
// REQUIRED; The version of the Azure Machine Learning vector index.
|
||||
Version *string
|
||||
|
||||
// If specified as true, the system will allow partial search results to be used and the request fails if all the queries
|
||||
// fail. If not specified, or specified as false, the request will fail if any
|
||||
// search query fails.
|
||||
AllowPartialResult *bool
|
||||
|
||||
// The authentication method to use when accessing the defined data source. Each data source type supports a specific set
|
||||
// of available authentication methods; please see the documentation of the data
|
||||
// source for supported mechanisms. If not otherwise provided, On Your Data will attempt to use System Managed Identity (default
|
||||
// credential) authentication.
|
||||
Authentication OnYourDataAuthenticationOptionsClassification
|
||||
|
||||
// Search filter. Only supported if the Azure Machine Learning vector index is of type AzureSearch.
|
||||
Filter *string
|
||||
|
||||
// Whether queries should be restricted to use of indexed data.
|
||||
InScope *bool
|
||||
|
||||
// The included properties of the output context. If not specified, the default value is citations and intent.
|
||||
IncludeContexts []OnYourDataContextProperty
|
||||
|
||||
// The max number of rewritten queries should be send to search provider for one user message. If not specified, the system
|
||||
// will decide the number of queries to send.
|
||||
MaxSearchQueries *int32
|
||||
|
||||
// Give the model instructions about how it should behave and any context it should reference when generating a response.
|
||||
// You can describe the assistant's personality and tell it how to format responses.
|
||||
// There's a 100 token limit for it, and it counts against the overall token limit.
|
||||
RoleInformation *string
|
||||
|
||||
// The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but
|
||||
// lower recall of the answer.
|
||||
Strictness *int32
|
||||
|
||||
// The configured top number of documents to feature for the configured query.
|
||||
TopNDocuments *int32
|
||||
}
|
||||
|
||||
// AzureSearchChatExtensionConfiguration - A specific representation of configurable options for Azure Search when using it
|
||||
// as an Azure OpenAI chat extension.
|
||||
type AzureSearchChatExtensionConfiguration struct {
|
||||
|
@ -383,11 +314,6 @@ type AzureSearchChatExtensionParameters struct {
|
|||
// The query type to use with Azure Cognitive Search.
|
||||
QueryType *AzureSearchQueryType
|
||||
|
||||
// Give the model instructions about how it should behave and any context it should reference when generating a response.
|
||||
// You can describe the assistant's personality and tell it how to format responses.
|
||||
// There's a 100 token limit for it, and it counts against the overall token limit.
|
||||
RoleInformation *string
|
||||
|
||||
// The additional semantic configuration for the query.
|
||||
SemanticConfiguration *string
|
||||
|
||||
|
@ -558,6 +484,93 @@ type ContentFilterResultsForPrompt struct {
|
|||
PromptIndex *int32
|
||||
}
|
||||
|
||||
// ElasticsearchChatExtensionConfiguration - A specific representation of configurable options for Elasticsearch when using
|
||||
// it as an Azure OpenAI chat extension.
|
||||
type ElasticsearchChatExtensionConfiguration struct {
|
||||
// REQUIRED; The parameters to use when configuring Elasticsearch®.
|
||||
Parameters *ElasticsearchChatExtensionParameters
|
||||
|
||||
// REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure
|
||||
// chat extensions are only compatible with Azure OpenAI.
|
||||
Type *AzureChatExtensionType
|
||||
}
|
||||
|
||||
// GetAzureChatExtensionConfiguration implements the AzureChatExtensionConfigurationClassification interface for type ElasticsearchChatExtensionConfiguration.
|
||||
func (e *ElasticsearchChatExtensionConfiguration) GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration {
|
||||
return &AzureChatExtensionConfiguration{
|
||||
Type: e.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// ElasticsearchChatExtensionParameters - Parameters to use when configuring Elasticsearch® as an Azure OpenAI chat extension.
|
||||
// The supported authentication types are KeyAndKeyId and EncodedAPIKey.
|
||||
type ElasticsearchChatExtensionParameters struct {
|
||||
// REQUIRED; The endpoint of Elasticsearch®.
|
||||
Endpoint *string
|
||||
|
||||
// REQUIRED; The index name of Elasticsearch®.
|
||||
IndexName *string
|
||||
|
||||
// If specified as true, the system will allow partial search results to be used and the request fails if all the queries
|
||||
// fail. If not specified, or specified as false, the request will fail if any
|
||||
// search query fails.
|
||||
AllowPartialResult *bool
|
||||
|
||||
// The authentication method to use when accessing the defined data source. Each data source type supports a specific set
|
||||
// of available authentication methods; please see the documentation of the data
|
||||
// source for supported mechanisms. If not otherwise provided, On Your Data will attempt to use System Managed Identity (default
|
||||
// credential) authentication.
|
||||
Authentication OnYourDataAuthenticationOptionsClassification
|
||||
|
||||
// The embedding dependency for vector search.
|
||||
EmbeddingDependency OnYourDataVectorizationSourceClassification
|
||||
|
||||
// The index field mapping options of Elasticsearch®.
|
||||
FieldsMapping *ElasticsearchIndexFieldMappingOptions
|
||||
|
||||
// Whether queries should be restricted to use of indexed data.
|
||||
InScope *bool
|
||||
|
||||
// The included properties of the output context. If not specified, the default value is citations and intent.
|
||||
IncludeContexts []OnYourDataContextProperty
|
||||
|
||||
// The max number of rewritten queries should be send to search provider for one user message. If not specified, the system
|
||||
// will decide the number of queries to send.
|
||||
MaxSearchQueries *int32
|
||||
|
||||
// The query type of Elasticsearch®.
|
||||
QueryType *ElasticsearchQueryType
|
||||
|
||||
// The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but
|
||||
// lower recall of the answer.
|
||||
Strictness *int32
|
||||
|
||||
// The configured top number of documents to feature for the configured query.
|
||||
TopNDocuments *int32
|
||||
}
|
||||
|
||||
// ElasticsearchIndexFieldMappingOptions - Optional settings to control how fields are processed when using a configured Elasticsearch®
|
||||
// resource.
|
||||
type ElasticsearchIndexFieldMappingOptions struct {
|
||||
// The names of index fields that should be treated as content.
|
||||
ContentFields []string
|
||||
|
||||
// The separator pattern that content fields should use.
|
||||
ContentFieldsSeparator *string
|
||||
|
||||
// The name of the index field to use as a filepath.
|
||||
FilepathField *string
|
||||
|
||||
// The name of the index field to use as a title.
|
||||
TitleField *string
|
||||
|
||||
// The name of the index field to use as a URL.
|
||||
URLField *string
|
||||
|
||||
// The names of fields that represent vector data.
|
||||
VectorFields []string
|
||||
}
|
||||
|
||||
// Error - The error object.
|
||||
type Error struct {
|
||||
// REQUIRED; One of a server-defined set of error codes.
|
||||
|
@ -567,6 +580,91 @@ type Error struct {
|
|||
Message *string
|
||||
}
|
||||
|
||||
// MongoDBChatExtensionConfiguration - A specific representation of configurable options for a MongoDB chat extension configuration.
|
||||
type MongoDBChatExtensionConfiguration struct {
|
||||
// REQUIRED; The parameters for the MongoDB chat extension.
|
||||
Parameters *MongoDBChatExtensionParameters
|
||||
|
||||
// REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure
|
||||
// chat extensions are only compatible with Azure OpenAI.
|
||||
Type *AzureChatExtensionType
|
||||
}
|
||||
|
||||
// GetAzureChatExtensionConfiguration implements the AzureChatExtensionConfigurationClassification interface for type MongoDBChatExtensionConfiguration.
|
||||
func (m *MongoDBChatExtensionConfiguration) GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration {
|
||||
return &AzureChatExtensionConfiguration{
|
||||
Type: m.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// MongoDBChatExtensionParameters - Parameters for the MongoDB chat extension. The supported authentication types are AccessToken,
|
||||
// SystemAssignedManagedIdentity and UserAssignedManagedIdentity.
|
||||
type MongoDBChatExtensionParameters struct {
|
||||
// REQUIRED; The app name for MongoDB.
|
||||
AppName *string
|
||||
|
||||
// REQUIRED; The collection name for MongoDB.
|
||||
CollectionName *string
|
||||
|
||||
// REQUIRED; The database name for MongoDB.
|
||||
DatabaseName *string
|
||||
|
||||
// REQUIRED; The vectorization source to use with the MongoDB chat extension.
|
||||
EmbeddingDependency *MongoDBChatExtensionParametersEmbeddingDependency
|
||||
|
||||
// REQUIRED; The endpoint name for MongoDB.
|
||||
Endpoint *string
|
||||
|
||||
// REQUIRED; Field mappings to apply to data used by the MongoDB data source. Note that content and vector field mappings
|
||||
// are required for MongoDB.
|
||||
FieldsMapping *MongoDBChatExtensionParametersFieldsMapping
|
||||
|
||||
// REQUIRED; The name of the MongoDB index.
|
||||
IndexName *string
|
||||
|
||||
// If specified as true, the system will allow partial search results to be used and the request fails if all the queries
|
||||
// fail. If not specified, or specified as false, the request will fail if any
|
||||
// search query fails.
|
||||
AllowPartialResult *bool
|
||||
|
||||
// The authentication method to use when accessing the defined data source. Each data source type supports a specific set
|
||||
// of available authentication methods; please see the documentation of the data
|
||||
// source for supported mechanisms. If not otherwise provided, On Your Data will attempt to use System Managed Identity (default
|
||||
// credential) authentication.
|
||||
Authentication OnYourDataAuthenticationOptionsClassification
|
||||
|
||||
// Whether queries should be restricted to use of indexed data.
|
||||
InScope *bool
|
||||
|
||||
// The included properties of the output context. If not specified, the default value is citations and intent.
|
||||
IncludeContexts []OnYourDataContextProperty
|
||||
|
||||
// The max number of rewritten queries should be send to search provider for one user message. If not specified, the system
|
||||
// will decide the number of queries to send.
|
||||
MaxSearchQueries *int32
|
||||
|
||||
// The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but
|
||||
// lower recall of the answer.
|
||||
Strictness *int32
|
||||
|
||||
// The configured top number of documents to feature for the configured query.
|
||||
TopNDocuments *int32
|
||||
}
|
||||
|
||||
// MongoDBChatExtensionParametersFieldsMapping - Field mappings to apply to data used by the MongoDB data source. Note that
|
||||
// content and vector field mappings are required for MongoDB.
|
||||
type MongoDBChatExtensionParametersFieldsMapping struct {
|
||||
// REQUIRED
|
||||
ContentFields []string
|
||||
|
||||
// REQUIRED
|
||||
VectorFields []string
|
||||
ContentFieldsSeparator *string
|
||||
FilepathField *string
|
||||
TitleField *string
|
||||
URLField *string
|
||||
}
|
||||
|
||||
// OnYourDataAPIKeyAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using an API key.
|
||||
type OnYourDataAPIKeyAuthenticationOptions struct {
|
||||
// REQUIRED; The API key to use for authentication.
|
||||
|
@ -688,6 +786,19 @@ func (o *OnYourDataEndpointVectorizationSource) GetOnYourDataVectorizationSource
|
|||
}
|
||||
}
|
||||
|
||||
// OnYourDataIntegratedVectorizationSource - Represents the integrated vectorizer defined within the search resource.
|
||||
type OnYourDataIntegratedVectorizationSource struct {
|
||||
// REQUIRED; The type of vectorization source to use.
|
||||
Type *OnYourDataVectorizationSourceType
|
||||
}
|
||||
|
||||
// GetOnYourDataVectorizationSource implements the OnYourDataVectorizationSourceClassification interface for type OnYourDataIntegratedVectorizationSource.
|
||||
func (o *OnYourDataIntegratedVectorizationSource) GetOnYourDataVectorizationSource() *OnYourDataVectorizationSource {
|
||||
return &OnYourDataVectorizationSource{
|
||||
Type: o.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// OnYourDataKeyAndKeyIDAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using an Elasticsearch
|
||||
// key and key ID pair.
|
||||
type OnYourDataKeyAndKeyIDAuthenticationOptions struct {
|
||||
|
@ -756,6 +867,26 @@ func (o *OnYourDataUserAssignedManagedIdentityAuthenticationOptions) GetOnYourDa
|
|||
}
|
||||
}
|
||||
|
||||
// OnYourDataUsernameAndPasswordAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using
|
||||
// a username and password.
|
||||
type OnYourDataUsernameAndPasswordAuthenticationOptions struct {
|
||||
// REQUIRED; The password.
|
||||
Password *string
|
||||
|
||||
// REQUIRED; The authentication type.
|
||||
Type *OnYourDataAuthenticationType
|
||||
|
||||
// REQUIRED; The username.
|
||||
Username *string
|
||||
}
|
||||
|
||||
// GetOnYourDataAuthenticationOptions implements the OnYourDataAuthenticationOptionsClassification interface for type OnYourDataUsernameAndPasswordAuthenticationOptions.
|
||||
func (o *OnYourDataUsernameAndPasswordAuthenticationOptions) GetOnYourDataAuthenticationOptions() *OnYourDataAuthenticationOptions {
|
||||
return &OnYourDataAuthenticationOptions{
|
||||
Type: o.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// OnYourDataVectorSearchAPIKeyAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using
|
||||
// an API key.
|
||||
type OnYourDataVectorSearchAPIKeyAuthenticationOptions struct {
|
||||
|
@ -870,11 +1001,6 @@ type PineconeChatExtensionParameters struct {
|
|||
// will decide the number of queries to send.
|
||||
MaxSearchQueries *int32
|
||||
|
||||
// Give the model instructions about how it should behave and any context it should reference when generating a response.
|
||||
// You can describe the assistant's personality and tell it how to format responses.
|
||||
// There's a 100 token limit for it, and it counts against the overall token limit.
|
||||
RoleInformation *string
|
||||
|
||||
// The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but
|
||||
// lower recall of the answer.
|
||||
Strictness *int32
|
||||
|
|
|
@ -107,6 +107,7 @@ func (a AzureChatExtensionDataSourceResponseCitation) MarshalJSON() ([]byte, err
|
|||
populate(objectMap, "chunk_id", a.ChunkID)
|
||||
populate(objectMap, "content", a.Content)
|
||||
populate(objectMap, "filepath", a.Filepath)
|
||||
populate(objectMap, "rerank_score", a.RerankScore)
|
||||
populate(objectMap, "title", a.Title)
|
||||
populate(objectMap, "url", a.URL)
|
||||
return json.Marshal(objectMap)
|
||||
|
@ -130,6 +131,9 @@ func (a *AzureChatExtensionDataSourceResponseCitation) UnmarshalJSON(data []byte
|
|||
case "filepath":
|
||||
err = unpopulate(val, "Filepath", &a.Filepath)
|
||||
delete(rawMsg, key)
|
||||
case "rerank_score":
|
||||
err = unpopulate(val, "RerankScore", &a.RerankScore)
|
||||
delete(rawMsg, key)
|
||||
case "title":
|
||||
err = unpopulate(val, "Title", &a.Title)
|
||||
delete(rawMsg, key)
|
||||
|
@ -340,7 +344,6 @@ func (a AzureCosmosDBChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
|||
populate(objectMap, "include_contexts", a.IncludeContexts)
|
||||
populate(objectMap, "index_name", a.IndexName)
|
||||
populate(objectMap, "max_search_queries", a.MaxSearchQueries)
|
||||
populate(objectMap, "role_information", a.RoleInformation)
|
||||
populate(objectMap, "strictness", a.Strictness)
|
||||
populate(objectMap, "top_n_documents", a.TopNDocuments)
|
||||
return json.Marshal(objectMap)
|
||||
|
@ -385,9 +388,6 @@ func (a *AzureCosmosDBChatExtensionParameters) UnmarshalJSON(data []byte) error
|
|||
case "max_search_queries":
|
||||
err = unpopulate(val, "MaxSearchQueries", &a.MaxSearchQueries)
|
||||
delete(rawMsg, key)
|
||||
case "role_information":
|
||||
err = unpopulate(val, "RoleInformation", &a.RoleInformation)
|
||||
delete(rawMsg, key)
|
||||
case "strictness":
|
||||
err = unpopulate(val, "Strictness", &a.Strictness)
|
||||
delete(rawMsg, key)
|
||||
|
@ -577,108 +577,6 @@ func (a *AzureGroundingEnhancementLineSpan) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type AzureMachineLearningIndexChatExtensionConfiguration.
|
||||
func (a AzureMachineLearningIndexChatExtensionConfiguration) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "parameters", a.Parameters)
|
||||
objectMap["type"] = AzureChatExtensionTypeAzureMachineLearningIndex
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMachineLearningIndexChatExtensionConfiguration.
|
||||
func (a *AzureMachineLearningIndexChatExtensionConfiguration) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", a, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "parameters":
|
||||
err = unpopulate(val, "Parameters", &a.Parameters)
|
||||
delete(rawMsg, key)
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &a.Type)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", a, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type AzureMachineLearningIndexChatExtensionParameters.
|
||||
func (a AzureMachineLearningIndexChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "allow_partial_result", a.AllowPartialResult)
|
||||
populate(objectMap, "authentication", a.Authentication)
|
||||
populate(objectMap, "filter", a.Filter)
|
||||
populate(objectMap, "in_scope", a.InScope)
|
||||
populate(objectMap, "include_contexts", a.IncludeContexts)
|
||||
populate(objectMap, "max_search_queries", a.MaxSearchQueries)
|
||||
populate(objectMap, "name", a.Name)
|
||||
populate(objectMap, "project_resource_id", a.ProjectResourceID)
|
||||
populate(objectMap, "role_information", a.RoleInformation)
|
||||
populate(objectMap, "strictness", a.Strictness)
|
||||
populate(objectMap, "top_n_documents", a.TopNDocuments)
|
||||
populate(objectMap, "version", a.Version)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMachineLearningIndexChatExtensionParameters.
|
||||
func (a *AzureMachineLearningIndexChatExtensionParameters) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", a, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "allow_partial_result":
|
||||
err = unpopulate(val, "AllowPartialResult", &a.AllowPartialResult)
|
||||
delete(rawMsg, key)
|
||||
case "authentication":
|
||||
a.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val)
|
||||
delete(rawMsg, key)
|
||||
case "filter":
|
||||
err = unpopulate(val, "Filter", &a.Filter)
|
||||
delete(rawMsg, key)
|
||||
case "in_scope":
|
||||
err = unpopulate(val, "InScope", &a.InScope)
|
||||
delete(rawMsg, key)
|
||||
case "include_contexts":
|
||||
err = unpopulate(val, "IncludeContexts", &a.IncludeContexts)
|
||||
delete(rawMsg, key)
|
||||
case "max_search_queries":
|
||||
err = unpopulate(val, "MaxSearchQueries", &a.MaxSearchQueries)
|
||||
delete(rawMsg, key)
|
||||
case "name":
|
||||
err = unpopulate(val, "Name", &a.Name)
|
||||
delete(rawMsg, key)
|
||||
case "project_resource_id":
|
||||
err = unpopulate(val, "ProjectResourceID", &a.ProjectResourceID)
|
||||
delete(rawMsg, key)
|
||||
case "role_information":
|
||||
err = unpopulate(val, "RoleInformation", &a.RoleInformation)
|
||||
delete(rawMsg, key)
|
||||
case "strictness":
|
||||
err = unpopulate(val, "Strictness", &a.Strictness)
|
||||
delete(rawMsg, key)
|
||||
case "top_n_documents":
|
||||
err = unpopulate(val, "TopNDocuments", &a.TopNDocuments)
|
||||
delete(rawMsg, key)
|
||||
case "version":
|
||||
err = unpopulate(val, "Version", &a.Version)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", a, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type AzureSearchChatExtensionConfiguration.
|
||||
func (a AzureSearchChatExtensionConfiguration) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
|
@ -724,7 +622,6 @@ func (a AzureSearchChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
|||
populate(objectMap, "index_name", a.IndexName)
|
||||
populate(objectMap, "max_search_queries", a.MaxSearchQueries)
|
||||
populate(objectMap, "query_type", a.QueryType)
|
||||
populate(objectMap, "role_information", a.RoleInformation)
|
||||
populate(objectMap, "semantic_configuration", a.SemanticConfiguration)
|
||||
populate(objectMap, "strictness", a.Strictness)
|
||||
populate(objectMap, "top_n_documents", a.TopNDocuments)
|
||||
|
@ -773,9 +670,6 @@ func (a *AzureSearchChatExtensionParameters) UnmarshalJSON(data []byte) error {
|
|||
case "query_type":
|
||||
err = unpopulate(val, "QueryType", &a.QueryType)
|
||||
delete(rawMsg, key)
|
||||
case "role_information":
|
||||
err = unpopulate(val, "RoleInformation", &a.RoleInformation)
|
||||
delete(rawMsg, key)
|
||||
case "semantic_configuration":
|
||||
err = unpopulate(val, "SemanticConfiguration", &a.SemanticConfiguration)
|
||||
delete(rawMsg, key)
|
||||
|
@ -1156,6 +1050,155 @@ func (c *ContentFilterResultsForPrompt) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ElasticsearchChatExtensionConfiguration.
|
||||
func (e ElasticsearchChatExtensionConfiguration) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "parameters", e.Parameters)
|
||||
objectMap["type"] = AzureChatExtensionTypeElasticsearch
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticsearchChatExtensionConfiguration.
|
||||
func (e *ElasticsearchChatExtensionConfiguration) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "parameters":
|
||||
err = unpopulate(val, "Parameters", &e.Parameters)
|
||||
delete(rawMsg, key)
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &e.Type)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ElasticsearchChatExtensionParameters.
|
||||
func (e ElasticsearchChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "allow_partial_result", e.AllowPartialResult)
|
||||
populate(objectMap, "authentication", e.Authentication)
|
||||
populate(objectMap, "embedding_dependency", e.EmbeddingDependency)
|
||||
populate(objectMap, "endpoint", e.Endpoint)
|
||||
populate(objectMap, "fields_mapping", e.FieldsMapping)
|
||||
populate(objectMap, "in_scope", e.InScope)
|
||||
populate(objectMap, "include_contexts", e.IncludeContexts)
|
||||
populate(objectMap, "index_name", e.IndexName)
|
||||
populate(objectMap, "max_search_queries", e.MaxSearchQueries)
|
||||
populate(objectMap, "query_type", e.QueryType)
|
||||
populate(objectMap, "strictness", e.Strictness)
|
||||
populate(objectMap, "top_n_documents", e.TopNDocuments)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticsearchChatExtensionParameters.
|
||||
func (e *ElasticsearchChatExtensionParameters) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "allow_partial_result":
|
||||
err = unpopulate(val, "AllowPartialResult", &e.AllowPartialResult)
|
||||
delete(rawMsg, key)
|
||||
case "authentication":
|
||||
e.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val)
|
||||
delete(rawMsg, key)
|
||||
case "embedding_dependency":
|
||||
e.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val)
|
||||
delete(rawMsg, key)
|
||||
case "endpoint":
|
||||
err = unpopulate(val, "Endpoint", &e.Endpoint)
|
||||
delete(rawMsg, key)
|
||||
case "fields_mapping":
|
||||
err = unpopulate(val, "FieldsMapping", &e.FieldsMapping)
|
||||
delete(rawMsg, key)
|
||||
case "in_scope":
|
||||
err = unpopulate(val, "InScope", &e.InScope)
|
||||
delete(rawMsg, key)
|
||||
case "include_contexts":
|
||||
err = unpopulate(val, "IncludeContexts", &e.IncludeContexts)
|
||||
delete(rawMsg, key)
|
||||
case "index_name":
|
||||
err = unpopulate(val, "IndexName", &e.IndexName)
|
||||
delete(rawMsg, key)
|
||||
case "max_search_queries":
|
||||
err = unpopulate(val, "MaxSearchQueries", &e.MaxSearchQueries)
|
||||
delete(rawMsg, key)
|
||||
case "query_type":
|
||||
err = unpopulate(val, "QueryType", &e.QueryType)
|
||||
delete(rawMsg, key)
|
||||
case "strictness":
|
||||
err = unpopulate(val, "Strictness", &e.Strictness)
|
||||
delete(rawMsg, key)
|
||||
case "top_n_documents":
|
||||
err = unpopulate(val, "TopNDocuments", &e.TopNDocuments)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ElasticsearchIndexFieldMappingOptions.
|
||||
func (e ElasticsearchIndexFieldMappingOptions) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "content_fields", e.ContentFields)
|
||||
populate(objectMap, "content_fields_separator", e.ContentFieldsSeparator)
|
||||
populate(objectMap, "filepath_field", e.FilepathField)
|
||||
populate(objectMap, "title_field", e.TitleField)
|
||||
populate(objectMap, "url_field", e.URLField)
|
||||
populate(objectMap, "vector_fields", e.VectorFields)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticsearchIndexFieldMappingOptions.
|
||||
func (e *ElasticsearchIndexFieldMappingOptions) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "content_fields":
|
||||
err = unpopulate(val, "ContentFields", &e.ContentFields)
|
||||
delete(rawMsg, key)
|
||||
case "content_fields_separator":
|
||||
err = unpopulate(val, "ContentFieldsSeparator", &e.ContentFieldsSeparator)
|
||||
delete(rawMsg, key)
|
||||
case "filepath_field":
|
||||
err = unpopulate(val, "FilepathField", &e.FilepathField)
|
||||
delete(rawMsg, key)
|
||||
case "title_field":
|
||||
err = unpopulate(val, "TitleField", &e.TitleField)
|
||||
delete(rawMsg, key)
|
||||
case "url_field":
|
||||
err = unpopulate(val, "URLField", &e.URLField)
|
||||
delete(rawMsg, key)
|
||||
case "vector_fields":
|
||||
err = unpopulate(val, "VectorFields", &e.VectorFields)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", e, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type Error.
|
||||
func (e Error) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
|
@ -1187,6 +1230,163 @@ func (e *Error) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MongoDBChatExtensionConfiguration.
|
||||
func (m MongoDBChatExtensionConfiguration) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "parameters", m.Parameters)
|
||||
objectMap["type"] = AzureChatExtensionTypeMongoDB
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDBChatExtensionConfiguration.
|
||||
func (m *MongoDBChatExtensionConfiguration) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "parameters":
|
||||
err = unpopulate(val, "Parameters", &m.Parameters)
|
||||
delete(rawMsg, key)
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &m.Type)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MongoDBChatExtensionParameters.
|
||||
func (m MongoDBChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "allow_partial_result", m.AllowPartialResult)
|
||||
populate(objectMap, "app_name", m.AppName)
|
||||
populate(objectMap, "authentication", m.Authentication)
|
||||
populate(objectMap, "collection_name", m.CollectionName)
|
||||
populate(objectMap, "database_name", m.DatabaseName)
|
||||
populate(objectMap, "embedding_dependency", m.EmbeddingDependency)
|
||||
populate(objectMap, "endpoint", m.Endpoint)
|
||||
populate(objectMap, "fields_mapping", m.FieldsMapping)
|
||||
populate(objectMap, "in_scope", m.InScope)
|
||||
populate(objectMap, "include_contexts", m.IncludeContexts)
|
||||
populate(objectMap, "index_name", m.IndexName)
|
||||
populate(objectMap, "max_search_queries", m.MaxSearchQueries)
|
||||
populate(objectMap, "strictness", m.Strictness)
|
||||
populate(objectMap, "top_n_documents", m.TopNDocuments)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDBChatExtensionParameters.
|
||||
func (m *MongoDBChatExtensionParameters) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "allow_partial_result":
|
||||
err = unpopulate(val, "AllowPartialResult", &m.AllowPartialResult)
|
||||
delete(rawMsg, key)
|
||||
case "app_name":
|
||||
err = unpopulate(val, "AppName", &m.AppName)
|
||||
delete(rawMsg, key)
|
||||
case "authentication":
|
||||
m.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val)
|
||||
delete(rawMsg, key)
|
||||
case "collection_name":
|
||||
err = unpopulate(val, "CollectionName", &m.CollectionName)
|
||||
delete(rawMsg, key)
|
||||
case "database_name":
|
||||
err = unpopulate(val, "DatabaseName", &m.DatabaseName)
|
||||
delete(rawMsg, key)
|
||||
case "embedding_dependency":
|
||||
err = unpopulate(val, "EmbeddingDependency", &m.EmbeddingDependency)
|
||||
delete(rawMsg, key)
|
||||
case "endpoint":
|
||||
err = unpopulate(val, "Endpoint", &m.Endpoint)
|
||||
delete(rawMsg, key)
|
||||
case "fields_mapping":
|
||||
err = unpopulate(val, "FieldsMapping", &m.FieldsMapping)
|
||||
delete(rawMsg, key)
|
||||
case "in_scope":
|
||||
err = unpopulate(val, "InScope", &m.InScope)
|
||||
delete(rawMsg, key)
|
||||
case "include_contexts":
|
||||
err = unpopulate(val, "IncludeContexts", &m.IncludeContexts)
|
||||
delete(rawMsg, key)
|
||||
case "index_name":
|
||||
err = unpopulate(val, "IndexName", &m.IndexName)
|
||||
delete(rawMsg, key)
|
||||
case "max_search_queries":
|
||||
err = unpopulate(val, "MaxSearchQueries", &m.MaxSearchQueries)
|
||||
delete(rawMsg, key)
|
||||
case "strictness":
|
||||
err = unpopulate(val, "Strictness", &m.Strictness)
|
||||
delete(rawMsg, key)
|
||||
case "top_n_documents":
|
||||
err = unpopulate(val, "TopNDocuments", &m.TopNDocuments)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MongoDBChatExtensionParametersFieldsMapping.
|
||||
func (m MongoDBChatExtensionParametersFieldsMapping) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "content_fields", m.ContentFields)
|
||||
populate(objectMap, "content_fields_separator", m.ContentFieldsSeparator)
|
||||
populate(objectMap, "filepath_field", m.FilepathField)
|
||||
populate(objectMap, "title_field", m.TitleField)
|
||||
populate(objectMap, "url_field", m.URLField)
|
||||
populate(objectMap, "vector_fields", m.VectorFields)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDBChatExtensionParametersFieldsMapping.
|
||||
func (m *MongoDBChatExtensionParametersFieldsMapping) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "content_fields":
|
||||
err = unpopulate(val, "ContentFields", &m.ContentFields)
|
||||
delete(rawMsg, key)
|
||||
case "content_fields_separator":
|
||||
err = unpopulate(val, "ContentFieldsSeparator", &m.ContentFieldsSeparator)
|
||||
delete(rawMsg, key)
|
||||
case "filepath_field":
|
||||
err = unpopulate(val, "FilepathField", &m.FilepathField)
|
||||
delete(rawMsg, key)
|
||||
case "title_field":
|
||||
err = unpopulate(val, "TitleField", &m.TitleField)
|
||||
delete(rawMsg, key)
|
||||
case "url_field":
|
||||
err = unpopulate(val, "URLField", &m.URLField)
|
||||
delete(rawMsg, key)
|
||||
case "vector_fields":
|
||||
err = unpopulate(val, "VectorFields", &m.VectorFields)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", m, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OnYourDataAPIKeyAuthenticationOptions.
|
||||
func (o OnYourDataAPIKeyAuthenticationOptions) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
|
@ -1408,6 +1608,33 @@ func (o *OnYourDataEndpointVectorizationSource) UnmarshalJSON(data []byte) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OnYourDataIntegratedVectorizationSource.
|
||||
func (o OnYourDataIntegratedVectorizationSource) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
objectMap["type"] = OnYourDataVectorizationSourceTypeIntegrated
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type OnYourDataIntegratedVectorizationSource.
|
||||
func (o *OnYourDataIntegratedVectorizationSource) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &o.Type)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OnYourDataKeyAndKeyIDAuthenticationOptions.
|
||||
func (o OnYourDataKeyAndKeyIDAuthenticationOptions) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
|
@ -1532,6 +1759,41 @@ func (o *OnYourDataUserAssignedManagedIdentityAuthenticationOptions) UnmarshalJS
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OnYourDataUsernameAndPasswordAuthenticationOptions.
|
||||
func (o OnYourDataUsernameAndPasswordAuthenticationOptions) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
populate(objectMap, "password", o.Password)
|
||||
objectMap["type"] = OnYourDataAuthenticationTypeUsernameAndPassword
|
||||
populate(objectMap, "username", o.Username)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type OnYourDataUsernameAndPasswordAuthenticationOptions.
|
||||
func (o *OnYourDataUsernameAndPasswordAuthenticationOptions) UnmarshalJSON(data []byte) error {
|
||||
var rawMsg map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawMsg); err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
for key, val := range rawMsg {
|
||||
var err error
|
||||
switch key {
|
||||
case "password":
|
||||
err = unpopulate(val, "Password", &o.Password)
|
||||
delete(rawMsg, key)
|
||||
case "type":
|
||||
err = unpopulate(val, "Type", &o.Type)
|
||||
delete(rawMsg, key)
|
||||
case "username":
|
||||
err = unpopulate(val, "Username", &o.Username)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshalling type %T: %v", o, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OnYourDataVectorSearchAPIKeyAuthenticationOptions.
|
||||
func (o OnYourDataVectorSearchAPIKeyAuthenticationOptions) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]any)
|
||||
|
@ -1691,7 +1953,6 @@ func (p PineconeChatExtensionParameters) MarshalJSON() ([]byte, error) {
|
|||
populate(objectMap, "include_contexts", p.IncludeContexts)
|
||||
populate(objectMap, "index_name", p.IndexName)
|
||||
populate(objectMap, "max_search_queries", p.MaxSearchQueries)
|
||||
populate(objectMap, "role_information", p.RoleInformation)
|
||||
populate(objectMap, "strictness", p.Strictness)
|
||||
populate(objectMap, "top_n_documents", p.TopNDocuments)
|
||||
return json.Marshal(objectMap)
|
||||
|
@ -1733,9 +1994,6 @@ func (p *PineconeChatExtensionParameters) UnmarshalJSON(data []byte) error {
|
|||
case "max_search_queries":
|
||||
err = unpopulate(val, "MaxSearchQueries", &p.MaxSearchQueries)
|
||||
delete(rawMsg, key)
|
||||
case "role_information":
|
||||
err = unpopulate(val, "RoleInformation", &p.RoleInformation)
|
||||
delete(rawMsg, key)
|
||||
case "strictness":
|
||||
err = unpopulate(val, "Strictness", &p.Strictness)
|
||||
delete(rawMsg, key)
|
||||
|
|
|
@ -34,6 +34,8 @@ func unmarshalOnYourDataAuthenticationOptionsClassification(rawMsg json.RawMessa
|
|||
b = &OnYourDataSystemAssignedManagedIdentityAuthenticationOptions{}
|
||||
case string(OnYourDataAuthenticationTypeUserAssignedManagedIdentity):
|
||||
b = &OnYourDataUserAssignedManagedIdentityAuthenticationOptions{}
|
||||
case string(OnYourDataAuthenticationTypeUsernameAndPassword):
|
||||
b = &OnYourDataUsernameAndPasswordAuthenticationOptions{}
|
||||
default:
|
||||
b = &OnYourDataAuthenticationOptions{}
|
||||
}
|
||||
|
@ -80,6 +82,8 @@ func unmarshalOnYourDataVectorizationSourceClassification(rawMsg json.RawMessage
|
|||
b = &OnYourDataDeploymentNameVectorizationSource{}
|
||||
case string(OnYourDataVectorizationSourceTypeEndpoint):
|
||||
b = &OnYourDataEndpointVectorizationSource{}
|
||||
case string(OnYourDataVectorizationSourceTypeIntegrated):
|
||||
b = &OnYourDataIntegratedVectorizationSource{}
|
||||
case string(OnYourDataVectorizationSourceTypeModelID):
|
||||
b = &OnYourDataModelIDVectorizationSource{}
|
||||
default:
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
directory: specification/cognitiveservices/OpenAI.Inference
|
||||
commit: cd41ba31a6af51dae34b0a5930eeb2e77a04b481
|
||||
commit: 79f6dc210e78d0544e68add22ae932553ad142f6
|
||||
repo: Azure/azure-rest-api-specs
|
||||
|
|
Загрузка…
Ссылка в новой задаче