From 2b1f499dffe36cf402eda515b490bead397eb16d Mon Sep 17 00:00:00 2001 From: Vatsal Manot Date: Wed, 22 Jan 2025 16:58:41 -0800 Subject: [PATCH] Update package --- .../PromptLiteral._Degenerate.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/LargeLanguageModels/Intramodular/Prompt Literal/PromptLiteral._Degenerate.swift b/Sources/LargeLanguageModels/Intramodular/Prompt Literal/PromptLiteral._Degenerate.swift index a781e681..c4da358c 100644 --- a/Sources/LargeLanguageModels/Intramodular/Prompt Literal/PromptLiteral._Degenerate.swift +++ b/Sources/LargeLanguageModels/Intramodular/Prompt Literal/PromptLiteral._Degenerate.swift @@ -26,7 +26,7 @@ extension PromptLiteral { var components: [_Degenerate.Component] = [] func append(_ component: _Degenerate.Component) throws { - if let last = components.last, component.payload.type == last.payload.type { + if let last = components.last, component.payload.type == last.payload.type, component.payload.type._isConcatenatable { let merged = try last.appending(contentsOf: component) components.mutableLast = merged @@ -132,6 +132,19 @@ extension PromptLiteral._Degenerate.Component { case image case functionCall case functionInvocation + + var _isConcatenatable: Bool { + switch self { + case .string: + return true + case .image: + return false + case .functionCall: + return false + case .functionInvocation: + return false + } + } } public enum Payload {