Skip to content

Commit

Permalink
Merge pull request #13 from patentfield/tools
Browse files Browse the repository at this point in the history
Add support tools
  • Loading branch information
andreibondarev authored Apr 5, 2024
2 parents 5b09686 + e4812a6 commit 2958a73
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,34 @@ end

`force_encoding` is preferred to avoid JSON parsing issue when Cohere returns emoticon.

`chat` supports Tool use (function calling).

```ruby
tools = [
{
name: "query_daily_sales_report",
description: "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
parameter_definitions: {
day: {
description: "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
type: "str",
required: true
}
}
}
]

message = "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?"

client.chat(
model: model,
message: message,
tools: tools,
)
```



### Embed

```ruby
Expand Down
2 changes: 2 additions & 0 deletions lib/cohere/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def chat(
p: nil,
frequency_penalty: nil,
presence_penalty: nil,
tools: [],
&block
)
response = connection.post("chat") do |req|
Expand All @@ -55,6 +56,7 @@ def chat(
req.body[:p] = p if p
req.body[:frequency_penalty] = frequency_penalty if frequency_penalty
req.body[:presence_penalty] = presence_penalty if presence_penalty
req.body[:tools] = tools if tools
end
response.body
end
Expand Down

0 comments on commit 2958a73

Please sign in to comment.