JZO001 / Forge.OpenAI

OpenAI API client library for .NET. I was developed it for for public use and it is free.
MIT License
37 stars 14 forks source link

ThreadsService and others missing OpenAI-Beta=assistants=v1 http header #10

Closed sevzas closed 7 months ago

sevzas commented 7 months ago

This line appears in AssistantService:

_apiHttpService.DefaultRequestHeaders.Add("OpenAI-Beta", "assistants=v1");

based on the curl examples on the OpenAi web site, such as https://platform.openai.com/docs/api-reference/threads it appears that the following services also need this line: ThreadsService, MessageService, RunService and RunStepService.

I suspect that this missing line is the cause of me seeing this error message while trying to call RunSvc.CreateThreadAndRunAsync(runRequest).Result

{ "error": { "type": "invalid_request_error", "code": "unknown_url", "message": "Unknown request URL: POST /threads/runs. Please check the URL for typos, or see the docs at https://platform.openai.com/docs/api-reference/.", "param": null } }

JZO001 commented 7 months ago

Interesting, the playground examples worked without that. I will check in the evening what was changed on OpenAI side.

JZO001 commented 7 months ago

I need a bit more time to solve this issue

sevzas commented 7 months ago

Thanks for the update... Looking forward to a resolution.

JZO001 commented 7 months ago

Fixed in v1.3.3. Thanks sevzas!

sevzas commented 7 months ago

I tried v1.3.3 and I get a new error on code that used to work. I'm using .Net Framework 4.8 without dependency injection.

When I call

OpenAIService.CreateService(opts)

I get:

System.InvalidOperationException: 'No constructor for type 'Forge.OpenAI.Services.Endpoints.OpenAIProviderEndpointService' can be instantiated using services from the service container and default values.'

JZO001 commented 7 months ago

Thanks for the feedback! I fixed the issue and released v1.3.4.

sevzas commented 7 months ago

I appreciate your timely fixes...

looks like there is (at least) one bug remaining in RunService.CreateThreadAndRunAsync():

When you call _apiHttpService.PostAsync on line 91, the first parameter "_options.RunThreadAndRunCreateUri" is incorrect because it is missing the "/v1/" segment that all of the other invocations of _apiHttpService.PostAsync have. This is because the first parameter's value is built with GetXXXXXXXUri() in all of the other places.

JZO001 commented 7 months ago

Thank you, I am really appreciate to help me to test the SDK. I fixed this URL issue and released a new one. If you have more, send them here :)

sevzas commented 7 months ago

I am now able to send a request using RunService.CreateThreadAndRunAsync() . Thank you.