Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/fumito-ito/FunctionCalling", from: "0.5.0"),
.package(url: "https://github.com/lzell/AIProxySwift.git", from: "0.43.0")
.package(url: "https://github.com/lzell/AIProxySwift.git", from: "0.44.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import FunctionCalling
import AIProxy

extension ToolContainer {
public typealias AIProxyOpenAITool = OpenAIChatCompletionRequestBody.Tool
public typealias AIProxyAnthropicTool = AnthropicTool
public typealias AIProxyTogetherAITool = TogetherAITool

// swiftlint:disable:next line_length
// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-use-openai-structured-outputs-json-schemas-in-a-tool-call
func toOpenAITools(strict: Bool = false) -> [OpenAIChatCompletionTool] {
func toOpenAITools(strict: Bool = false) -> [AIProxyOpenAITool] {
guard let allTools else { return [] }

return allTools.map { tool in
OpenAIChatCompletionTool.function(
AIProxyOpenAITool.function(
name: tool.name,
description: tool.description,
parameters: tool.inputSchema.toJSONSchema(),
Expand All @@ -21,11 +25,11 @@ extension ToolContainer {
}

// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-use-streaming-tool-calls-with-anthropic
func toAnthropicTools() -> [AnthropicTool] {
func toAnthropicTools() -> [AIProxyAnthropicTool] {
guard let allTools else { return [] }

return allTools.map { tool in
AnthropicTool(
AIProxyAnthropicTool(
description: tool.description,
inputSchema: tool.inputSchema.toJSONSchema(),
name: tool.name
Expand All @@ -35,11 +39,11 @@ extension ToolContainer {

// swiftlint:disable:next line_length
// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-make-a-tool-call-request-with-llama-and-togetherai
func toTogetherAITools() -> [TogetherAITool] {
func toTogetherAITools() -> [AIProxyTogetherAITool] {
guard let allTools else { return [] }

return allTools.map { tool in
TogetherAITool(
AIProxyTogetherAITool(
function: .init(
description: tool.description,
name: tool.name,
Expand Down