Skip to content

Commit f52694e

Browse files
sebstoCopilot
andauthored
optimize regex
Co-authored-by: Copilot <[email protected]>
1 parent c824ce0 commit f52694e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/InvokeModel/TextCompletion.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public struct TextCompletion: Codable, Sendable {
2626
}
2727

2828
private static func extractReasoning(from text: String) -> (completion: String, reasoning: String?) {
29-
let reasoningRegex = /<reasoning>(.*?)<\/reasoning>/
30-
guard let match = text.firstMatch(of: reasoningRegex) else {
29+
guard let match = text.firstMatch(of: Self.reasoningRegex) else {
3130
return (text, nil)
3231
}
3332

3433
let reasoning = String(match.1)
35-
let cleanedText = text.replacing(reasoningRegex, with: "")
34+
let cleanedText = text.replacing(Self.reasoningRegex, with: "")
3635

3736
return (cleanedText, reasoning)
3837
}
38+
private static let reasoningRegex = /<reasoning>(.*?)<\/reasoning>/
3939
}

0 commit comments

Comments
 (0)