docs(changelog): add 0.2.0 entry and pricing section to README
Document the incremental reasoning-delta streaming, live display pricing, and dynamic model fetch in CHANGELOG.md. Add a Pricing section to README.md explaining the MODEL_COSTS overlay and how to update prices.
This commit is contained in:
+36
-27
@@ -172,7 +172,7 @@ export function createStreamCommandCode(deps: CoreDependencies) {
|
|||||||
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined
|
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined
|
||||||
let textBlock: TextContent | undefined
|
let textBlock: TextContent | undefined
|
||||||
let currentTextIdx = -1
|
let currentTextIdx = -1
|
||||||
let thinkingBlock: string[] = []
|
let thinkingIdx = -1
|
||||||
let finished = false
|
let finished = false
|
||||||
|
|
||||||
const abortUpstream = () => {
|
const abortUpstream = () => {
|
||||||
@@ -204,29 +204,18 @@ export function createStreamCommandCode(deps: CoreDependencies) {
|
|||||||
currentTextIdx = -1
|
currentTextIdx = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
const flushThinkingBlock = () => {
|
const endThinking = () => {
|
||||||
if (thinkingBlock.length === 0) return
|
if (thinkingIdx < 0) return
|
||||||
const thinkingText = thinkingBlock.join("")
|
const tc = output.content[thinkingIdx]
|
||||||
thinkingBlock = []
|
if (tc && tc.type === "thinking") {
|
||||||
output.content.push({ type: "thinking", thinking: thinkingText })
|
stream.push({
|
||||||
const idx = output.content.length - 1
|
type: "thinking_end",
|
||||||
stream.push({
|
contentIndex: thinkingIdx,
|
||||||
type: "thinking_start",
|
content: (tc as { thinking: string }).thinking,
|
||||||
contentIndex: idx,
|
partial: output,
|
||||||
partial: output,
|
})
|
||||||
})
|
}
|
||||||
stream.push({
|
thinkingIdx = -1
|
||||||
type: "thinking_delta",
|
|
||||||
contentIndex: idx,
|
|
||||||
delta: thinkingText,
|
|
||||||
partial: output,
|
|
||||||
})
|
|
||||||
stream.push({
|
|
||||||
type: "thinking_end",
|
|
||||||
contentIndex: idx,
|
|
||||||
content: thinkingText,
|
|
||||||
partial: output,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleEvent = (event: unknown) => {
|
const handleEvent = (event: unknown) => {
|
||||||
@@ -262,12 +251,32 @@ export function createStreamCommandCode(deps: CoreDependencies) {
|
|||||||
|
|
||||||
case "reasoning-delta": {
|
case "reasoning-delta": {
|
||||||
endTextBlock()
|
endTextBlock()
|
||||||
thinkingBlock.push(stringValue(event.text) ?? "")
|
const delta = stringValue(event.text) ?? ""
|
||||||
|
if (thinkingIdx < 0) {
|
||||||
|
output.content.push({ type: "thinking", thinking: delta })
|
||||||
|
thinkingIdx = output.content.length - 1
|
||||||
|
stream.push({
|
||||||
|
type: "thinking_start",
|
||||||
|
contentIndex: thinkingIdx,
|
||||||
|
partial: output,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const tc = output.content[thinkingIdx]
|
||||||
|
if (tc && tc.type === "thinking") {
|
||||||
|
(tc as { thinking: string }).thinking += delta
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.push({
|
||||||
|
type: "thinking_delta",
|
||||||
|
contentIndex: thinkingIdx,
|
||||||
|
delta,
|
||||||
|
partial: output,
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "reasoning-end": {
|
case "reasoning-end": {
|
||||||
flushThinkingBlock()
|
endThinking()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +445,7 @@ export function createStreamCommandCode(deps: CoreDependencies) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
endTextBlock()
|
endTextBlock()
|
||||||
flushThinkingBlock()
|
endThinking()
|
||||||
|
|
||||||
stream.push({
|
stream.push({
|
||||||
type: "done",
|
type: "done",
|
||||||
|
|||||||
Reference in New Issue
Block a user