Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Applications/MLXChatExample/Services/MLXService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class MLXService {
chat: chat, processing: .init(resize: .init(width: 1024, height: 1024)))

// Generate response using the model
return try await modelContainer.perform { (context: ModelContext) in
return try await modelContainer.perform { context in

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the type was specified here -- just omit and it builds fine.

let lmInput = try await context.processor.prepare(input: userInput)
// Set temperature for response randomness (0.7 provides good balance)
let parameters = GenerateParameters(temperature: 0.7)
Expand Down
4 changes: 2 additions & 2 deletions Tools/llm-tool/LLMTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ struct GenerateArguments: ParsableArguments, Sendable {
}

func prepare(
_ context: inout ModelContext
_ context: inout TrainableModelContext
) {
if let extraEosToken {
context.configuration.extraEOSTokens.insert(extraEosToken)
}
}

func generate(
input: LMInput, context: ModelContext
input: LMInput, context: ModelContextProviding
Comment on lines -199 to +207

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the two examples I use in ModelContainer for how to update.

) async throws -> (GenerateCompletionInfo, String) {
var output = ""
for await item in try MLXLMCommon.generate(
Expand Down
Loading