Skip to content

Commit 0cc53b9

Browse files
committed
fix(Server): update mlx-swift-lm submodule to receive Evaluate.swift iteration mapping bugfix
Also apply proper stopReason to .length extraction logic over Server.swift chat streaming loops.
1 parent 7da183d commit 0cc53b9

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

Sources/mlx-server/Server.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,15 @@ func handleChatStreaming(
970970
let argsJson = serializeToolCallArgs(tc.function.arguments)
971971
cont.yield(sseToolCallChunk(modelId: modelId, index: toolCallIndex, name: tc.function.name, arguments: argsJson))
972972
toolCallIndex += 1
973-
case .info:
973+
case .info(let info):
974974
if !stopped {
975-
let reason = hasToolCalls ? "tool_calls" : "stop"
975+
var reason: String
976+
switch info.stopReason {
977+
case .length:
978+
reason = "length"
979+
case .cancelled, .stop:
980+
reason = hasToolCalls ? "tool_calls" : "stop"
981+
}
976982
cont.yield(sseChunk(modelId: modelId, delta: "", finishReason: reason))
977983
if includeUsage {
978984
cont.yield(sseUsageChunk(modelId: modelId, promptTokens: promptTokenCount, completionTokens: completionTokenCount))
@@ -1186,9 +1192,16 @@ func handleTextStreaming(
11861192
}
11871193
case .toolCall:
11881194
break
1189-
case .info:
1195+
case .info(let info):
11901196
if !stopped {
1191-
cont.yield(sseTextChunk(modelId: modelId, text: "", finishReason: "stop"))
1197+
var reason: String
1198+
switch info.stopReason {
1199+
case .length:
1200+
reason = "length"
1201+
case .cancelled, .stop:
1202+
reason = "stop"
1203+
}
1204+
cont.yield(sseTextChunk(modelId: modelId, text: "", finishReason: reason))
11921205
cont.yield("data: [DONE]\n\n")
11931206
cont.finish()
11941207
}

mlx-swift-lm

0 commit comments

Comments
 (0)