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

chore: Update Azure OpenAI types #141

Merged
merged 17 commits into from
Sep 19, 2024
Merged

Conversation

deekshas8
Copy link
Contributor

@deekshas8 deekshas8 commented Sep 18, 2024

Context

AI/gen-ai-hub-sdk-js-backlog#109.

Manual adjustments I had to make:

  • remove x-ms-examples section
  • some multiline descriptions start |2-, this cases jsdoc description to have additional spaces in front which is not fixed by running lint:fix for some reason.

Generate types using Azure Open AI spec version 2024-06-01

Definition of Done

  • Code is tested (Unit, E2E)
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • (Optional) Aligned changes with the Java SDK
  • (Optional) Release notes updated

@deekshas8 deekshas8 marked this pull request as ready for review September 18, 2024 13:09
Copy link
Member

@MatKuhr MatKuhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the below problems, the type names are super long now and spread across so many files that it's hard to navigate them.

On the plus side, users seem to have more fields accessible to them now.

Maybe if we delete some of the weird looking things, or at least not export them publicly, this might be good enough?

* A specific representation of configurable options for Azure Cosmos DB when using it as an Azure OpenAI chat
* extension.
*/
export type AzureOpenAiAzureCosmosDBChatExtensionConfiguration =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should delete files that are not relevant for our client, like these cosmos-db files are. I am marking more files below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the relevant chat completion types are currently exported from the package.

I am honestly not sure about deleting them manually, the next time we update the spec we have the same problem. We dont delete unused types in Orchestration as well.
@marikaner what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea would be to add a && rm ... to the script, or exclude it from the export. For orchestration we probably need to do the same, as we otherwise publish unreleased and non-functional API.

Copy link
Contributor Author

@deekshas8 deekshas8 Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we exclude the export of unused types from both the packages (see index.ts). So even though we publish everything, users will not be able to access these types using @sap-ai-sdk/foundation-models.

I did this manually for now, maybe having a script would be a better (which either deletes the files or adds exports to index.ts).

*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import type { AzureOpenAiOnYourDataAuthenticationOptions } from './on-your-data-authentication-options.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this and all other on-your-data

/**
* Translation or transcription response when response_format was json.
*/
export type AzureOpenAiAudioResponse = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used by transcriptions which we currently don't offer API for, thus effectively unused at the moment

/**
* Representation of the 'AzureOpenAiChatCompletionRequestMessage' schema.
*/
export type AzureOpenAiChatCompletionRequestMessage = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is incorrect, it should include the mandatory field content. @marikaner figured this is due to the discriminator in the spec, which doesn't work in our generator, and is investigating if it can be fixed on a short notice..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the same issue applies for AzureOpenAiChatCompletionRequestMessageContentPart

* A specific representation of configurable options for Azure Search when using it as an Azure OpenAI chat
* extension.
*/
export type AzureOpenAiAzureSearchChatExtensionConfiguration =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused AFAI can see..

Copy link
Contributor

@jjtang1985 jjtang1985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine to merge this first.

  • When feat: Add support for discriminator cloud-sdk-js#5012 comes in, we can do another iteration, but this PR already improved the current status.
  • For unused types, I dont mind, if we keep them, as they are not public APIs anyways. We can also create a follow up for a more sophisticated way to delete, instead of manual jobs.

Copy link
Contributor

@ZhongpinWang ZhongpinWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


allExportedTypes.forEach(exportedType => {
if (
!allExportedIndex.find(nameInIndex => exportedType.name === nameInIndex)
) {
if (exportedType.path.split(sep).join(posix.sep).match(schemaPathRegex)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marikaner @shibeshduw I adjusted the check public api script here to not complaint if I have a type specifically in ./schema that is not exported from index.ts. Logs a warning for those cases. We can remove it once we fix our generation or del unwanted types. Just FYI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deekshas8 deekshas8 merged commit 54ba205 into main Sep 19, 2024
10 checks passed
@deekshas8 deekshas8 deleted the generate-azure-openai-types branch September 19, 2024 13:19
@jjtang1985
Copy link
Contributor

Please correct me: @deekshas8
The types are regenerated by using the cloud sdk PR: SAP/cloud-sdk-js#5012

@deekshas8
Copy link
Contributor Author

@jjtang1985 Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants