-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[azopenai] Move azopenai from
cognitiveservices/azopenai
to `ai/azo…
…penai` (#21264) Part of the fix for #21260. - Moved the code (to preserve history) into `ai/azopenai` - Marked `cognitiveservices/azopenai`, prepping to release one last release to deprecate it. We still need to submit an issue to de-list `cognitiveservices/azopenai` but I believe this takes care of our end.
- Loading branch information
1 parent
a4e1833
commit 140a57a
Showing
51 changed files
with
6,913 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Release History | ||
|
||
## 0.1.1 (Unreleased) | ||
|
||
### Features Added | ||
|
||
### Breaking Changes | ||
|
||
### Bugs Fixed | ||
|
||
### Other Changes | ||
|
||
## 0.1.0 (2023-07-20) | ||
|
||
* Initial release of the `azopenai` library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# 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. | ||
|
||
[Source code][azopenai_repo] | [Package (pkg.go.dev)][azopenai_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 `azopenai` and `azidentity` modules with `go get`: | ||
|
||
```bash | ||
go get github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai | ||
|
||
# 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/azopenai#example-NewClient) | ||
* Using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai#example-NewClientWithKeyCredential) | ||
|
||
#### OpenAI | ||
|
||
OpenAI supports connecting using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai#example-NewClientForOpenAI) | ||
|
||
## Key concepts | ||
|
||
See [Key concepts][openai_key_concepts] 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/azopenai#pkg-examples) or in the example*_test.go files in our GitHub repo for [azopenai](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/cognitiveservices/azopenai). | ||
|
||
## 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 | ||
[azopenai_repo]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/cognitiveservices/azopenai | ||
[azopenai_pkg_go]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai | ||
[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_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"AssetsRepo": "Azure/azure-sdk-assets", | ||
"AssetsRepoPrefixPath": "go", | ||
"TagPrefix": "go/cognitiveservices/azopenai", | ||
"Tag": "go/cognitiveservices/azopenai_8fdad86997" | ||
} |
Oops, something went wrong.