-
Notifications
You must be signed in to change notification settings - Fork 14
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
StreamCallback issue if :usage is nothing in PT. #247
Comments
Although what is interesting is that:
This works. If I specify the flavor it won't work anymore. |
Thanks for reporting! It's a bug in StreamCallbacks that should be fixed by this PR: svilupp/StreamCallbacks.jl#9 (new patch version has been tagged). The issue was that I wasn't checking if we had any usage data or not, so I was adding a If you want usage from the server, you must explicitly set it |
thx for fast fix! |
Tested this exact call: using PromptingTools
using PromptingTools: SystemMessage, UserMessage, AIMessage
using StreamCallbacks
using StreamCallbacksExt
cb = StreamCallbackWithHooks(
content_formatter = text -> begin
text
end,
on_done = () -> nothing,
on_stop_sequence = (stop_sequence) -> (println(stop_sequence)),
)
cb = StreamCallbackChannelWrapper(callback=cb)
conv = [SystemMessage("YOU ARE JUST GUD."), UserMessage("How you so gud."), AIMessage("You no know?"), UserMessage("ohno")]
msg = aigenerate(conv;
streamcallback=cb,
model="claude",
api_kwargs=(; stop_sequences=["that"], top_p=0.8, max_tokens=8192)
) And no issues. |
MVP:
If I don't add the
stream=true
which I think is rarely mentioned anywhere in the StreamCallbacks.jl if even mentioned that it is needed.As a quick fix I did this in llm_openai.jl:180
But I am not sure if I this is the right way to fix this issue.
The problem is that
resp.response.usage == nothing
, soget
doesn't default toDict
but return thenothing
.The text was updated successfully, but these errors were encountered: