Skip to content

Commit

Permalink
[azopenaiextensions] Prepping for release tomorrow (#23551)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
richardpark-msft authored Oct 10, 2024
1 parent a230ef2 commit 8759ee6
Show file tree
Hide file tree
Showing 16 changed files with 922 additions and 234 deletions.
6 changes: 4 additions & 2 deletions sdk/ai/azopenaiextensions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 21 additions & 2 deletions sdk/ai/azopenaiextensions/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)) {
Expand Down Expand Up @@ -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 $;
```
3 changes: 3 additions & 0 deletions sdk/ai/azopenaiextensions/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions sdk/ai/azopenaiextensions/client_assistants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/azopenaiextensions/client_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 28 additions & 4 deletions sdk/ai/azopenaiextensions/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions sdk/ai/azopenaiextensions/custom_models.go
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions sdk/ai/azopenaiextensions/example_azure_on_your_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down Expand Up @@ -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),
)

Expand Down
12 changes: 6 additions & 6 deletions sdk/ai/azopenaiextensions/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
)
24 changes: 12 additions & 12 deletions sdk/ai/azopenaiextensions/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -29,24 +29,24 @@ 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=
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=
Expand Down
11 changes: 6 additions & 5 deletions sdk/ai/azopenaiextensions/interfaces.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8759ee6

Please sign in to comment.