mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
fix issue with costs resetting once chat is completed
This commit is contained in:
parent
ca48a4f0fb
commit
248325925f
1 changed files with 2 additions and 11 deletions
|
@ -502,15 +502,6 @@ export namespace Session {
|
|||
}
|
||||
text = undefined
|
||||
},
|
||||
async onFinish(input) {
|
||||
log.info("message finish", {
|
||||
reason: input.finishReason,
|
||||
})
|
||||
const assistant = next.metadata!.assistant!
|
||||
const usage = getUsage(model.info, input.usage, input.providerMetadata)
|
||||
assistant.cost = usage.cost
|
||||
await updateMessage(next)
|
||||
},
|
||||
onError(err) {
|
||||
log.error("callback error", err)
|
||||
switch (true) {
|
||||
|
@ -681,7 +672,7 @@ export namespace Session {
|
|||
value.usage,
|
||||
value.providerMetadata,
|
||||
)
|
||||
assistant.cost = usage.cost
|
||||
assistant.cost += usage.cost
|
||||
await updateMessage(next)
|
||||
if (value.finishReason === "length")
|
||||
throw new Message.OutputLengthError({})
|
||||
|
@ -830,7 +821,7 @@ export namespace Session {
|
|||
async onFinish(input) {
|
||||
const assistant = next.metadata!.assistant!
|
||||
const usage = getUsage(model.info, input.usage, input.providerMetadata)
|
||||
assistant.cost = usage.cost
|
||||
assistant.cost += usage.cost
|
||||
assistant.tokens = usage.tokens
|
||||
next.metadata!.time.completed = Date.now()
|
||||
await updateMessage(next)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue