Open TwistingTwists opened 3 months ago
I am taking time off for week or so. Might not be actively able to actively contibute to this PR until 4 april.
Can review changes, comments. :)
https://github.com/brainlid/langchain/pull/86/files
Reference PR.
Sax parser for supporting claude native XML format.
Examples of using Sax parsing with Saxy (which I used recently), if that's useful!
Examples of using Sax parsing with Saxy (which I used recently), if that's useful!
Super useful. Gem. 🌸🌸
Will continue working on this pr after holidays finish. :)
https://twitter.com/jxnlco/status/1773536962403533187
Maybe don't need to do XML stuff. Json mode has been reported to work reliably
{"anthropic-beta", "tools-2024-04-04"}
this header is required to use tools now
The function to conform to openai structure should be:
# %{
# "content" => [
# %{
# "text" => "ACTUAL RESPONSE ",
# "type" => "text"
# }
# ],
# "id" => "msg_01W35ZRGGrPaL4fXqgB5fHDs",
# "model" => "claude-3-haiku-20240307",
# "role" => "assistant",
# "stop_reason" => "end_turn",
# "stop_sequence" => nil,
# "type" => "message",
# "usage" => %{"input_tokens" => 243, "output_tokens" => 132}
# }
defp to_openai_response(%{"content" => [%{"text" => text}]} = _params) do
%{
"choices" => [
%{
"message" => %{"content" => text}
}
]
}
end
Added PR but removed my fork so i could submit something else to main repo, but it's still here: https://github.com/TwistingTwists/instructor_ex/pull/1/files
Will work on it over the weekend. Thanks for this @noozo !
@cigrainger : Streaming response works.
Will add an example in a few minutes. Feel free to checkout this branch.
This might not be mergable, at the moment, because it includes lots of goodies from other branches as well. But it works.
Big thanks to @noozo , @thbar for the tips ! :)
Also, since I was testing Gemini as well, I rebased Andres Alejos
's work and put this in the same PR.
can remove this if needed.
almost done with #33
Gave it a try and got the following error:
** (MatchError) no match of right hand side value: {:error, :adapter_error, %{"error" => %{"message" => "tool_choice: Input tag 'function' found using 'type' does not match any of the expected tags: 'auto', 'any', 'tool'", "type" => "invalid_request_error"}, "type" => "error"}}
@cigrainger ,{:error, error}
is always a tuple of two. Also updated the signature of the chat_completion function.
Done so far:
In progress: