feat(history): Implement conversation history management with artifact restoration and Markdown rendering.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi } from "vitest"
|
||||
import { ChatService, type ChatEvent } from "./chat"
|
||||
import { describe, it, expect } from "vitest"
|
||||
import { ChatService, type ChatEvent, type MessageResponse } from "./chat"
|
||||
|
||||
describe("ChatService SSE Parsing", () => {
|
||||
it("should correctly parse a text stream chunk", () => {
|
||||
@@ -42,26 +42,26 @@ describe("ChatService SSE Parsing", () => {
|
||||
|
||||
describe("ChatService Message State Management", () => {
|
||||
it("should append text chunks to the last message content", () => {
|
||||
const messages = [{ id: "1", role: "assistant", content: "Initial", created_at: new Date().toISOString() }]
|
||||
const messages: MessageResponse[] = [{ id: "1", role: "assistant", content: "Initial", created_at: new Date().toISOString() }]
|
||||
const event: ChatEvent = {
|
||||
type: "on_chat_model_stream",
|
||||
node: "summarizer",
|
||||
data: { chunk: { content: " text" } }
|
||||
}
|
||||
|
||||
const updatedMessages = ChatService.updateMessagesWithEvent(messages as any, event)
|
||||
const updatedMessages = ChatService.updateMessagesWithEvent(messages, event)
|
||||
expect(updatedMessages[0].content).toBe("Initial text")
|
||||
})
|
||||
|
||||
it("should add plots to the message state", () => {
|
||||
const messages = [{ id: "1", role: "assistant", content: "Analysis", created_at: new Date().toISOString(), plots: [] }]
|
||||
const messages: MessageResponse[] = [{ id: "1", role: "assistant", content: "Analysis", created_at: new Date().toISOString(), plots: [] }]
|
||||
const event: ChatEvent = {
|
||||
type: "on_chain_end",
|
||||
name: "executor",
|
||||
data: { encoded_plots: ["plot1"] }
|
||||
}
|
||||
|
||||
const updatedMessages = ChatService.updateMessagesWithEvent(messages as any, event)
|
||||
const updatedMessages = ChatService.updateMessagesWithEvent(messages, event)
|
||||
expect(updatedMessages[0].plots).toEqual(["plot1"])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user