Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azopenaiassistants] First checkin for Azure OpenAI assistants #22369

Merged
merged 29 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
668c6a2
A package for OpenAI assistants.
Jan 24, 2024
1348d5b
let's try this
richardpark-msft Feb 10, 2024
56990d3
Fixing recordings.
Feb 10, 2024
2b0cb06
New recordings.
Feb 10, 2024
1fba95b
Bring back another test, start getting our CI elements in place.
Feb 10, 2024
cb28116
Updating conversation a bit.
Feb 10, 2024
cba3e81
Accidentally modified a test.
Feb 10, 2024
5b1e478
Making some updates to get the surface into usable shape:
Feb 16, 2024
aaf80bf
New test, new recording.
Feb 16, 2024
d1374c1
Normalize newlines for our tests.
Feb 16, 2024
2d61987
adding in required files
Feb 16, 2024
a6ea25e
- CONTRIBUTING.MD is personalized per package, so just fixing some st…
Feb 16, 2024
2628251
Temporarily use a link to something that does exist so I can get past…
Feb 16, 2024
3d85ea9
Fixing more links, centralizing into the bottom set of links.
Feb 16, 2024
7045a04
- Regenerated, which made the input parameter an io.ReadSeeker for up…
Feb 17, 2024
d1e0c7e
Docs
Feb 17, 2024
a981da6
Fix missing docs.
Feb 17, 2024
89b7bbc
Temporarily disable live testing.
Feb 20, 2024
7775edc
Bring it back!
Feb 20, 2024
d97469d
- Turn on live tests again now that I have the keyvault variables lin…
Feb 21, 2024
c1fcd18
- Accomodating a non-deterministic test. There is a recording that ca…
Feb 22, 2024
2984b42
Fixing test, the expected filename is different with the later versio…
Feb 27, 2024
c0a4ad7
Use the 'Unreleased' keyword instead.
Feb 27, 2024
75a7cf1
Disabling a test until we get all the perms worked out.
Feb 27, 2024
9bb3c84
Rerecord.
Feb 28, 2024
2edc936
Making `clientData` a field instead of an anonymous embed.
Mar 4, 2024
11cd906
Updating readme to have a better intro sentence.
Mar 4, 2024
4edc5dc
Add release date, hopefully release tomorrow provided there are no ne…
Mar 4, 2024
3cbb925
Updating to the merge commit on main (no change)
Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
A package for OpenAI assistants.
Richard Park authored Feb 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 668c6a23dac9c7be10007aa245cbb5be501e0574
5 changes: 5 additions & 0 deletions sdk/ai/azopenaiassistants/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 0.1.0 (2023-07-20)
richardpark-msft marked this conversation as resolved.
Show resolved Hide resolved

* Initial release of the `azopenaiassistants` library
99 changes: 99 additions & 0 deletions sdk/ai/azopenaiassistants/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Azure OpenAI client module for Go

NOTE: this client can be used with Azure OpenAI and OpenAI.

Azure OpenAI Service provides access to OpenAI's powerful language models including the GPT-4, GPT-35-Turbo, and Embeddings model series, as well as image generation using DALL-E.
jhendrixMSFT marked this conversation as resolved.
Show resolved Hide resolved

[Source code][azopenaiasst_repo] | [Package (pkg.go.dev)][azopenaiasst_pkg_go] | [REST API documentation][openai_rest_docs] | [Product documentation][openai_docs]

## Getting started

### Prerequisites

