Skip to content

Commit ed332ce

Browse files
committed
adding mistral tool fields to encoders
1 parent 61864f5 commit ed332ce

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/GenKit/Services/Mistral/MistralEncoders.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ extension MistralService {
1010
func encode(message: Message) -> Mistral.Message {
1111
.init(
1212
role: encode(role: message.role),
13-
content: message.content ?? ""
13+
content: message.content ?? "",
14+
toolCalls: encode(toolCalls: message.toolCalls),
15+
toolCallID: message.toolCallID
1416
)
1517
}
1618

@@ -38,6 +40,21 @@ extension MistralService {
3840
)
3941
}
4042

43+
func encode(toolCalls: [ToolCall]?) -> [Mistral.Message.ToolCall]? {
44+
guard let toolCalls else { return nil }
45+
return toolCalls.map { encode(toolCall: $0) }
46+
}
47+
48+
func encode(toolCall: ToolCall) -> Mistral.Message.ToolCall {
49+
.init(
50+
id: toolCall.id,
51+
function: .init(
52+
name: toolCall.function.name,
53+
arguments: toolCall.function.arguments
54+
)
55+
)
56+
}
57+
4158
func encode(toolChoice: Tool?) -> ChatRequest.ToolChoice {
4259
if toolChoice != nil {
4360
return .any

0 commit comments

Comments
 (0)