azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG] Java OpenAI EmbeddingsOptions requires setUser be called with non-null value

Open mattgotteiner opened this issue 1 year ago • 3 comments

Describe the bug The Java OpenAI Sample would not work https://github.com/Azure/azure-sdk-for-java/blob/azure-ai-openai_1.0.0-beta.6/sdk/openai/azure-ai-openai/src/samples/java/com/azure/ai/openai/usage/GetEmbeddingsSample.java

Exception or Stack Trace An exception occurred while executing the Java class. Status code 400, "{ [ERROR] "error": { [ERROR] "message": "None is not of type 'string' - 'user'", [ERROR] "type": "invalid_request_error", [ERROR] "param": null, [ERROR] "code": null [ERROR] } [ERROR] }

To Reproduce Run the sample as is. To fix add .setUser("some-string") when creating EmbeddingsOptions

Code Snippet

EmbeddingsOptions embeddingsOptions = new EmbeddingsOptions(Arrays.asList("Your text string goes here"));

Embeddings embeddings = client.getEmbeddings(deploymentOrModelId, embeddingsOptions);

for (EmbeddingItem item : embeddings.getData()) {
    System.out.printf("Index: %d.%n", item.getPromptIndex());
    for (Double embedding : item.getEmbedding()) {
        System.out.printf("%f;", embedding);
    }
}

Expected behavior Should be able to use without calling .setUser

mattgotteiner avatar Feb 27 '24 20:02 mattgotteiner

Thanks for filing this @mattgotteiner.

@mssfang could you fix this sample.

alzimmermsft avatar Feb 28 '24 15:02 alzimmermsft

Hi, @mattgotteiner
What model are you using? I won't be able to reproduce the error with model "text-embedding-ada-002" in both of Azure OpenAI and OpenAI clients

mssfang avatar Feb 28 '24 22:02 mssfang

Hi @mattgotteiner. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Feb 28 '24 22:02 github-actions[bot]

Hi @mattgotteiner, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

github-actions[bot] avatar Mar 07 '24 03:03 github-actions[bot]