-
Notifications
You must be signed in to change notification settings - Fork 20
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
http_kwargs
not passed to HTTP.request
#44
Comments
The test here only checks that the reply is successful, but in fact, if you put one more argument, for instance http_kwargs=(connect_timeout=10, readtimeout=0, verbose=2) the test should throw: julia> create_chat("<token>", "gpt-3.5-turbo", [Dict("role" => "user", "content"=> "say something")]; http_kwargs=(connect_timeout=10, readtimeout=0, verbose=2))
ERROR: MethodError: no method matching request(::String, ::String, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}; body::IOBuffer, headers::Vector{Pair{String, String}})
Closest candidates are:
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any) got unsupported keyword arguments "body", "headers"
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:455
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any, ::Any; headers, body, query, kw...)
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:455
request(::Any, ::Any, ::Any, ::Any; headers, body, query, observelayers, kw...)
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:313
...
Stacktrace:
[1] request_body(url::String, method::String; input::IOBuffer, headers::Vector{Pair{String, String}}, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}})
@ OpenAI ~/.julia/dev/OpenAI/src/OpenAI.jl:80 |
I just did the following call: create_chat(
ENV["OPENAI_API_KEY"],
"gpt-3.5-turbo",
[Dict("role" => "user", "content" => "Summarize HTTP.jl package in a short sentence.")],
http_kwargs=(connect_timeout=10, readtimeout=0, verbose=2)
) And this gets printed:
At least, I can conclude from here that the |
I guess there's a typo in my original message, ' |
@algunion Hmm, for me it still throws: julia> using OpenAI: create_chat
julia> create_chat(
ENV["OPENAI_API_TOKEN"],
"gpt-3.5-turbo",
[Dict("role" => "user", "content" => "Summarize HTTP.jl package in a short sentence.")],
http_kwargs=(connect_timeout=10, readtimeout=0, verbose=2)
)
ERROR: MethodError: no method matching request(::String, ::String, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}; body::IOBuffer, headers::Vector{Pair{String, String}})
Closest candidates are:
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any) got unsupported keyword arguments "body", "headers"
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:455
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any, ::Any; headers, body, query, kw...)
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:455
request(::Any, ::Any, ::Any, ::Any; headers, body, query, observelayers, kw...)
@ HTTP ~/.julia/packages/HTTP/e7yOj/src/HTTP.jl:313
...
Stacktrace:
[1] request_body(url::String, method::String; input::IOBuffer, headers::Vector{Pair{String, String}}, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}})
@ OpenAI ~/.julia/packages/OpenAI/jZ9Qc/src/OpenAI.jl:80 Julia 1.9.2, OpenAI 0.8.5 |
I've also tried with fresh install of Julia 1.7.2, seems to throw: julia> VERSION
v"1.7.2"
(@v1.7) pkg> st
Status `~/.julia/environments/v1.7/Project.toml`
[e9f21f70] OpenAI v0.8.5
julia> using OpenAI: create_chat
julia> create_chat(
ENV["OPENAI_API_TOKEN"],
"gpt-3.5-turbo",
[Dict("role" => "user", "content" => "Summarize HTTP.jl package in a short sentence.")],
http_kwargs=(connect_timeout=10, readtimeout=0, verbose=2)
)
ERROR: MethodError: no method matching request(::String, ::String, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}, ::Pair{Symbol, Int64}; body=IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=113, maxsize=Inf, ptr=1, mark=-1), headers=["Authorization" => "Bearer sk-<...>", "Content-Type" => "application/json"])
Closest candidates are:
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any) at ~/.julia/packages/HTTP/nn2yB/src/HTTP.jl:455 got unsupported keyword arguments "body", "headers"
request(::Union{Function, Type}, ::Any, ::Any, ::Any, ::Any, ::Any; headers, body, query, kw...) at ~/.julia/packages/HTTP/nn2yB/src/HTTP.jl:455
request(::Any, ::Any, ::Any, ::Any; headers, body, query, observelayers, kw...) at ~/.julia/packages/HTTP/nn2yB/src/HTTP.jl:313
...
Stacktrace:
[1] request_body(url::String, method::String; input::IOBuffer, headers::Vector{Pair{String, String}}, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}})
@ OpenAI ~/.julia/packages/OpenAI/jZ9Qc/src/OpenAI.jl:80
[2] _request(api::String, provider::OpenAI.OpenAIProvider, api_key::String; method::String, http_kwargs::NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}, streamcallback::Nothing, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:model, :messages), Tuple{String, Vector{Dict{String, String}}}}})
@ OpenAI ~/.julia/packages/OpenAI/jZ9Qc/src/OpenAI.jl:136
[3] openai_request(api::String, api_key::String; method::String, http_kwargs::NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}, streamcallback::Nothing, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:model, :messages), Tuple{String, Vector{Dict{String, String}}}}})
@ OpenAI ~/.julia/packages/OpenAI/jZ9Qc/src/OpenAI.jl:163
[4] create_chat(api_key::String, model_id::String, messages::Vector{Dict{String, String}}; http_kwargs::NamedTuple{(:connect_timeout, :readtimeout, :verbose), Tuple{Int64, Int64, Int64}}, streamcallback::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ OpenAI ~/.julia/packages/OpenAI/jZ9Qc/src/OpenAI.jl:297
[5] top-level scope
@ REPL[4]:1 |
I get the same error as @kir19890817 on Windows 11
and package version
shows signigicantly more than 2 tokens as answer. |
I'll take a look at this tonight or tomorrow |
I believe this could be closed, as it has been fixed by: #49 |
It seems that
http_kwargs
are not translated here properly:If the
(verbose = 2,)
is passed toHTTP.request
directly, it will display the debug information in the REPL.The text was updated successfully, but these errors were encountered: