- Add support for GPT-OSS and improve tool calling across all models.
GPT-OSS model tool calling
let chat: [Chat.Message] = [
.system(
"You are a helpful assistant that can provide stock prices. When asked for a stock price, you must use the get_stock_price tool."
),
.user("What is the price of AAPL?"),
]
var input = UserInput(chat: chat)
guard let llm1 = try gptOSS_20B(
input,
tools: [stockTool]
) else { return }
let (_, _, toolCalls) = try await llm1.result
guard let toolCall = toolCalls?.first else {
return
}
input.appendHarmonyAssistantToolCall(toolCall)
input.appendHarmonyToolResult(["price": 123.45])
guard let llm2 = try gptOSS_20B(
input,
tools: [stockTool]
) else { return }
let result = try await llm2.text.result
Other model tool calling
let chat: [Chat.Message] = [
.system(
"You are a helpful assistant that can provide stock prices. When asked for a stock price, you must use the get_stock_price tool."
),
.user("What is the price of AAPL?"),
]
var input = UserInput(chat: chat)
guard let llm1 = try qwen3MoE(
input,
tools: [stockTool]
) else { return }
let (_, _, toolCalls) = try await llm1.result
guard let toolCall = toolCalls?.first else {
return
}
input.appendToolResult(["price": 123.45])
guard let llm2 = try qwen3MoE(
input,
tools: [stockTool]
) else { return }
let result = try await llm2.text.result