Skip to content

Commit c9e2b8f

Browse files
authored
Make initializer and some methods public in GenerateResult and GenerateParameters (#239)
* Make the initializer public for GenerateResult and sampler and processor methods of GenerateParameters.
1 parent 95556b1 commit c9e2b8f

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

Libraries/MLXLMCommon/Evaluate.swift

+22-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public struct GenerateParameters: Sendable {
7979
self.repetitionContextSize = repetitionContextSize
8080
}
8181

82-
func sampler() -> LogitSampler {
82+
public func sampler() -> LogitSampler {
8383
if temperature == 0 {
8484
return ArgMaxSampler()
8585
} else if topP > 0 && topP < 1 {
@@ -89,7 +89,7 @@ public struct GenerateParameters: Sendable {
8989
}
9090
}
9191

92-
func processor() -> LogitProcessor? {
92+
public func processor() -> LogitProcessor? {
9393
if let repetitionPenalty, repetitionContextSize > 0 {
9494
return RepetitionContext(
9595
repetitionPenalty: repetitionPenalty, repetitionContextSize: repetitionContextSize)
@@ -379,6 +379,26 @@ public struct TokenIterator: Sequence, IteratorProtocol {
379379

380380
/// Result of a call to ``generate(input:parameters:context:didGenerate:)``.
381381
public struct GenerateResult: Sendable {
382+
383+
/// Initializes a new `GenerateResult` instance.
384+
///
385+
/// - Parameters:
386+
/// - inputText: The input text used for generation.
387+
/// - tokens: The array of tokens generated.
388+
/// - output: The generated output string.
389+
/// - promptTime: The time taken to prompt the input.
390+
/// - generateTime: The time taken to generate the output.
391+
public init(
392+
inputText: LMInput.Text, tokens: [Int], output: String, promptTime: TimeInterval,
393+
generateTime: TimeInterval
394+
) {
395+
self.inputText = inputText
396+
self.tokens = tokens
397+
self.output = output
398+
self.promptTime = promptTime
399+
self.generateTime = generateTime
400+
}
401+
382402
/// input (prompt, images, etc.)
383403
public let inputText: LMInput.Text
384404

Package.resolved

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
{
1313
"identity" : "jinja",
1414
"kind" : "remoteSourceControl",
15-
"location" : "https://github.com/maiqingqiang/Jinja",
15+
"location" : "https://github.com/johnmai-dev/Jinja",
1616
"state" : {
17-
"revision" : "6dbe4c449469fb586d0f7339f900f0dd4d78b167",
18-
"version" : "1.0.6"
17+
"revision" : "bbddb92fc51ae420b87300298370fd1dfc308f73",
18+
"version" : "1.1.1"
1919
}
2020
},
2121
{
@@ -32,8 +32,8 @@
3232
"kind" : "remoteSourceControl",
3333
"location" : "https://github.com/apple/swift-argument-parser.git",
3434
"state" : {
35-
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
36-
"version" : "1.5.0"
35+
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
36+
"version" : "1.4.0"
3737
}
3838
},
3939
{
@@ -50,8 +50,8 @@
5050
"kind" : "remoteSourceControl",
5151
"location" : "https://github.com/apple/swift-collections.git",
5252
"state" : {
53-
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
54-
"version" : "1.1.0"
53+
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
54+
"version" : "1.1.4"
5555
}
5656
},
5757
{
@@ -68,8 +68,8 @@
6868
"kind" : "remoteSourceControl",
6969
"location" : "https://github.com/huggingface/swift-transformers",
7070
"state" : {
71-
"revision" : "d42fdae473c49ea216671da8caae58e102d28709",
72-
"version" : "0.1.14"
71+
"revision" : "be855fac725dbae27264e47a3eb535cc422a4ba8",
72+
"version" : "0.1.18"
7373
}
7474
}
7575
],

0 commit comments

Comments
 (0)