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

Datatypes for fields should match in NPM package vs. API reference. #29370

Open
lif2 opened this issue Apr 19, 2024 · 5 comments
Open

Datatypes for fields should match in NPM package vs. API reference. #29370

lif2 opened this issue Apr 19, 2024 · 5 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@lif2
Copy link

lif2 commented Apr 19, 2024

Is your feature request related to a problem? Please describe.
In my opinion @azure/openai package should follow the same datatypes definition that official AzureOpenAI API.
I've noticed that "created" field is a Date, while OpenAI and Azure OpenAI API references, have this field in "number" (int) format.
Example for created date in chat completions below.
Created date in this package -> https://learn.microsoft.com/en-us/javascript/api/@azure/openai/chatcompletions?view=azure-node-preview#@azure-openai-chatcompletions-created
Created date in Azure OpenAI Rest Api -> https://github.com/Azure/azure-rest-api-specs/blob/e6a20fec72ed3bcb4b43c559ee20b56ca2786ec0/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-02-01/inference.json#L2467

Describe the solution you'd like
Datatypes are the same. Example -> "created" field [date vs number].

Describe alternatives you've considered
If it's not possible, it will be nice to mention in package documentation, which fields are not the same datatype, so community will be careful about them.

Additional context
"created" field was 'number' few months back; but it was changed by this PR -> [OpenAI] Support Functions by deyaaeldeen · Pull Request #26782 · Azure/azure-sdk-for-js · GitHub

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. labels Apr 19, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @glharper.

@lif2
Copy link
Author

lif2 commented Apr 22, 2024

I've just found new package -> https://www.npmjs.com/package/@azure-rest/openai. First release was done ~2months ago.

Is it new package that should be used instead '@azure/openai', to be sure schema/models match 'official OpenAI' rest apis? I wasn't able to find [yet] any official statement on microsoft example pages for '@azure-rest/openai'?
Microsoft page just informs about '@azure/openai':
image

@minhanh-phan
Copy link
Contributor

Hi @lif2, thank you for raising the issue. To better assist you, would you mind giving us more context on your scenario uses created field as an integer? For reference, the @azure-rest/openai package has not been officially released yet and it is generated off of our pipeline build, so that's why there is no official document on this package yet. Please let us know if you have and additional questions.

@lif2
Copy link
Author

lif2 commented Apr 22, 2024

Hi @minhanh-phan!

'Created' field is in Azure OpenAI REST API documentations a number type field.

We are using this package to build JavaScript based app which also has some Rest API endpoints. By returning completions "as is" using your package, package is returning Date for this field (string in json). Some other apps that are integrating with our endpoints (endpoint returns completions based on @azure/openai), simply fails because these expect 'number' field for 'created' - because that's how Azure OpenAI REST API defines that field.

@minhanh-phan
Copy link
Contributor

Hi @lif2, @azure/openai SDK for JS is designed to provide the customer with a convenience layer and serve as a high level package. It is isomorphic to the Rest API but it doesn't necessarily correspond 1 to 1. For example, the SDK use camel casing convention while the Rest API uses snake case.

For your specific scenario, it'd be more beneficial to use the @azure/openai Rest API endpoint directly through importing from @azure/openai/rest. You can see an example of how to use them here. For instance, a request for Completions operation would be as follow:

import OpenAIClient from "@azure/openai/rest";

const client = OpenAIClient(endpoint, new AzureKeyCredential(azureApiKey));

const result = await client.path("/deployments/{deploymentId}/completions", deploymentId).post({
  body: { prompt, max_tokens: 128 },
});

console.log(JSON.stringify(result));

Please feel free to refer to the Azure OpenAI Rest API documentation here and let us know if you have any questions in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants