Skip to content

Commit

Permalink
update beta version, supports tool_choice option. fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
lebrunel committed May 17, 2024
1 parent 75112c3 commit d068f9e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion lib/anthropix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ defmodule Anthropix do
]
]

schema :chat_tool_choice, [
type: [
type: :string,
required: true,
doc: "One of `auto`, `any` or `tool`."
],
name: [
type: :string,
doc: "The name of the tool to use."
]
]

@typedoc """
Chat message
Expand Down Expand Up @@ -263,7 +275,7 @@ defmodule Anthropix do
req = @default_req_opts
|> Keyword.merge(opts)
|> Req.new()
|> Req.Request.put_header("anthropic-beta", "tools-2024-04-04")
|> Req.Request.put_header("anthropic-beta", "tools-2024-05-16")
|> Req.Request.put_header("x-api-key", api_key)
|> Req.Request.put_headers(headers)

Expand Down Expand Up @@ -312,6 +324,11 @@ defmodule Anthropix do
type: {:list, {:map, schema(:chat_tool).schema}},
doc: "A list of tools the model may call.",
],
tool_choice: [
type: :map,
keys: schema(:chat_tool_choice).schema,
doc: "How to use the provided tools."
],
top_k: [
type: :integer,
doc: "Only sample from the top K options for each subsequent token."
Expand All @@ -336,6 +353,12 @@ defmodule Anthropix do
#{doc(:chat_message)}
## Tool structure
Each tool is a map with the following fields:
#{doc(:chat_tool)}
## Examples
```elixir
Expand Down
2 changes: 1 addition & 1 deletion test/support/mock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ defmodule Anthropix.Mock do
]
}

@spec client(function()) :: Anthropix.t()
@spec client(function()) :: Anthropix.client()
def client(plug) when is_function(plug, 1) do
struct(Anthropix, req: Req.new(plug: plug))
end
Expand Down

0 comments on commit d068f9e

Please sign in to comment.