Skip to content

Commit 04650e1

Browse files
committed
Add documentation comments to helper methods
1 parent 2488201 commit 04650e1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Sources/AnyLanguageModel/Models/LlamaLanguageModel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ import Foundation
692692
)
693693
}
694694

695+
/// Builds structured-generation defaults while honoring explicit overrides.
695696
private func resolvedStructuredOptions(from options: GenerationOptions) -> ResolvedGenerationOptions {
696697
var base = legacyDefaults
697698
if let temp = options.temperature {
@@ -880,6 +881,7 @@ import Foundation
880881
return generatedText
881882
}
882883

884+
/// Builds a JSONSchema-informed prompt for structured output.
883885
private func schemaPrompt(for schema: GenerationSchema) -> String {
884886
let encoder = JSONEncoder()
885887
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]

Sources/AnyLanguageModel/Models/MLXLanguageModel.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ import Foundation
389389
)
390390
}
391391

392+
/// Builds MLX parameters tuned for structured generation.
392393
private func toStructuredGenerateParameters(_ options: GenerationOptions) -> MLXLMCommon.GenerateParameters {
393394
MLXLMCommon.GenerateParameters(
394395
maxTokens: options.maximumResponseTokens,
@@ -664,6 +665,7 @@ import Foundation
664665
return textParts.joined(separator: "\n")
665666
}
666667

668+
/// Builds a JSONSchema-informed prompt for structured output.
667669
private func schemaPrompt(for schema: GenerationSchema) -> String {
668670
let encoder = JSONEncoder()
669671
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
@@ -736,6 +738,7 @@ import Foundation
736738
return json
737739
}
738740

741+
/// Merges system prompts and schema instructions into a user message.
739742
private func normalizeChatForStructuredGeneration(
740743
_ chat: [MLXLMCommon.Chat.Message],
741744
schemaPrompt: String?

0 commit comments

Comments
 (0)