Skip to content

Commit 140a57a

Browse files
[azopenai] Move azopenai from cognitiveservices/azopenai to ai/azopenai (#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.
1 parent a4e1833 commit 140a57a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6913
-104
lines changed

sdk/ai/azopenai/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Release History
2+
3+
## 0.1.1 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
13+
## 0.1.0 (2023-07-20)
14+
15+
* Initial release of the `azopenai` library

sdk/ai/azopenai/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

sdk/ai/azopenai/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Azure OpenAI client module for Go
2+
3+
NOTE: this client can be used with Azure OpenAI and OpenAI.
4+
5+
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.
6+
7+
[Source code][azopenai_repo] | [Package (pkg.go.dev)][azopenai_pkg_go] | [REST API documentation][openai_rest_docs] | [Product documentation][openai_docs]
8+
9+
## Getting started
10+
11+
### Prerequisites
12+
13+
* Go, version 1.18 or higher - [Install Go](https://go.dev/doc/install)
14+
* [Azure subscription][azure_sub]
15+
* [Azure OpenAI access][azure_openai_access]
16+
17+
### Install the packages
18+
19+
Install the `azopenai` and `azidentity` modules with `go get`:
20+
21+
```bash
22+
go get github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai
23+
24+
# optional
25+
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
26+
```
27+
28+
The [azidentity][azure_identity] module is used for Azure Active Directory authentication with Azure OpenAI.
29+
30+
### Authentication
31+
32+
#### Azure OpenAI
33+
34+
Azure OpenAI clients can authenticate using Azure Active Directory or with an API key:
35+
36+
* Using Azure Active Directory, with a TokenCredential: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai#example-NewClient)
37+
* Using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai#example-NewClientWithKeyCredential)
38+
39+
#### OpenAI
40+
41+
OpenAI supports connecting using an API key: [example](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai#example-NewClientForOpenAI)
42+
43+
## Key concepts
44+
45+
See [Key concepts][openai_key_concepts] in the product documentation for more details about general concepts.
46+
47+
# Examples
48+
49+
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).
50+
51+
## Troubleshooting
52+
53+
### Error Handling
54+
55+
All methods that send HTTP requests return `*azcore.ResponseError` when these requests fail. `ResponseError` has error details and the raw response from the service.
56+
57+
### Logging
58+
59+
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:
60+
61+
```go
62+
import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
63+
64+
// Print log events to stdout
65+
azlog.SetListener(func(cls azlog.Event, msg string) {
66+
fmt.Println(msg)
67+
})
68+
69+
// Includes only requests and responses in credential logs
70+
azlog.SetEvents(azlog.EventRequest, azlog.EventResponse)
71+
```
72+
73+
## Contributing
74+
75+
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.
76+
77+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate
78+
the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to
79+
do this once across all repos using our CLA.
80+
81+
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information, see
82+
the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or
83+
comments.
84+
85+
<!-- LINKS -->
86+
[azure_openai_access]: https://learn.microsoft.com/azure/cognitive-services/openai/overview#how-do-i-get-access-to-azure-openai
87+
[azopenai_repo]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/cognitiveservices/azopenai
88+
[azopenai_pkg_go]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai
89+
[azure_identity]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity
90+
[azure_sub]: https://azure.microsoft.com/free/
91+
[openai_docs]: https://learn.microsoft.com/azure/cognitive-services/openai
92+
[openai_key_concepts]: https://learn.microsoft.com/azure/cognitive-services/openai/overview#key-concepts
93+
[openai_rest_docs]: https://learn.microsoft.com/azure/cognitive-services/openai/reference
94+
[cla]: https://cla.microsoft.com
95+
[coc]: https://opensource.microsoft.com/codeofconduct/
96+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
97+
[coc_contact]: mailto:[email protected]
98+
[azure_openai_quickstart]: https://learn.microsoft.com/azure/cognitive-services/openai/quickstart

sdk/ai/azopenai/assets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "go",
4+
"TagPrefix": "go/cognitiveservices/azopenai",
5+
"Tag": "go/cognitiveservices/azopenai_8fdad86997"
6+
}

0 commit comments

Comments
 (0)