* Go, version 1.18 or higher - [Install Go](https://go.dev/doc/install)
* [Azure subscription][azure_sub]
* [Azure OpenAI access][azure_openai_access]

### Install the packages

Install the `azopenaiassistants` and `azidentity` modules with `go get`:

```bash
go get github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants

# optional
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
```

The [azidentity][azure_identity] module is used for Azure Active Directory authentication with Azure OpenAI.

### Authentication

#### Azure OpenAI

Azure OpenAI clients can authenticate using Azure Active Directory or with an API key:

* Using Azure Active Directory, with a TokenCredential: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants#example-NewClient)
* Using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants#example-NewClientWithKeyCredential)

#### OpenAI

OpenAI supports connecting using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants#example-NewClientForOpenAI)

## Key concepts

See [Key concepts][openai_key_concepts_assistants] in the product documentation for more details about general concepts.

# Examples

Examples for various scenarios can be found on [pkg.go.dev](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants#pkg-examples) or in the example*_test.go files in our GitHub repo for [azopenaiassistants](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/ai/azopenaiassistants).

## Troubleshooting

### Error Handling

All methods that send HTTP requests return `*azcore.ResponseError` when these requests fail. `ResponseError` has error details and the raw response from the service.

### Logging

This module uses the logging implementation in `azcore`. To turn on logging for all Azure SDK modules, set `AZURE_SDK_GO_LOGGING` to `all`. By default, the logger writes to stderr. Use the `azcore/log` package to control log output. For example, logging only HTTP request and response events, and printing them to stdout:

```go
import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"

// Print log events to stdout
azlog.SetListener(func(cls azlog.Event, msg string) {
fmt.Println(msg)
})

// Includes only requests and responses in credential logs
azlog.SetEvents(azlog.EventRequest, azlog.EventResponse)
```

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a [Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights to use your contribution.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate
the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to
do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information, see
the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or
comments.

<!-- LINKS -->
[azure_openai_access]: https://learn.microsoft.com/azure/cognitive-services/openai/overview#how-do-i-get-access-to-azure-openai
[azopenaiasst_repo]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/ai/azopenaiassistants
[azopenaiasst_pkg_go]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants
[azure_identity]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity
[azure_sub]: https://azure.microsoft.com/free/
[openai_docs]: https://learn.microsoft.com/azure/cognitive-services/openai
[openai_key_concepts]: https://learn.microsoft.com/azure/cognitive-services/openai/overview#key-concepts
[openai_key_concepts_assistants]: https://platform.openai.com/docs/assistants/overview
[openai_rest_docs]: https://learn.microsoft.com/azure/cognitive-services/openai/reference
[cla]: https://cla.microsoft.com
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:[email protected]
[azure_openai_quickstart]: https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
6 changes: 6 additions & 0 deletions sdk/ai/azopenaiassistants/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/ai/azopenaiassistants",
"Tag": "go/ai/azopenaiassistants_962be24011"
}
33 changes: 33 additions & 0 deletions sdk/ai/azopenaiassistants/autorest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Go

These settings apply only when `--go` is specified on the command line.

``` yaml
input-file:
# PR: https://github.com/Azure/azure-rest-api-specs/pull/27076/files
#- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/18c24352ad4a2e0959c0b4ec1404c3a250912f8b/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json
- ./testdata/generated/openapi.json
output-folder: ../azopenaiassistants
clear-output-folder: false
module: github.com/Azure/azure-sdk-for-go/sdk/ai/azopenaiassistants
license-header: MICROSOFT_MIT_NO_VERSION
openapi-type: data-plane
go: true
title: "OpenAIAssistants"
use: "@autorest/[email protected]"
richardpark-msft marked this conversation as resolved.
Show resolved Hide resolved
slice-elements-byval: true
# can't use this since it removes an innererror type that we want ()
# remove-non-reference-schema: true
```

## Transformations

Fix deployment and endpoint parameters so they show up in the right spots

``` yaml
directive:
# Add x-ms-parameter-location to parameters in x-ms-parameterized-host
- from: swagger-document
where: $["x-ms-parameterized-host"].parameters.0
transform: $["x-ms-parameter-location"] = "client";
```
14 changes: 14 additions & 0 deletions sdk/ai/azopenaiassistants/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//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 azopenaiassistants

// go:generate pwsh ./testdata/genopenapi.ps1
//go:generate autorest ./autorest.md
//go:generate goimports -w ./..
//go:generate go run ./internal/transform
//go:generate goimports -w ./..
//go:generate go mod tidy
Loading