Skip to content

Commit 2ea046b

Browse files
glecarosriparkrichardpark-msftazure-sdkdanieljurek
authored
[azopenaiassistants] Updates for 2024-10-01-preview (Azure#23730)
* hash+gen * Adding in MessageAttachmentToolDefinition * Accidental copy/paste * Updating doc comment for MessageAttachmentToolDefinition * Update docindex.yml to use Python 3.11 (Azure#23719) Co-authored-by: Daniel Jurek <[email protected]> * Refresh OIDC token in azadmin test resources scripts (Azure#23722) * remove pkg.go.dev link in readme (Azure#23708) * remove pkg.go.dev link in readme * fix changelog * upgrade typesspec-go (Azure#23720) * [azopenai] Inference changes for 2024-10-01-preview (Azure#23672) * update for 1.2.0 release (Azure#23728) * Sync eng/common directory with azure-sdk-tools for PR 9328 (Azure#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 (Azure#23735) * Added permissions & resourcetype parameters in listblob response (Azure#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 (Azure#23742) * Prep for stg 95 GA release * Update CHANGELOG.md format for changelog * Add SparseCheckoutPaths to archetype-typespec-emitter.yml (Azure#23740) Co-authored-by: Wei Hu <[email protected]> * [azopenai] Update azopenai changelog. (Azure#23732) * Fix missing stress matrix display name filter (Azure#23726) Co-authored-by: Ben Broderick Phillips <[email protected]> * update date (Azure#23746) * [azopenai] non-existing deployments fail in a different way now. (Azure#23747) * Increment package version after release of ai/azopenai (Azure#23750) * [Release] sdk/resourcemanager/hybridcompute/armhybridcompute/2.1.0-beta.1 generation from spec commit: 63d530d0def1c624f5d42d39170ff4ac196522e2 (Azure#23753) * Increment package version after release of security/keyvault/azadmin (Azure#23749) * Update azopenai* to use hardcoded variable group config (Azure#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 (Azure#23757) * Add helpers to log a GitHub "notice" (Azure#23764) Co-authored-by: Mike Harder <[email protected]> * Increment package version after release of storage/azdatalake (Azure#23745) * Increment package version after release of storage/azblob (Azure#23744) * Increment package version after release of storage/azfile (Azure#23743) * batching adjustments for create-prjobmatrix (Azure#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]>
1 parent 590fc96 commit 2ea046b

File tree

11 files changed

+142
-121
lines changed

11 files changed

+142
-121
lines changed

sdk/ai/azopenaiassistants/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 0.3.0 (2024-12-03)
4+
5+
### Features Added
6+
7+
- Added support for the `ParallelToolCalls` option.
8+
9+
### Breaking Changes
10+
11+
- `MessageAttachmentToolAssignment` is now `MessageAttachmentToolDefinition`.
12+
313
## 0.2.1 (2024-09-10)
414

515
### Features Added
@@ -23,7 +33,6 @@
2333
### Bugs Fixed
2434

2535
- ThreadRun.RequiredAction was deserialized incorrectly, making it impossible to actually resubmit a tool output. (PR#22834)
26-
2736
## 0.1.0 (2024-03-05)
2837

2938
* Initial release of the `azopenaiassistants` library

sdk/ai/azopenaiassistants/autorest.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ directive:
155155
return $;
156156
```
157157

158+
MessageAttachmentToolDefinition
159+
160+
```yaml
161+
directive:
162+
- from: swagger-document
163+
where: $.definitions
164+
transform: |
165+
// create the dummy type that I can use to point to my manually created union
166+
$.MessageAttachmentToolDefinition = {
167+
"x-ms-external": true,
168+
"type": "object",
169+
"properties": { "ignored": { "type": "string" } },
170+
"x-ms-client-name": "MessageAttachmentToolDefinition"
171+
};
172+
```
173+
158174
## Model -> DeploymentName
159175

160176
```yaml

sdk/ai/azopenaiassistants/client.go

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/azopenaiassistants/client_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ func TestAssistantMessages(t *testing.T) {
157157
Attachments: []azopenaiassistants.MessageAttachment{
158158
{
159159
FileID: uploadResp.ID,
160-
Tools: []azopenaiassistants.MessageAttachmentToolAssignment{
161-
{Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentTypeCodeInterpreter)},
162-
{Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentTypeFileSearch)},
160+
Tools: []azopenaiassistants.MessageAttachmentToolDefinition{
161+
{CodeInterpreterToolDefinition: &azopenaiassistants.CodeInterpreterToolDefinition{}},
162+
{FileSearchToolDefinition: &azopenaiassistants.FileSearchToolDefinition{}},
163163
},
164164
},
165165
},
@@ -169,17 +169,12 @@ func TestAssistantMessages(t *testing.T) {
169169
attachmentTools := messageResp.Attachments[0].Tools
170170

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

176-
require.Equal(t, azopenaiassistants.MessageAttachmentToolAssignment{
177-
Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentType("code_interpreter")),
178-
}, attachmentTools[0])
179-
180-
require.Equal(t, azopenaiassistants.MessageAttachmentToolAssignment{
181-
Type: to.Ptr(azopenaiassistants.MessageAttachmentToolAssignmentType("file_search")),
182-
}, attachmentTools[1])
176+
require.NotNil(t, attachmentTools[0].CodeInterpreterToolDefinition)
177+
require.NotNil(t, attachmentTools[1].FileSearchToolDefinition)
183178

184179
messageID := messageResp.ID
185180

sdk/ai/azopenaiassistants/constants.go

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/azopenaiassistants/internal/transform/transform.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,8 @@ func (t *transformer) replaceDocs() error {
266266
log.Printf("replaceDocs()")
267267

268268
err := transformFiles(t.fileCache, "replaceDocs", []string{"client.go"}, func(text string) (string, error) {
269-
docString := `
270-
// CreateVectorStoreFile - Create a vector store file by attaching a file to a vector store.
271-
// If the operation fails it returns an *azcore.ResponseError type.
272-
//
273-
// Generated from API version 2024-07-01-preview
274-
// - vectorStoreID - The ID of the vector store for which to create a File.
275-
// - options - CreateVectorStoreFileOptions contains the optional parameters for the Client.CreateVectorStoreFile method.
276-
`
277-
newDocString := `
278-
// CreateVectorStoreFile - Create a vector store file by attaching a file to a vector store.
279-
// If the operation fails it returns an *azcore.ResponseError type.
280-
//
281-
// Generated from API version 2024-07-01-preview
282-
// - vectorStoreID - The ID of the vector store for which to create a File.
283-
// - body - Request object for creating a vector store file.
284-
// - options - CreateVectorStoreFileOptions contains the optional parameters for the Client.CreateVectorStoreFile method.
285-
`
286-
text = strings.ReplaceAll(text, docString, newDocString)
269+
docStringRE := regexp.MustCompile(`(?s)(- options - CreateVectorStoreFileOptions)`)
270+
text = docStringRE.ReplaceAllString(text, " - body - Request object for creating a vector store file.\n"+`// $1`)
287271
return text, nil
288272
}, nil)
289273
return err

sdk/ai/azopenaiassistants/models.go

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/azopenaiassistants/models_custom.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package azopenaiassistants
55

66
import (
77
"encoding/json"
8+
"errors"
89
"fmt"
910
)
1011

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

152153
return "", model, nil
153154
}
155+
156+
// MessageAttachmentToolDefinition allows you to specify tools for use with a message attachment.
157+
type MessageAttachmentToolDefinition struct {
158+
*CodeInterpreterToolDefinition
159+
*FileSearchToolDefinition
160+
}
161+
162+
// MarshalJSON implements the json.Marshaller interface for type MessageAttachmentToolDefinition.
163+
func (m MessageAttachmentToolDefinition) MarshalJSON() ([]byte, error) {
164+
if m.CodeInterpreterToolDefinition != nil && m.FileSearchToolDefinition != nil {
165+
return nil, errors.New("only one tool definition should be set in MessageAttachmentToolDefinition")
166+
}
167+
168+
switch {
169+
case m.CodeInterpreterToolDefinition != nil:
170+
return json.Marshal(m.CodeInterpreterToolDefinition)
171+
case m.FileSearchToolDefinition != nil:
172+
return json.Marshal(m.FileSearchToolDefinition)
173+
default:
174+
return nil, errors.New("no tool definition was set in MessageAttachmentToolDefinition")
175+
}
176+
}
177+
178+
// UnmarshalJSON implements the json.Marshaller interface for type MessageAttachmentToolDefinition.
179+
func (m *MessageAttachmentToolDefinition) UnmarshalJSON(data []byte) error {
180+
// There's only two types right now (CodeInterpreterToolDefinition and FileSearchToolDefinition)
181+
// and CodeInterpreterToolDefinition is a subset of FileSearchToolDefinition
182+
var toolDef *FileSearchToolDefinition
183+
184+
if err := json.Unmarshal(data, &toolDef); err != nil {
185+
return err
186+
}
187+
188+
switch *toolDef.Type {
189+
case "code_interpreter":
190+
m.CodeInterpreterToolDefinition = &CodeInterpreterToolDefinition{Type: toolDef.Type}
191+
return nil
192+
case "file_search":
193+
m.FileSearchToolDefinition = toolDef
194+
return nil
195+
default:
196+
return fmt.Errorf("unhandled tool definition type %s", *toolDef.Type)
197+
}
198+
}

sdk/ai/azopenaiassistants/models_serde.go

Lines changed: 12 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#location: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/cacb3dc095486d8691c47dea944fc9ed0f4d0e32/specification/ai/OpenAI.Assistants/client.tsp
22
directory: specification/ai/OpenAI.Assistants
33
# https://github.com/Azure/azure-rest-api-specs/pull/29067
4-
commit: eb46d197d57e1f71f1819f37779f387f20c344e9
4+
commit: ea5bac870d87ff0424a4e4f5c448b0a66890838d
55
repo: Azure/azure-rest-api-specs

0 commit comments

Comments
 (0)