Giter Club home page Giter Club logo

Comments (11)

Freddeb avatar Freddeb commented on September 26, 2024 1

@rogerdaryl
Hi Roger, thank you to share this code sample.

I call the OpenAI library from a chatbot developed for Microsoft Teams (Microsoft Bot Framework 4).
The file is first uploaded (in the conversation prompt and saved on the user business OneDrive) then the bot application receives a converstation activity with the file information. I load the file from a http request in a MemoryStream.

I will adapt your code and use the function RestRequest.AddFile (3rd overload) that supports a stream as parameter.

Thank you.

from azure-sdk-for-net.

github-actions avatar github-actions commented on September 26, 2024

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

from azure-sdk-for-net.

rogerdaryl avatar rogerdaryl commented on September 26, 2024

I am getting the same, but I am using the library to connect to Azure OpenAI. Using Azure.AI.OpenAI.Assistants 1.0.0-beta.4
Response<OpenAIFile> uploadAssistantFileResponse = await _client.UploadFileAsync(tempFile, OpenAIFilePurpose.Assistants);

Azure.RequestFailedException: 'Additional properties are not allowed ('filename' was unexpected)
Status: 400 (Bad Request)
Content:
{
"error": {
"message": "Additional properties are not allowed ('filename' was unexpected)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

Headers:
Access-Control-Allow-Origin: REDACTED
x-ms-middleware-request-id: REDACTED
X-Content-Type-Options: REDACTED
X-Request-ID: REDACTED
apim-request-id: REDACTED
Strict-Transport-Security: REDACTED
x-ms-client-request-id: efc0e964-d49f-43b4-9a01-2f99a415fc3d
x-ms-region: REDACTED
Date: Mon, 13 May 2024 22:17:22 GMT
Content-Length: 178
Content-Type: application/json'

from azure-sdk-for-net.

georgegkonis avatar georgegkonis commented on September 26, 2024

I'm also having issues. It seems the Files API has been updated; no longer accepts a filepath but the actual file.

from azure-sdk-for-net.

Freddeb avatar Freddeb commented on September 26, 2024

I created a MemoryStream and I filled it up with the binary content of the PDF, i call the method UploadFile and this time i let the default parameter value (null) for the filename but It does not work neither.

from azure-sdk-for-net.

rogerdaryl avatar rogerdaryl commented on September 26, 2024

@Freddeb I have put together an alternate wrapper that you can use to upload files (using restsharp and the /openai/files endpoints)
https://github.com/ViceVersaLtd/viceversa.ai.openai.files

It got me around the bug, so thought I would share.

from azure-sdk-for-net.

JohnTranstel avatar JohnTranstel commented on September 26, 2024

Hi @Freddeb @rogerdaryl I am struggling with the same problem.
I now have my file as a stream and it is not accepted. I already have my file uploaded server side, and can easily convert it into byte[] or MemoryStream, but it is the 2 lines

var client = new AssistantsClient(apiKey);
var fileUploadresponse = await client.UploadFileAsync(stream, OpenAIFilePurpose.Assistants, null, token);

where I still have a problem.
(The fourth parameter is a new Cancellation token, it makes no difference). The error is that the file is not one of the list of possible file types.
Am I still to use UploadFileAsync or should I be using a different client.xxx function?

Any help appreciated
Thanks

from azure-sdk-for-net.

rogerdaryl avatar rogerdaryl commented on September 26, 2024

Hi @Freddeb @rogerdaryl I am struggling with the same problem. I now have my file as a stream and it is not accepted. I already have my file uploaded server side, and can easily convert it into byte[] or MemoryStream, but it is the 2 lines

var client = new AssistantsClient(apiKey); var fileUploadresponse = await client.UploadFileAsync(stream, OpenAIFilePurpose.Assistants, null, token);

where I still have a problem. (The fourth parameter is a new Cancellation token, it makes no difference). The error is that the file is not one of the list of possible file types. Am I still to use UploadFileAsync or should I be using a different client.xxx function?

Any help appreciated Thanks

Hi @JohnTranstel,

I wrote my own function to get around the bug.
Details are here.
https://github.com/ViceVersaLtd/viceversa.ai.openai.files

Let me know if you need more info than that.

from azure-sdk-for-net.

JohnTranstel avatar JohnTranstel commented on September 26, 2024

from azure-sdk-for-net.

rogerdaryl avatar rogerdaryl commented on September 26, 2024

Hi @JohnTranstel,

The "AzureKeys" variables in my code can be swapped for OpenAI values (the Endpoints are defined the same)

And yes, my ResVal is the same as fileUploadresponse.Value.Id. Which is all you need to associate it with the Assistant.

from azure-sdk-for-net.

JohnTranstel avatar JohnTranstel commented on September 26, 2024

from azure-sdk-for-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.