Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue pulling models list #206

Open
jaacMusic opened this issue May 1, 2024 · 2 comments
Open

Issue pulling models list #206

jaacMusic opened this issue May 1, 2024 · 2 comments

Comments

@jaacMusic
Copy link

Hello,

When trying to pull a list of all the models using the following: api.Models.GetModelsAsync().Result My program just get stuck.
Does anyone knows how to pull a list of all AI models?

Thanks!
Juan

@jaacMusic jaacMusic changed the title Issue pullilng models list Issue pulling models list May 1, 2024
@bojake
Copy link

bojake commented May 14, 2024

It's likely a deadlock in the .Result call. That can happen if you call the async client from inside a web application.

HttpClient client = new HttpClient();
HttpResponseMessage resp = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
string body = await resp.Content.ReadAsStringAsync();

That may likely fix the problem you are having, if you wanted to edit the source and make a custom build of the library.

@jaacMusic
Copy link
Author

Thanks Bojake for the response!
I was able to work around this issue using the following and skipping the first 8 values.

            for (int i = 8; i < typeof(OpenAI_API.Models.Model).GetProperties().Length; i++)
            {
                AIModels.Items.Add(typeof(OpenAI_API.Models.Model).GetProperties()[i].Name);
            }

models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants