Tool Calling
Learn the basic interface of tool calling within Orpheus.
use orpheus::prelude::*;
fn main() {
let client = Orpheus::from_env().unwrap();
// Define a tool
// For this example, it's just an empty tool we can use as a "switch".
let my_tool = Tool::function("my_tool").empty();
let res = client
.chat("Call my tool")
.model("openai/gpt-4o")
.tools([my_tool]) // Pass an iterable of tools to the request
.send()
.unwrap();
// `tool_calls` is a convenience method to
// access tool calls in the response, if any
if let Some(tool_calls) = res.tool_calls().unwrap() {
for tool_call in tool_calls {
println!("Tool call: {:?}", tool_call);
}
}
}Last updated
Was this helpful?