Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
721a035
Early code generation from topic branch for whisper
jpalvarezl Aug 31, 2023
bce544c
Added simplest test
jpalvarezl Aug 31, 2023
98b0587
Regened with correct paths
jpalvarezl Aug 31, 2023
3e7c30f
Fixed name of method in the test
jpalvarezl Aug 31, 2023
35384fb
Added test file for translations
jpalvarezl Aug 31, 2023
8c0087e
[OpenAI] BYO Multipart form request support (#36621)
jpalvarezl Sep 7, 2023
bfd2bd8
Code regen and adjustments to new methods
jpalvarezl Sep 7, 2023
bd7f7b8
Using latest commit
jpalvarezl Sep 7, 2023
9f141ec
plain text works
jpalvarezl Sep 7, 2023
6a09621
Code gen works
jpalvarezl Sep 7, 2023
042a688
Code regen with looser types, no hooks for content-type nor length
jpalvarezl Sep 11, 2023
372fbc9
Migrated multiform implementation over from the strongly typed branch
jpalvarezl Sep 12, 2023
430ce3e
Added headers
jpalvarezl Sep 12, 2023
f86b515
Added classes
jpalvarezl Sep 12, 2023
5246435
reran code gen
jpalvarezl Sep 13, 2023
05d703e
Compiles with modded tsp defintion, including content-type
jpalvarezl Sep 13, 2023
b338c6e
Corrected wrong value passed for content-length
jpalvarezl Sep 13, 2023
b4fce21
It works!
jpalvarezl Sep 13, 2023
dd075cd
Removed pattern instanceof for older compatibility version
jpalvarezl Sep 13, 2023
cc9736c
Refactored the MultipartHelper to be testable
jpalvarezl Sep 13, 2023
d5be9d4
Added test definition for MultipartDataHelper class
jpalvarezl Sep 13, 2023
f19d690
Added happy path test and model to the list to be serialized
jpalvarezl Sep 13, 2023
b21db2b
Added tests for the MultipartDataHelper class
jpalvarezl Sep 13, 2023
d78ebb3
Refactored audio translation tests to use testRunners
jpalvarezl Sep 13, 2023
1b0b188
Added tests for miused formats
jpalvarezl Sep 13, 2023
e5b3612
Added more negative tests for wrong formats
jpalvarezl Sep 13, 2023
1417214
Renamed tests
jpalvarezl Sep 13, 2023
6ba8260
Finished Azure OAI sync test suite
jpalvarezl Sep 14, 2023
c9c4a51
Added support for nonAzure translations
jpalvarezl Sep 14, 2023
2860ce9
Added Async translation methods
jpalvarezl Sep 14, 2023
d1a7aea
Added tests and async functionality for translations
jpalvarezl Sep 14, 2023
262cdde
Async translation tests for non-Azure
jpalvarezl Sep 14, 2023
8d6bfc6
Extracted audioTranscription assertion statements to method
jpalvarezl Sep 14, 2023
9b842de
Added sync transcription functionality and AOAI tests
jpalvarezl Sep 14, 2023
5f49b14
Added license to source files
jpalvarezl Sep 14, 2023
a5ad09a
Added todo markers where docs are missing
jpalvarezl Sep 14, 2023
15ddabd
Added async implementation and minimal testing for transcription
jpalvarezl Sep 14, 2023
f299a3a
Added tests for nonAzure OAI
jpalvarezl Sep 14, 2023
1f7161b
Code regen
jpalvarezl Sep 15, 2023
1974d1e
Corrected content type for bodyParam nonAzure
jpalvarezl Sep 15, 2023
846cd6c
Added remaing transcription tests for AOAI sync case
jpalvarezl Sep 15, 2023
4d8eea3
Added tests for async AOAI
jpalvarezl Sep 15, 2023
a6af7ea
Added transcription tests for nonAzure OAI sync API
jpalvarezl Sep 15, 2023
fac7601
Added tests for nonAzure OAI async API
jpalvarezl Sep 15, 2023
5e39c7d
Commited whisper session-record changes
jpalvarezl Sep 15, 2023
70bbc20
Inlined methods
jpalvarezl Sep 15, 2023
5b75b7e
Added documentation to sync/async client for translation and transcri…
jpalvarezl Sep 15, 2023
88406cd
Added documentation to multipart helper classes
jpalvarezl Sep 15, 2023
fbbaea7
Replaced start imports with single class imports
jpalvarezl Sep 15, 2023
38078fb
Simplified tests and added logger to async client
jpalvarezl Sep 18, 2023
2bc1976
Added missing asset
jpalvarezl Sep 18, 2023
1c48b63
Added recordings for nonAzure tests
jpalvarezl Sep 18, 2023
4383d7a
Style checks
jpalvarezl Sep 18, 2023
3578e4c
Style check
jpalvarezl Sep 18, 2023
76f640e
Style check
jpalvarezl Sep 18, 2023
691080d
Style check done
jpalvarezl Sep 18, 2023
398b702
Changelog update and static bug analysis issues addressed
jpalvarezl Sep 18, 2023
ae71931
Last 2 replacement of monoError
jpalvarezl Sep 18, 2023
47e345b
[OpenAI] Added sample and updated READMEs (#36806)
mssfang Sep 18, 2023
6306060
suppression spotbugs for allowing external mutation on the bytep[ (#3…
mssfang Sep 18, 2023
9b6fdd1
Merge branch 'main' into jpalvarezl/whisper_support_looser_types
mssfang Sep 18, 2023
40dcaff
fixed unknown cspell error, 'mpga'
mssfang Sep 19, 2023
4af1ba5
fixed sample broken links
mssfang Sep 19, 2023
65e4ee4
regenerated, no changes but only indents alignment
mssfang Sep 19, 2023
c1fb921
Hardcoded boundary value for multipart requests
jpalvarezl Sep 19, 2023
a5f32d9
Updated test records for nonAzure
jpalvarezl Sep 19, 2023
bcb6fae
Most test passing with latest service version
jpalvarezl Sep 19, 2023
04a3201
Rolled back test records for regressed tests
jpalvarezl Sep 19, 2023
8773677
Removed unused import
jpalvarezl Sep 19, 2023
6bafc2e
Re-ordered method parameters. Options bag is last
jpalvarezl Sep 19, 2023
8f4e36a
Readme update
jpalvarezl Sep 19, 2023
5a9b295
[OpenAI] Improve JavaDoc and compatible with JDK 21 (#36846)
mssfang Sep 19, 2023
8b6fca8
removed export implementaion/model
mssfang Sep 19, 2023
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
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
"Mockito",
"Mordor",
"mosca",
"mpga",
"msal",
"msix",
"MSRC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2697,4 +2697,18 @@
<Method name="transfer"/>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
</Match>

<!-- Returning a new copy of the object is not necessary -->
<Match>
<Class name="~com\.azure\.ai\.openai\.models\.(AudioTranscriptionOptions|AudioTranslationOptions)"/>
<Method name="&lt;init&gt;"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>

<!-- False positive, it throws an IllegalArgumentException if non-exist method parameter type passed.-->
<Match>
<Class name="com.azure.ai.openai.implementation.MultipartDataHelper"/>
<Method name="serializeRequest"/>
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
</Match>
</FindBugsFilter>
4 changes: 4 additions & 0 deletions sdk/openai/azure-ai-openai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Features Added

- Support for `Whisper` endpoints was added.
- Translation and Transcription of audio files is available
- The above features are available both in Azure and non-Azure OpenAI

### Breaking Changes

### Bugs Fixed
Expand Down
45 changes: 45 additions & 0 deletions sdk/openai/azure-ai-openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ For concrete examples you can have a look at the following links. Some of the mo
* [Streaming chat completions sample](#streaming-chat-completions "Streaming chat completions")
* [Embeddings sample](#text-embeddings "Text Embeddings")
* [Image Generation sample](#image-generation "Image Generation")
* [Audio Transcription sample](#audio-transcription "Audio Transcription")
* [Audio Translation sample](#audio-translation "Audio Translation")

If you want to see the full code for these snippets check out our [samples folder][samples_folder].

Expand Down Expand Up @@ -150,6 +152,8 @@ The following sections provide several code snippets covering some of the most c
* [Streaming chat completions sample](#streaming-chat-completions "Streaming chat completions")
* [Embeddings sample](#text-embeddings "Text Embeddings")
* [Image Generation sample](#image-generation "Image Generation")
* [Audio Transcription sample](#audio-transcription "Audio Transcription")
* [Audio Translation sample](#audio-translation "Audio Translation")

### Text completions

Expand Down Expand Up @@ -286,6 +290,44 @@ for (ImageLocation imageLocation : images.getData()) {

For a complete sample example, see sample [Image Generation][sample_image_generation].

### Audio Transcription
The OpenAI service starts supporting `audio transcription` with the introduction of `Whisper` models.
The following code snippet shows how to use the service to transcribe audio.

```java readme-sample-audioTranscription
String fileName = "{your-file-name}";
Path filePath = Paths.get("{your-file-path}" + fileName);

byte[] file = BinaryData.fromFile(filePath).toBytes();
AudioTranscriptionOptions transcriptionOptions = new AudioTranscriptionOptions(file)
.setResponseFormat(AudioTranscriptionFormat.JSON);

AudioTranscription transcription = client.getAudioTranscription("{deploymentOrModelId}", fileName, transcriptionOptions);

System.out.println("Transcription: " + transcription.getText());
```
For a complete sample example, see sample [Audio Transcription][sample_audio_transcription].
Please refer to the service documentation for a conceptual discussion of [Whisper][microsoft_docs_whisper_model].

### Audio Translation
The OpenAI service starts supporting `audio translation` with the introduction of `Whisper` models.
The following code snippet shows how to use the service to translate audio.

```java readme-sample-audioTranslation
String fileName = "{your-file-name}";
Path filePath = Paths.get("{your-file-path}" + fileName);

byte[] file = BinaryData.fromFile(filePath).toBytes();
AudioTranslationOptions translationOptions = new AudioTranslationOptions(file)
.setResponseFormat(AudioTranscriptionFormat.JSON);

AudioTranscription translation = client.getAudioTranslation("{deploymentOrModelId}", fileName, translationOptions);

System.out.println("Translation: " + translation.getText());
```
For a complete sample example, see sample [Audio Translation][sample_audio_translation].
Please refer to the service documentation for a conceptual discussion of [Whisper][microsoft_docs_whisper_model].

## Troubleshooting
### Enable client logging
You can set the `AZURE_LOG_LEVEL` environment variable to view logging statements made in the client library. For
Expand Down Expand Up @@ -327,6 +369,7 @@ For details on contributing to this repository, see the [contributing guide](htt
[logLevels]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
[microsoft_docs_openai_completion]: https://learn.microsoft.com/azure/cognitive-services/openai/how-to/completions
[microsoft_docs_openai_embedding]: https://learn.microsoft.com/azure/cognitive-services/openai/concepts/understand-embeddings
[microsoft_docs_whisper_model]: https://learn.microsoft.com/azure/ai-services/openai/whisper-quickstart?tabs=command-line
[non_azure_openai_authentication]: https://platform.openai.com/docs/api-reference/authentication
[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning
[product_documentation]: https://azure.microsoft.com/services/
Expand All @@ -342,6 +385,8 @@ For details on contributing to this repository, see the [contributing guide](htt
[sample_get_completions_streaming]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/GetCompletionsStreamSample.java
[sample_get_embedding]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/GetEmbeddingsSample.java
[sample_image_generation]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/GetImagesSample.java
[sample_audio_transcription]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/AudioTranscriptionSample.java
[sample_audio_translation]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/AudioTranslationSample.java
[openai_client_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java
[openai_client_builder]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClientBuilder.java
[openai_client_sync]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/azure-ai-openai/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/openai/azure-ai-openai",
"Tag": "java/openai/azure-ai-openai_57107e7a09"
"Tag": "java/openai/azure-ai-openai_3c34d9f076"
}
Loading