Skip to content

Commit

Permalink
[azopenaiassistants] Updates for 2024-10-01-preview (#23730)
Browse files Browse the repository at this point in the history
* hash+gen

* Adding in MessageAttachmentToolDefinition

* Accidental copy/paste

* Updating doc comment for MessageAttachmentToolDefinition

* Update docindex.yml to use Python 3.11 (#23719)

Co-authored-by: Daniel Jurek <[email protected]>

* Refresh OIDC token in azadmin test resources scripts (#23722)

* remove pkg.go.dev link in readme (#23708)

* remove pkg.go.dev link in readme

* fix changelog

* upgrade typesspec-go (#23720)

* [azopenai] Inference changes for 2024-10-01-preview (#23672)

* update for 1.2.0 release (#23728)

* Sync eng/common directory with azure-sdk-tools for PR 9328 (#23692)

* ensure that ChangedServices value within the generated pr diff is always properly an array of strings
* upload the changed services as an attachment named AdditionalTags in save-package-properties.yml, to allow PipelineWitness to tag public builds during log processing

---------

Co-authored-by: Scott Beddall <[email protected]>
Co-authored-by: Scott Beddall <[email protected]>
Co-authored-by: Patrick Hallisey <[email protected]>

* refine typespec release tool (#23735)

* Added permissions & resourcetype parameters in listblob response  (#23687)

* one

* Add permissions in ListBlobsIncludeItems

* Add permissions in ListBlobsIncludeItems

* Appending the value to swagger

* Added Owner,Group,Permissions,Acl,ResourceType in ListBlob Response

* [Storage] Prep for stg 95 GA release (#23742)

* Prep for stg 95 GA release

* Update CHANGELOG.md

format for changelog

* Add SparseCheckoutPaths to archetype-typespec-emitter.yml (#23740)

Co-authored-by: Wei Hu <[email protected]>

* [azopenai] Update azopenai changelog. (#23732)

* Fix missing stress matrix display name filter (#23726)

Co-authored-by: Ben Broderick Phillips <[email protected]>

* update date (#23746)

* [azopenai] non-existing deployments fail in a different way now. (#23747)

* Increment package version after release of ai/azopenai (#23750)

* [Release] sdk/resourcemanager/hybridcompute/armhybridcompute/2.1.0-beta.1 generation from spec commit: 63d530d0def1c624f5d42d39170ff4ac196522e2 (#23753)

* Increment package version after release of security/keyvault/azadmin (#23749)

* Update azopenai* to use hardcoded variable group config (#23748)

* Update azopenai* to use hardcoded variable group config

* Remove bicep template for ai services

* [Release] sdk/resourcemanager/networkcloud/armnetworkcloud/1.2.0-beta.1 generation from spec commit: 4e46346c63935bace7e24f806b4b084f2589d660 (#23757)

* Add helpers to log a GitHub "notice" (#23764)

Co-authored-by: Mike Harder <[email protected]>

* Increment package version after release of storage/azdatalake (#23745)

* Increment package version after release of storage/azblob (#23744)

* Increment package version after release of storage/azfile (#23743)

* batching adjustments for create-prjobmatrix (#23773)

Co-authored-by: Scott Beddall <[email protected]>

* changelog

* updated version

* Update sdk/ai/azopenaiassistants/CHANGELOG.md

Co-authored-by: Wes Haggard <[email protected]>

* updated

---------

Co-authored-by: ripark <[email protected]>
Co-authored-by: Richard Park <[email protected]>
Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Daniel Jurek <[email protected]>
Co-authored-by: Ben Broderick Phillips <[email protected]>
Co-authored-by: Chenjie Shi <[email protected]>
Co-authored-by: Ashley Stanton-Nurse <[email protected]>
Co-authored-by: Scott Beddall <[email protected]>
Co-authored-by: Scott Beddall <[email protected]>
Co-authored-by: Patrick Hallisey <[email protected]>
Co-authored-by: ashruti-msft <[email protected]>
Co-authored-by: tanyasethi-msft <[email protected]>
Co-authored-by: Wei Hu <[email protected]>
Co-authored-by: Grace Wilcox <[email protected]>
Co-authored-by: Judy Liu <[email protected]>
Co-authored-by: Mike Harder <[email protected]>
Co-authored-by: Wes Haggard <[email protected]>
  • Loading branch information
18 people authored Dec 3, 2024
1 parent 590fc96 commit 2ea046b
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 121 deletions.
11 changes: 10 additions & 1 deletion sdk/ai/azopenaiassistants/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 0.3.0 (2024-12-03)

### Features Added

- Added support for the `ParallelToolCalls` option.

### Breaking Changes

- `MessageAttachmentToolAssignment` is now `MessageAttachmentToolDefinition`.

## 0.2.1 (2024-09-10)

### Features Added
Expand All @@ -23,7 +33,6 @@
### Bugs Fixed

- ThreadRun.RequiredAction was deserialized incorrectly, making it impossible to actually resubmit a tool output. (PR#22834)

## 0.1.0 (2024-03-05)

* Initial release of the `azopenaiassistants` library
16 changes: 16 additions & 0 deletions sdk/ai/azopenaiassistants/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ directive:
return $;
```

MessageAttachmentToolDefinition

```yaml
directive:
- from: swagger-document
where: $.definitions
transform: |
// create the dummy type that I can use to point to my manually created union
$.MessageAttachmentToolDefinition = {
"x-ms-external": true,
"type": "object",
"properties": { "ignored": { "type": "string" } },
"x-ms-client-name": "MessageAttachmentToolDefinition"
};
```

## Model -> DeploymentName

```yaml
Expand Down
78 changes: 39 additions & 39 deletions sdk/ai/azopenaiassistants/client.go

Large diffs are not rendered by default.

17 changes: 6 additions & 11 deletions sdk/ai/azopenaiassistants/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func TestAssistantMessages(t *testing.T) {
Attachments: []azopenaiassistants.MessageAttachment{
{
FileID: uploadResp.ID,
Tools: []azopenaiassistants.MessageAttachmentToolAssignment{
{Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentTypeCodeInterpreter)},
{Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentTypeFileSearch)},
Tools: []azopenaiassistants.MessageAttachmentToolDefinition{
{CodeInterpreterToolDefinition: &azopenaiassistants.CodeInterpreterToolDefinition{}},
{FileSearchToolDefinition: &azopenaiassistants.FileSearchToolDefinition{}},
},
},
},
Expand All @@ -169,17 +169,12 @@ func TestAssistantMessages(t *testing.T) {
attachmentTools := messageResp.Attachments[0].Tools

// just trying to keep a consistent ordering of the tools for our checks.
if *attachmentTools[0].Type == azopenaiassistants.MessageAttachmentToolAssignmentTypeFileSearch {
if attachmentTools[0].FileSearchToolDefinition != nil {
attachmentTools[0], attachmentTools[1] = attachmentTools[1], attachmentTools[0]
}

require.Equal(t, azopenaiassistants.MessageAttachmentToolAssignment{
Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentType("code_interpreter")),
}, attachmentTools[0])

require.Equal(t, azopenaiassistants.MessageAttachmentToolAssignment{
Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentType("file_search")),
}, attachmentTools[1])
require.NotNil(t, attachmentTools[0].CodeInterpreterToolDefinition)
require.NotNil(t, attachmentTools[1].FileSearchToolDefinition)

messageID := messageResp.ID

Expand Down
16 changes: 0 additions & 16 deletions sdk/ai/azopenaiassistants/constants.go

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

20 changes: 2 additions & 18 deletions sdk/ai/azopenaiassistants/internal/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,8 @@ func (t *transformer) replaceDocs() error {
log.Printf("replaceDocs()")

err := transformFiles(t.fileCache, "replaceDocs", []string{"client.go"}, func(text string) (string, error) {
docString := `
// CreateVectorStoreFile - Create a vector store file by attaching a file to a vector store.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2024-07-01-preview
// - vectorStoreID - The ID of the vector store for which to create a File.
// - options - CreateVectorStoreFileOptions contains the optional parameters for the Client.CreateVectorStoreFile method.
`
newDocString := `
// CreateVectorStoreFile - Create a vector store file by attaching a file to a vector store.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2024-07-01-preview
// - vectorStoreID - The ID of the vector store for which to create a File.
// - body - Request object for creating a vector store file.
// - options - CreateVectorStoreFileOptions contains the optional parameters for the Client.CreateVectorStoreFile method.
`
text = strings.ReplaceAll(text, docString, newDocString)
docStringRE := regexp.MustCompile(`(?s)(- options - CreateVectorStoreFileOptions)`)
text = docStringRE.ReplaceAllString(text, " - body - Request object for creating a vector store file.\n"+`// $1`)
return text, nil
}, nil)
return err
Expand Down
17 changes: 10 additions & 7 deletions sdk/ai/azopenaiassistants/models.go

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

45 changes: 45 additions & 0 deletions sdk/ai/azopenaiassistants/models_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package azopenaiassistants

import (
"encoding/json"
"errors"
"fmt"
)

Expand Down Expand Up @@ -151,3 +152,47 @@ func unmarshalStringOrObject[T any](jsonBytes []byte) (string, *T, error) {

return "", model, nil
}

// MessageAttachmentToolDefinition allows you to specify tools for use with a message attachment.
type MessageAttachmentToolDefinition struct {
*CodeInterpreterToolDefinition
*FileSearchToolDefinition
}

// MarshalJSON implements the json.Marshaller interface for type MessageAttachmentToolDefinition.
func (m MessageAttachmentToolDefinition) MarshalJSON() ([]byte, error) {
if m.CodeInterpreterToolDefinition != nil && m.FileSearchToolDefinition != nil {
return nil, errors.New("only one tool definition should be set in MessageAttachmentToolDefinition")
}

switch {
case m.CodeInterpreterToolDefinition != nil:
return json.Marshal(m.CodeInterpreterToolDefinition)
case m.FileSearchToolDefinition != nil:
return json.Marshal(m.FileSearchToolDefinition)
default:
return nil, errors.New("no tool definition was set in MessageAttachmentToolDefinition")
}
}

// UnmarshalJSON implements the json.Marshaller interface for type MessageAttachmentToolDefinition.
func (m *MessageAttachmentToolDefinition) UnmarshalJSON(data []byte) error {
// There's only two types right now (CodeInterpreterToolDefinition and FileSearchToolDefinition)
// and CodeInterpreterToolDefinition is a subset of FileSearchToolDefinition
var toolDef *FileSearchToolDefinition

if err := json.Unmarshal(data, &toolDef); err != nil {
return err
}

switch *toolDef.Type {
case "code_interpreter":
m.CodeInterpreterToolDefinition = &CodeInterpreterToolDefinition{Type: toolDef.Type}
return nil
case "file_search":
m.FileSearchToolDefinition = toolDef
return nil
default:
return fmt.Errorf("unhandled tool definition type %s", *toolDef.Type)
}
}
39 changes: 12 additions & 27 deletions sdk/ai/azopenaiassistants/models_serde.go

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

2 changes: 1 addition & 1 deletion sdk/ai/azopenaiassistants/testdata/tsp-location.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#location: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/cacb3dc095486d8691c47dea944fc9ed0f4d0e32/specification/ai/OpenAI.Assistants/client.tsp
directory: specification/ai/OpenAI.Assistants
# https://github.com/Azure/azure-rest-api-specs/pull/29067
commit: eb46d197d57e1f71f1819f37779f387f20c344e9
commit: ea5bac870d87ff0424a4e4f5c448b0a66890838d
repo: Azure/azure-rest-api-specs
2 changes: 1 addition & 1 deletion sdk/ai/azopenaiassistants/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
package azopenaiassistants

const (
version = "v0.2.1"
version = "v0.3.0"
)

0 comments on commit 2ea046b

Please sign in to comment.