Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions js/dist/shinychat.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/shinychat.js.map

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions js/src/chat/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,6 @@ export const initialState: ChatState = {
}

function messagePayloadToData(msg: MessagePayload): ChatMessageData {
if (msg.content_type === "thinking") {
return {
id: msg.id ?? uuid(),
role: "assistant",
content: "",
contentType: "markdown",
streaming: false,
icon: msg.icon,
blocks: [
{
type: "thinking",
content: msg.content,
streaming: false,
startedAt: Date.now(),
},
],
}
}

const blocks = splitThinkingBlocks(msg.content, msg.content_type)
const contentOnly = blocks
.filter((b): b is ContentBlock => b.type === "content")
Expand Down Expand Up @@ -117,10 +98,6 @@ function splitThinkingBlocks(
content: string,
contentType: ContentType,
): MessageBlock[] {
if (contentType === "thinking") {
return [{ type: "thinking", content, streaming: false }]
}

// Skip splitting for non-markdown content types where <thinking> tags
// are likely literal content rather than thinking markers
if (contentType !== "markdown") {
Expand Down Expand Up @@ -394,39 +371,6 @@ export function chatReducer(state: ChatState, action: AnyAction): ChatState {
? (lastBlock as ContentBlock).contentType
: undefined) ?? "markdown"

// If server explicitly says "thinking", use the direct thinking path
if (explicitType === "thinking") {
const blocks = [...last.blocks]
const tail = lastBlock?.type === "thinking" ? lastBlock : null
if (tail) {
const { cleaned, topic, buffer } = extractTopics(
action.content,
tail.topicBuffer ?? "",
)
blocks[blocks.length - 1] = {
...tail,
content: tail.content + cleaned,
topicBuffer: buffer,
...(topic !== null ? { topic } : {}),
}
} else {
const { cleaned, topic, buffer } = extractTopics(action.content, "")
blocks.push({
type: "thinking",
content: cleaned,
topicBuffer: buffer,
streaming: true,
startedAt: Date.now(),
...(topic !== null ? { topic } : {}),
})
}
return {
...state,
streamingMessage: { ...last, blocks },
}
}

// No explicit content_type — detect <thinking> tags in content
const chunkType = explicitType ?? defaultContentType

// If we're inside a thinking tag or the chunk might contain one,
Expand Down
2 changes: 1 addition & 1 deletion js/src/transport/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { HtmlDep } from "rstudio-shiny/srcts/types/src/shiny/render"

export type ContentType = "markdown" | "html" | "text" | "thinking"
export type ContentType = "markdown" | "html" | "text"

export type MessagePayload = {
id?: string
Expand Down
Loading
Loading