-
Notifications
You must be signed in to change notification settings - Fork 30
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
Dializer error for what looks like valid call #8
Comments
Hey! While the data you pass in is correct, Dialyzer expects a %ExOpenAI.Components.ChatCompletionRequestMessage struct to pass into def create_completion(prompt, max_tokens) do
messages = [
%ExOpenAI.Components.ChatCompletionRequestMessage{role: :user, content: prompt}
]
opts = [max_tokens: max_tokens, temperature: 0]
ExOpenAI.Chat.create_chat_completion(messages, "gpt-3.5-turbo", opts)
|> case do
{:ok, %{choices: [%{message: %{content: content}}]}} ->
{:ok, content}
{:error, %{error: %{message: message}}} ->
{:error, message}
end
end the complaining should go away. Checked in iex for Jason decoder errors:
|
Nice dude. Here's what I get:
Looks like I'm on the right version:
Configs:
|
I can't reproduce this. Have you recently upgraded? In that case you may need to clean your deps and recompile everything I've created a new project from scratch, added 1.2.1 as deps, copied over my my envrc and config.exs for API key setup and ran the code you provided:
config.exs:
Can you provide me the code/project you're using? |
In your test project, I don't think you tried to create a chat completion with that struct? I tried your suggestion, and cleaned + recompiled the product = no love. I can't share the project right now, it's a private repo. |
I did, see the lines here:
This is very odd. Let me do some poking around here and see if I can somehow reproduce this.... If you have time, could you clone this repo, setup your API key, remove the VCR cassette for the chat completion test and re-run Jason stuff is implemented in ex_openai/lib/ex_openai/Jason.ex Line 4 in 2306fe7
And then used when components are generated here: Line 72 in 2306fe7
So all ExOpenAI.Components.* should implement Jason just fine. Another random idea, but are you using Jason in your project? If yes, which version are you pulling in? Could be a mismatch that’s causing some weirdness |
Ah ok, I assume that
Does something similar to my code sample. |
|
Please run (...But you didn't have any jason issues when you trialed the audio transcription stuff which is using the exact same jason implementing, so this shouldn't matter) And try a manual Jason.encode in an iex -S mix session after running a
Then, please also run this within your project iex session to check what things within ex_openai are implementing the Jason.Encoder protocol:
Output should be:
|
I'm getting this dialyzer error:
For this function call:
I've tried:
ChatCompletionRequestMessage
(which raises a Jason decoder error)I'm not sure what's causing this, but I'm pretty close to the documented example.
Great library BTW, I'm much happier with it than any of the other implementations I've tried (which is about 4 at this point).
The text was updated successfully, but these errors were encountered: