Skip to content

Commit 4f1fb0e

Browse files
committed
Add JSONValue dependency and remove OKJSONValue usage
1 parent 183be24 commit 4f1fb0e

File tree

8 files changed

+36
-74
lines changed

8 files changed

+36
-74
lines changed

Package.resolved

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
2+
"originHash" : "6242cad8dd673917dc88c55f945db46d49b52a4cb3fc946fd6473dbfe09979f0",
23
"pins" : [
4+
{
5+
"identity" : "jsonvalue",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/1amageek/JSONValue.git",
8+
"state" : {
9+
"branch" : "main",
10+
"revision" : "067dcf205a3688bdd9a11928aeb83f3e61774271"
11+
}
12+
},
313
{
414
"identity" : "swift-docc-plugin",
515
"kind" : "remoteSourceControl",
@@ -19,5 +29,5 @@
1929
}
2030
}
2131
],
22-
"version" : 2
32+
"version" : 3
2333
}

Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ let package = Package(
1616
targets: ["OllamaKit"]),
1717
],
1818
dependencies: [
19+
.package(url: "https://github.com/1amageek/JSONValue.git", branch: "main"),
1920
.package(url: "https://github.com/apple/swift-docc-plugin.git", .upToNextMajor(from: "1.3.0"))
2021
],
2122
targets: [
2223
.target(
2324
name: "OllamaKit",
24-
dependencies: []),
25+
dependencies: [
26+
"JSONValue"
27+
]),
2528
.testTarget(
2629
name: "OllamaKitTests",
2730
dependencies: ["OllamaKit"]),

Playground/OKPlayground/Views/ChatWithFormatView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Combine
99
import OllamaKit
1010
import SwiftUI
11+
import JSONValue
1112

1213
struct ChatWithFormatView: View {
1314

@@ -133,7 +134,7 @@ struct ChatWithFormatView: View {
133134
.store(in: &cancellables)
134135
}
135136

136-
private func getFormat() -> OKJSONValue {
137+
private func getFormat() -> JSONValue {
137138
return
138139
.object(["type": .string("array"),
139140
"items": .object([

Playground/OKPlayground/Views/ChatWithToolsView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Combine
99
import OllamaKit
1010
import SwiftUI
11+
import JSONValue
1112

1213
struct ChatWithToolsView: View {
1314
@Environment(ViewModel.self) private var viewModel
@@ -105,7 +106,7 @@ struct ChatWithToolsView: View {
105106
.store(in: &cancellables)
106107
}
107108

108-
private func getTools() -> [OKJSONValue] {
109+
private func getTools() -> [JSONValue] {
109110
return [
110111
.object([
111112
"type": .string("function"),

Sources/OllamaKit/RequestData/OKChatRequestData.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Foundation
9+
import JSONValue
910

1011
/// A structure that encapsulates data for chat requests to the Ollama API.
1112
public struct OKChatRequestData: Sendable {
@@ -17,12 +18,12 @@ public struct OKChatRequestData: Sendable {
1718
/// An array of ``Message`` instances representing the content to be sent to the Ollama API.
1819
public let messages: [Message]
1920

20-
/// An optional array of ``OKJSONValue`` representing the tools available for tool calling in the chat.
21-
public let tools: [OKJSONValue]?
21+
/// An optional array of ``JSONValue`` representing the tools available for tool calling in the chat.
22+
public let tools: [JSONValue]?
2223

23-
/// Optional ``OKJSONValue`` representing the JSON schema for the response.
24+
/// Optional ``JSONValue`` representing the JSON schema for the response.
2425
/// Be sure to also include "return as JSON" in your prompt
25-
public let format: OKJSONValue?
26+
public let format: JSONValue?
2627

2728
/// Optional ``OKCompletionOptions`` providing additional configuration for the chat request.
2829
public var options: OKCompletionOptions?
@@ -31,8 +32,8 @@ public struct OKChatRequestData: Sendable {
3132
public init(
3233
model: String,
3334
messages: [Message],
34-
tools: [OKJSONValue]? = nil,
35-
format: OKJSONValue? = nil,
35+
tools: [JSONValue]? = nil,
36+
format: JSONValue? = nil,
3637
options: OKCompletionOptions? = nil
3738
) {
3839
self.stream = tools == nil
@@ -46,8 +47,8 @@ public struct OKChatRequestData: Sendable {
4647
public init(
4748
model: String,
4849
messages: [Message],
49-
tools: [OKJSONValue]? = nil,
50-
format: OKJSONValue? = nil,
50+
tools: [JSONValue]? = nil,
51+
format: JSONValue? = nil,
5152
with configureOptions: @Sendable (inout OKCompletionOptions) -> Void
5253
) {
5354
self.stream = tools == nil

Sources/OllamaKit/RequestData/OKGenerateRequestData.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Foundation
9+
import JSONValue
910

1011
/// A structure that encapsulates the data required for generating responses using the Ollama API.
1112
public struct OKGenerateRequestData: Sendable {
@@ -20,9 +21,9 @@ public struct OKGenerateRequestData: Sendable {
2021
/// An optional array of base64-encoded images.
2122
public let images: [String]?
2223

23-
/// Optional ``OKJSONValue`` representing the JSON schema for the response.
24+
/// Optional ``JSONValue`` representing the JSON schema for the response.
2425
/// Be sure to also include "return as JSON" in your prompt
25-
public let format: OKJSONValue?
26+
public let format: JSONValue?
2627

2728
/// An optional string specifying the system message.
2829
public var system: String?
@@ -39,7 +40,7 @@ public struct OKGenerateRequestData: Sendable {
3940
images: [String]? = nil,
4041
system: String? = nil,
4142
context: [Int]? = nil,
42-
format: OKJSONValue? = nil,
43+
format: JSONValue? = nil,
4344
options: OKCompletionOptions? = nil
4445
) {
4546
self.stream = true
@@ -56,7 +57,7 @@ public struct OKGenerateRequestData: Sendable {
5657
model: String,
5758
prompt: String,
5859
images: [String]? = nil,
59-
format: OKJSONValue? = nil,
60+
format: JSONValue? = nil,
6061
with configureOptions: @Sendable (inout OKCompletionOptions) -> Void
6162
) {
6263
self.stream = true

Sources/OllamaKit/Responses/OKChatResponse.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import Foundation
9+
@_exported import JSONValue
910

1011
/// A structure that represents the response to a chat request from the Ollama API.
1112
public struct OKChatResponse: OKCompletionResponse, Decodable, Sendable {
@@ -107,8 +108,8 @@ public struct OKChatResponse: OKCompletionResponse, Decodable, Sendable {
107108
/// The name of the tool being called.
108109
public let name: String?
109110

110-
/// An optional ``OKJSONValue`` representing the arguments passed to the tool.
111-
public let arguments: OKJSONValue?
111+
/// An optional ``JSONValue`` representing the arguments passed to the tool.
112+
public let arguments: JSONValue?
112113
}
113114
}
114115
}

Sources/OllamaKit/Utils/OKJSONValue.swift

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)