Comments (11)
@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.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.
from azure-sdk-for-net.
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.
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.
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.
@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.
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.
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.
from azure-sdk-for-net.
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.
from azure-sdk-for-net.
Related Issues (20)
- [QUERY] Trigger a logic app workflow with a custom payload using logic app management client library HOT 1
- [Azure.Core] Use Base64Url encoding in TelemetryDetails once released
- [BUG] Azure.Monitor.Query update of sovereign cloud was breaking but not announced as breaking HOT 2
- [BUG] Azure.AI.OpenAI 1.0.0-beta.17 client.GetChatCompletionsStreamingAsync() not returning citations when used with AzureSearchChatExtensionConfiguration HOT 1
- [BUG] Test BearerTokenAuthenticationPolicy_TokenNotAlmostExpiredWithRefreshOnNow is failing randomly HOT 2
- Invalid ms.service metadata value HOT 4
- [Docs] Update context of EnableBatchedOperations
- Azure.Core: Add RequestContent.Create from IPerstistableModel<T>
- [FEATURE REQ] Add a GenerateUserDelegation...SasUri extension to storage clients. HOT 3
- When reposting a service bus message after a failure, the Diagnostic-Id field is not reset/clear. HOT 4
- [FEATURE REQ] Enhance MockableTrafficManagerArmClient Usability for Unit Testing by Adding Setters to TrafficManagerRegion Properties HOT 4
- [BUG] Misspelled hard-coded path to AGW WAF resource HOT 3
- [QUERY] how can I see http payload sent to azure ai search ? HOT 5
- [FEATURE REQ] Add constructor to allow using custom audience, appId for authenticating with Load Balancing through Azure API Management HOT 2
- [QUERY] ArmDeploymentResource.ValidateAsync doesn't return ArmDeploymentValidateResult but throws exception when "Preflight validation failed" HOT 5
- UpdateSubscriptionAsync method does not update AutoDeleteOnIdle properties HOT 7
- Facebook.com HOT 1
- Facebook.com HOT 1
- [FEATURE REQ] Support for federated identity credential + managed identity HOT 1
- [FEATURE REQ] Add AddAzureMonitorLogExporter extension method on LoggerProviderBuilder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-net.