mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
Revert "feat: include tokens usage for streamed output" (#4336)
Revert "feat: include tokens usage for streamed output (#4282)"
This reverts commit 0d6c3a7d57
.
This commit is contained in:
parent
cea5a0ea42
commit
f943c4b803
5 changed files with 10 additions and 25 deletions
|
@ -117,12 +117,8 @@ func ModelInference(ctx context.Context, s string, messages []schema.Message, im
|
|||
ss := ""
|
||||
|
||||
var partialRune []byte
|
||||
err := inferenceModel.PredictStream(ctx, opts, func(reply *proto.Reply) {
|
||||
msg := reply.GetMessage()
|
||||
partialRune = append(partialRune, msg...)
|
||||
|
||||
tokenUsage.Prompt = int(reply.PromptTokens)
|
||||
tokenUsage.Completion = int(reply.Tokens)
|
||||
err := inferenceModel.PredictStream(ctx, opts, func(chars []byte) {
|
||||
partialRune = append(partialRune, chars...)
|
||||
|
||||
for len(partialRune) > 0 {
|
||||
r, size := utf8.DecodeRune(partialRune)
|
||||
|
@ -136,10 +132,6 @@ func ModelInference(ctx context.Context, s string, messages []schema.Message, im
|
|||
|
||||
partialRune = partialRune[size:]
|
||||
}
|
||||
|
||||
if len(msg) == 0 {
|
||||
tokenCallback("", tokenUsage)
|
||||
}
|
||||
})
|
||||
return LLMResponse{
|
||||
Response: ss,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue