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

Azure OpenAI API doesn't work when tools are being used with streamChatCompletions #28611

Closed
6 tasks
jmaczan opened this issue Feb 19, 2024 · 7 comments
Closed
6 tasks
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

@jmaczan
Copy link

jmaczan commented Feb 19, 2024

  • Package Name: @azure/openai
  • Package Version: ^1.0.0-beta.11
  • Operating system: Win 10
  • nodejs
    • version: v18.12.1
  • browser
    • name/version: Chrome 121
  • typescript
    • version: 8.19.2
  • Is the bug related to documentation in

Describe the bug

I try to use tools (a new version of function calling) together with streamChatCompletions() and I get either

{
    requestid: '4b00c2f0-0d49-4faf-9ef0-24bb8c5fd155',
    code: 400,
    message: 'Functions are not supported for this API version or this model version. To learn how to user use function calling with Azure OpenAI Service. Please refer to this wiki  https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling?tabs=python'
  }

or

  {
    requestid: '5746e80b-3523-44bf-a9db-4e1e7cacc8c9',
    code: 500,
    message: "'dict' object has no attribute 'lower'"
  }

To Reproduce
Steps to reproduce the behavior:

  1. Create a GPT-4 deployment in Azure OpenAI Studio with model version 1106-Preview
  2. Try to send a request using sdk
import {
    AzureKeyCredential,
    ChatRequestMessage,
    OpenAIClient,
} from "@azure/openai";


try {
    const client = new OpenAIClient(
        process.env.AOAIEndpoint, // fill with your value
        new AzureKeyCredential(process.env.AOAIKey), // fill with your value
        {
            apiVersion: "2023-12-01-preview", // you can try with other values as well
        }
    );

    const deploymentId = process.env.AOAIDeploymentId; // fill with your value

      let result = await client
          .streamChatCompletions(
              deploymentId,
              [{ role: "user", content: "Call my function", }] as ChatRequestMessage[],
              {
                    temperature: 0,
                    topP: 1,
                    maxTokens: 1000,
                    frequencyPenalty: 0,
                    presencePenalty: 0,
                    azureExtensionOptions: {
                        extensions: [
                            {
                                type: "AzureCognitiveSearch",
                                endpoint: process.env.SearchEndpoint,
                                key: process.env.SearchKey,
                                indexName: process.env.SearchIndex,
                                inScope: false,
                                strictness: 2,
                                topNDocuments: 8,
                                semanticConfiguration: "default",
                                queryType: "vectorSemanticHybrid",
                                fieldsMapping: {},
                                roleInformation: roleInformationPrompt,
                                filter: null,
                                embeddingKey: process.env.AOAIKey,
                                embeddingEndpoint: process.env.EmbeddingEndpoint
                                embeddingDependency: {
                                    type: "DeploymentName",
                                    deploymentName: process.env.EmbeddingDeploymentName
                                },
                            },
                        ],
                    },
                  tools: [
                      {
                          function: someFunction,
                          type: "function",
                      },
                  ],
              }
          )

Expected behavior
A clear and concise description of what you expected to happen.

Tool is called when needed

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 19, 2024
@jmaczan jmaczan changed the title I can't use tools with streamChatCompletions Azure OpenAI API doesn't work when tools are being used with streamChatCompletions Feb 20, 2024
@xirzec xirzec added Client This issue points to a problem in the data-plane of the library. OpenAI labels Feb 20, 2024
@github-actions github-actions bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Feb 20, 2024
@deyaaeldeen
Copy link
Member

Thanks for opening this report!

This seems to be a service issue so I'd recommend opening a support ticket in the Azure portal, so our support team can assist you better and resolve it as soon as possible. To open a support ticket, please refer to the guide here.

Also, I wonder, does the same issue manifest when getChatCompletions is being used? Also, does your deployment handle tool calls correctly if azure extensions are not being used?

Thank you for your patience and cooperation. Please let us know if you have any other questions.

@deyaaeldeen deyaaeldeen added the Service Attention This issue is responsible by Azure service team. label Feb 20, 2024
@github-actions github-actions bot added the needs-team-attention This issue needs attention from Azure service team or SDK team label Feb 20, 2024
@jmaczan
Copy link
Author

jmaczan commented Feb 21, 2024

Hello,

The issue persists for getChatCompletions as well

Removing azureExtensionOptions from API call resolves the issue for both getChatCompletions and streamChatCompletions!

@jmaczan
Copy link
Author

jmaczan commented Feb 21, 2024

Shall I still issue a ticket to Azure? Are you able to confirm that the issue is not on SDK's side?

Much thanks in advance!

@deyaaeldeen
Copy link
Member

@jmaczan Yes please, this is definitely a service issue, and @minhanh-phan was able to repro it.

@jmaczan
Copy link
Author

jmaczan commented Feb 22, 2024

Thanks Deyaaeldeen. I have registered an issue in Azure Portal and will let you know about the status when things move on

@jmaczan
Copy link
Author

jmaczan commented Mar 4, 2024

Hey, so after a joint investigation with Izabela from MS, we confirmed that it's an issue with services availability and the (undocumented) fact that some API versions doesn't play well with AI Search. I think we can close the ticket for now, unless you'd like to incorporate some code that aligns API typings with API version, so some parts of API are not available if user uses a particular API version string.

Let me know if I can help further

Thanks and have a great day!

@deyaaeldeen
Copy link
Member

Thanks a lot for sharing! In this case, let's close it then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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

3 participants