Skip to content

Commit

Permalink
feat: normal chat completions up
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistingTwists committed Jun 24, 2024
1 parent a3b7862 commit 4ba634a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/instructor/adapters/anthropic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Instructor.Adapters.Anthropic do
@behaviour Instructor.Adapter

@impl true
def chat_completion(params, config) do
def chat_completion(params, config \\ nil) do
config = if config, do: config, else: config()

# Peel off instructor only parameters
Expand Down Expand Up @@ -53,11 +53,13 @@ defmodule Instructor.Adapters.Anthropic do
# "type" => "message",
# "usage" => %{"input_tokens" => 243, "output_tokens" => 132}
# }
defp to_openai_response(params) do
defp to_openai_response(%{"content" => [%{"text" => content_text, "type" => "text"}]}=_params) do
# optionally, remove ```
content_text = content_text |> String.trim_trailing("\n```")
%{
"choices" => [
%{
"message" => params
"message" => %{"content" => content_text}
}
]
}
Expand Down

0 comments on commit 4ba634a

Please sign in to comment.