Skip to content

Commit d0102f8

Browse files
committed
Remove id from ToolCallResponse
1 parent 36f51bb commit d0102f8

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

Core/Sources/ChatGPTChatTab/Chat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ struct Chat: ReducerProtocol {
329329

330330
for call in message.toolCalls ?? [] {
331331
all.append(.init(
332-
id: message.id + call.response.id,
332+
id: message.id + call.id,
333333
role: .tool,
334334
text: call.response.summary ?? call.response.content,
335335
references: []

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ extension ChatGPTService {
610610
all.append(ChatCompletionsRequestBody.Message(
611611
role: .tool,
612612
content: call.response.content,
613-
toolCallId: call.response.id
613+
toolCallId: call.id
614614
))
615615
} else {
616616
all.append(ChatCompletionsRequestBody.Message(

Tool/Sources/OpenAIService/Memory/AutoManagedChatGPTMemoryStrategy/AutoManagedChatGPTMemoryOpenAIStrategy.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension TokenEncoder {
4545
encodingContent.append(toolCall.function.arguments)
4646
total += 4
4747
encodingContent.append(toolCall.response.content)
48-
encodingContent.append(toolCall.response.id)
48+
encodingContent.append(toolCall.id)
4949
}
5050
}
5151
total += await withTaskGroup(of: Int.self, body: { group in

Tool/Sources/OpenAIService/Models.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ public struct ChatMessage: Equatable, Codable {
4040
self.id = id
4141
self.type = type
4242
self.function = function
43-
self.response = response ?? .init(id: id, content: "", summary: nil)
43+
self.response = response ?? .init(content: "", summary: nil)
4444
}
4545
}
4646

4747
public struct ToolCallResponse: Codable, Equatable {
48-
public var id: String
4948
public var content: String
5049
public var summary: String?
51-
public init(id: String, content: String, summary: String?) {
52-
self.id = id
50+
public init(content: String, summary: String?) {
5351
self.content = content
5452
self.summary = summary
5553
}

Tool/Tests/OpenAIServiceTests/ChatGPTStreamTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ final class ChatGPTStreamTests: XCTestCase {
133133
id: "id",
134134
type: "function",
135135
function: .init(name: "function", arguments: "{\n\"foo\": 1\n}"),
136-
response: .init(id: "id", content: "Function is called.", summary: nil)
136+
response: .init(content: "Function is called.", summary: nil)
137137
),
138138
]
139139
),
@@ -254,19 +254,19 @@ final class ChatGPTStreamTests: XCTestCase {
254254
id: "id",
255255
type: "function",
256256
function: .init(name: "function", arguments: "{\n\"foo\": 1\n}"),
257-
response: .init(id: "id", content: "Function is called.", summary: nil)
257+
response: .init(content: "Function is called.", summary: nil)
258258
),
259259
.init(
260260
id: "id2",
261261
type: "function",
262262
function: .init(name: "function", arguments: "{\n\"foo\": 1\n}"),
263-
response: .init(id: "id2", content: "Function is called.", summary: nil)
263+
response: .init(content: "Function is called.", summary: nil)
264264
),
265265
.init(
266266
id: "id3",
267267
type: "function",
268268
function: .init(name: "function", arguments: "{\n\"foo\": 1\n}"),
269-
response: .init(id: "id3", content: "Function is called.", summary: nil)
269+
response: .init(content: "Function is called.", summary: nil)
270270
),
271271
]
272272
),
@@ -360,7 +360,7 @@ final class ChatGPTStreamTests: XCTestCase {
360360
id: "id",
361361
type: "function",
362362
function: .init(name: "function", arguments: "{\n\"foo\": 1\n}"),
363-
response: .init(id: "id", content: "Function is called.", summary: nil)
363+
response: .init(content: "Function is called.", summary: nil)
364364
),
365365
]
366366
),

Tool/Tests/OpenAIServiceTests/ReformatPromptToBeGoogleAICompatibleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ReformatPromptToBeGoogleAICompatibleTests: XCTestCase {
110110
id: "id",
111111
type: "function",
112112
function: .init(name: "ping", arguments: "{ \"ip\": \"127.0.0.1\" }"),
113-
response: .init(id: "id", content: "42ms", summary: nil)
113+
response: .init(content: "42ms", summary: nil)
114114
),
115115
]
116116
),

0 commit comments

Comments
 (0)