Skip to content

Commit

Permalink
Merge pull request #27 from eastriverlee/26-missing-argument-for-llam…
Browse files Browse the repository at this point in the history
…a_token_to_piece

deal with API change
  • Loading branch information
eastriverlee authored Jul 12, 2024
2 parents 53ae135 + e50b98e commit bd31fdb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/LLM/LLM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ extension Model {
public func decode(_ token: Token, with multibyteCharacter: inout [CUnsignedChar]) -> String {
var bufferLength = 16
var buffer: [CChar] = .init(repeating: 0, count: bufferLength)
let actualLength = Int(llama_token_to_piece(self, token, &buffer, Int32(bufferLength), false))
let actualLength = Int(llama_token_to_piece(self, token, &buffer, Int32(bufferLength), 0, false))
guard 0 != actualLength else { return "" }
if actualLength < 0 {
bufferLength = -actualLength
buffer = .init(repeating: 0, count: bufferLength)
llama_token_to_piece(self, token, &buffer, Int32(bufferLength), false)
llama_token_to_piece(self, token, &buffer, Int32(bufferLength), 0, false)
} else {
buffer.removeLast(bufferLength - actualLength)
}
Expand Down

0 comments on commit bd31fdb

Please sign in to comment.