Skip to content

v0.7.0

Choose a tag to compare

@atdrendel atdrendel released this 16 Oct 22:01
· 15 commits to main since this release
56c99d4
  • 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