Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.07k stars 1.19k forks source link

[@azure/openai-assistants] Incorrect Property Names in Type Definitions #29205

Closed nume-kudi closed 3 months ago

nume-kudi commented 6 months ago

Describe the bug Within the MessageImageFileDetails interface, the property named fileId does not match the expected API property file_id.

Similarly, in the RunStepMessageCreationReference interface, the property named messageId is inaccurately named. According to the expected API property, it should be message_id.

To Reproduce Steps to reproduce the behavior:

  1. Retrieve an object with AssistantsClient.

Expected behavior Should be able to correctly access file_id or message_id.

Additional context The AssistantsClient is using API version 2024-03-01-preview

glharper commented 6 months ago

@nnkkd Thank you for using the Azure OpenAI Assistants SDK, and for writing this issue up. For the JS Azure SDK, our standard naming policy for properties like fileId and messageId is camel case, as opposed to the snake case used in the official OpenAI Node library. We opted for consistency within the JS Azure SDK instead of consistency with that external API. Does that make sense?

nume-kudi commented 6 months ago

@glharper I understand the importance of maintaining consistency in naming conventions. However, the issue arises from the fact that some property names do not maintain this consistency internally. As a result, following the SDK's type definitions leads to always retrieving undefined, and users cannot realize the mismatch in types until they perform console outputs.

For instance, the actual RunStep object is as follows:

{
  id: 'step_2PbBOaWx3bXKseIxYGRVR3QJ',
  object: 'thread.run.step',
  type: 'message_creation',
  status: 'completed',
  usage: { promptTokens: 498, completionTokens: 27, totalTokens: 525 },
  runId: 'run_kGMxicgga9htGBxhHLAj2oDc',
  assistantId: 'asst_jZzGZiRcBsMntpHQBEkOIXNi',
  threadId: 'thread_r1bRylSX3TYoUzN85CS4jbbM',
  expiresAt: null,
  stepDetails: {
    type: 'message_creation',
    messageCreation: { message_id: 'msg_72rPSkVULBzwU3VKK6nvu9ex' },
    toolCalls: []
  },
  lastError: null,
  createdAt: 2024-04-09T23:39:06.000Z,
  expiredAt: Invalid Date,
  completedAt: 2024-04-09T23:39:08.000Z,
  cancelledAt: null,
  failedAt: null
}
deyaaeldeen commented 3 months ago

Hi @nume-kudi, we strongly recommend that you migrate to use the AzureOpenAI client exported by the official OpenAI client library for JavaScript. Checkout the migration guide for how to do so while maintaining typing for Azure features.

Please let us know if you have any other questions!