jzo001 / forge.openai Goto Github PK
View Code? Open in Web Editor NEWOpenAI API client library for .NET. I was developed it for for public use and it is free.
License: MIT License
OpenAI API client library for .NET. I was developed it for for public use and it is free.
License: MIT License
Hi there,
I see that you have examples for using the service with assistant APIs. Are you still working on it or can you create a release?
Cheers
This is an enhancement request.
OpenAI has overhauled the assistants Api - https://platform.openai.com/docs/changelog/released-assistants-api-updates
I'm hoping that Forge.OpenAI can be enhanced to support the new Assistants API features.
Thank You!
In your framework you have added "parameters" in the ChatToolFunction as a string. I cannot get it to work with just adding JSON in this string.
It is defined as as "object" in the documentation:
https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools
This probably needs to be an object with the settings possible, like type, properties and required. Properties as its own object - with something dynamic because names like emotion and language are specific for this case.
When I create my own full JSON payload like below, where parameters is a normal object with no " around the parameters content, it works.
{
"tools": [
{
"type": "function",
"function": {
"description": "Classify the relevant information from the phrase.",
"name": "getinformation",
"parameters": {
"type": "object",
"properties": {
"emotion": {
"type": "string",
"description": "The emotion of the phrase."
},
"language": {
"type": "string",
"description": "The language of the phrase."
}
},
"required": [
"emotion",
"language"
]
}
}
}
]
}
Errormessage example:
{
"error": {
"message": ""{'type': 'object', 'properties': {'language': {'type': 'string','description': 'The language of the phrase.' }}}" is not of type 'object' - 'tools.0.function.parameters'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Hi there,
I'm attempting to swap over to Azure Open AI and have come up against two problems.
the example here seems incomplete. It appears we have to provide the BaseAddress and AzureApiVersion. Is this correct?
A bigger issue seems to be how you are handling AuthenticationInfo
public AuthenticationInfo(string apiKey)
{
if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentNullException(nameof(apiKey));
if (!apiKey.Contains("sk-"))
{
throw new ArgumentException($"{apiKey} parameter must start with 'sk-'");
}
ApiKey = apiKey;
}
As far as I'm aware Azure does not prefix their API keys with sk-. Without adding the "sk-" I'm getting argument exception and if I add "sk-" to my Azure key I'm getting a 404. Are you able to provide some guidance.
Cheers
-Rob
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
}
}
This is a feature request.
It would be great if Forge.OpenAI had string constants defined for:
This request is similar to what is already in place for Content.CONTENT_TYPE_XXXX
Feel free to close this request if it's out of scope.
https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages
file = client.files.create(
file=open("myimage.png", "rb"),
purpose="vision"
)
thread = client.beta.threads.create(
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is the difference between these images?"
},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.png"}
},
{
"type": "image_file",
"image_file": ("file_id": file.id)
},
],
}
]
)
I would to use the image_url type for assistant messages, however in the Message.cs i only see content as string. Is that possible to change?
I want to create a differeny OpenAIService per key. Here's what I tried:
I can use static OpenAIService.CreateService
and provide options. This works but generally ServiceProvider
should be disposed. Therefore I'm left with hanging undisposed instance of a container. This is an issue on it's own.
I can use AddForgeOpenAIAsTransient
in my root container and after call:
IOpenAIService CreateService(OpenAIOptions options, IServiceProvider serviceProvider, IProviderEndpointService providerEndpointService)
This function gives me the impression that I can really provide OpenAIOptions but in reality each service resolves on it's own IApiHttpService
that ends up with default IProviderEndpointService
with default options inside.
Specifically this code is copypasted in many services:
_apiHttpService = serviceProvider.GetRequiredService<IApiHttpService>();
_providerEndpointService = providerEndpointService;
But it's actually wrong because provided providerEndpointService
is not passed to _apiHttpService
OpenAIProviderEndpointService
is registered as singleton. Therefore it is shared and you can't really have different options in one app. Ok you can call a function from step 2. creating this service with options as constructor parameter but that still leaves IApiHttpService
out of the box.In the 2nd constructor of OpenAIService, the one with this signature:
public OpenAIService(OpenAIOptions options, IApiHttpService apiHttpService, IProviderEndpointService providerEndpointService)
the RunService and RunStepService members are not being initialized and they remain null. Looks like maybe Zoltan forgot to add initialization for these two members when he added it to the first constructor?
please check openai playground below.
https://platform.openai.com/playground/complete
this is a legacy now. but are planning to integrate this?
Is there an easy way to change the timeout.
I've been hitting a timeout issue in my response from the ChatCompletionService. The max appears to be 100seconds.
Please add below models
"gpt-4-turbo"
"gpt-4-turbo-2024-04-09" in KnownModelTypes
i got htis email from openAI and they are now recommending
"We recommend developers using GPT-4 Turbo switch to calling gpt-4-turbo rather than gpt-4-turbo-preview or gpt-4-vision-preview. You can try the new GPT-4 Turbo model"
Hi there,
We’ve released an improved GPT-4 Turbo model, gpt-4-turbo-2024-04-09, and it is now generally available (GA) in the API under the gpt-4-turbo alias.
This model now supports vision, where the model can “see” and interpret the content of images. Additionally, vision requests can now use function calling and JSON mode.
This model is better at math, logical reasoning, and coding. Our open-source GitHub repo shows detailed eval results comparing this new model to previous model versions (e.g. gpt-4-0125-preview) and other models. Plus, you can use the code to run these evals yourself. Here’s a preview:
This model also writes in a more natural style, for example:
The last version had knowledge up until April 2023. This new model has knowledge up until December 2023. (Note: knowledge between April and December 2023 may have some inaccuracies.)
We recommend developers using GPT-4 Turbo switch to calling gpt-4-turbo rather than gpt-4-turbo-preview or gpt-4-vision-preview. You can try the new GPT-4 Turbo model in the playground.
If you have questions, reach out in the OpenAI developer forum. For the latest updates, follow @OpenAIDevs on X.
Happy building!
—The OpenAI team
This is a feature request.
OpenAI API offers streaming notification for changes to message and run objects.
https://platform.openai.com/docs/api-reference/assistants-streaming
It would be great in Forge.OpenAI supported this feature.
As best as I can understand, the intention of the RunSvc.GetAsync(ThreadId, RunId) is to retrieve the details for a single Run.
I believe that this method corresponds to this OpenAI API call: https://platform.openai.com/docs/api-reference/runs/getRun
I see the response is contained in the RunResponse class, but the RunResponse class is missing the actual properties of the Run that I'm looking to read such as "status".
Can you add them?
https://platform.openai.com/docs/api-reference/chat/create
As Function Messages are deprecated please add ChatMessageRoleTypes.TOOL and mark ChatMessageRoleTypes.FUNCTION as deprecated
Due to dependencies to System.Numerics, the library does not work with old .net 46, but only with .net Core - at least in my case.
br Andy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.