@@ -79,7 +79,7 @@ public struct GenerateParameters: Sendable {
79
79
self . repetitionContextSize = repetitionContextSize
80
80
}
81
81
82
- func sampler( ) -> LogitSampler {
82
+ public func sampler( ) -> LogitSampler {
83
83
if temperature == 0 {
84
84
return ArgMaxSampler ( )
85
85
} else if topP > 0 && topP < 1 {
@@ -89,7 +89,7 @@ public struct GenerateParameters: Sendable {
89
89
}
90
90
}
91
91
92
- func processor( ) -> LogitProcessor ? {
92
+ public func processor( ) -> LogitProcessor ? {
93
93
if let repetitionPenalty, repetitionContextSize > 0 {
94
94
return RepetitionContext (
95
95
repetitionPenalty: repetitionPenalty, repetitionContextSize: repetitionContextSize)
@@ -379,6 +379,26 @@ public struct TokenIterator: Sequence, IteratorProtocol {
379
379
380
380
/// Result of a call to ``generate(input:parameters:context:didGenerate:)``.
381
381
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
+
382
402
/// input (prompt, images, etc.)
383
403
public let inputText : LMInput . Text
384
404
0 commit comments