feat(frontend): Update chat service and UI to support Orchestrator architecture and native subgraph streaming
This commit is contained in:
@@ -3,21 +3,21 @@ import { ChatService, type ChatEvent, type MessageResponse } from "./chat"
|
||||
|
||||
describe("ChatService SSE Parsing", () => {
|
||||
it("should correctly parse a text stream chunk", () => {
|
||||
const rawChunk = `data: {"type": "on_chat_model_stream", "name": "summarizer", "data": {"chunk": "Hello"}}\n\n`
|
||||
const rawChunk = `data: {"type": "on_chat_model_stream", "name": "synthesizer", "data": {"chunk": "Hello"}}\n\n`
|
||||
const events = ChatService.parseSSEChunk(rawChunk)
|
||||
|
||||
expect(events).toHaveLength(1)
|
||||
expect(events[0]).toEqual({
|
||||
type: "on_chat_model_stream",
|
||||
name: "summarizer",
|
||||
name: "synthesizer",
|
||||
data: { chunk: "Hello" }
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle multiple events in one chunk", () => {
|
||||
const rawChunk =
|
||||
`data: {"type": "on_chat_model_stream", "name": "summarizer", "data": {"chunk": "Hello"}}\n\n` +
|
||||
`data: {"type": "on_chat_model_stream", "name": "summarizer", "data": {"chunk": " World"}}\n\n`
|
||||
`data: {"type": "on_chat_model_stream", "name": "synthesizer", "data": {"chunk": "Hello"}}\n\n` +
|
||||
`data: {"type": "on_chat_model_stream", "name": "synthesizer", "data": {"chunk": " World"}}\n\n`
|
||||
|
||||
const events = ChatService.parseSSEChunk(rawChunk)
|
||||
|
||||
@@ -25,8 +25,8 @@ describe("ChatService SSE Parsing", () => {
|
||||
expect(events[1].data!.chunk).toBe(" World")
|
||||
})
|
||||
|
||||
it("should parse encoded plots from executor node", () => {
|
||||
const rawChunk = `data: {"type": "on_chain_end", "name": "executor", "data": {"encoded_plots": ["base64data"]}}\n\n`
|
||||
it("should parse encoded plots from data_analyst_worker node", () => {
|
||||
const rawChunk = `data: {"type": "on_chain_end", "name": "data_analyst_worker", "data": {"encoded_plots": ["base64data"]}}\n\n`
|
||||
const events = ChatService.parseSSEChunk(rawChunk)
|
||||
|
||||
expect(events[0].data!.encoded_plots).toEqual(["base64data"])
|
||||
@@ -45,7 +45,7 @@ describe("ChatService Message State Management", () => {
|
||||
const messages: MessageResponse[] = [{ id: "1", role: "assistant", content: "Initial", created_at: new Date().toISOString() }]
|
||||
const event: ChatEvent = {
|
||||
type: "on_chat_model_stream",
|
||||
node: "summarizer",
|
||||
node: "synthesizer",
|
||||
data: { chunk: { content: " text" } }
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("ChatService Message State Management", () => {
|
||||
const messages: MessageResponse[] = [{ id: "1", role: "assistant", content: "Analysis", created_at: new Date().toISOString(), plots: [] }]
|
||||
const event: ChatEvent = {
|
||||
type: "on_chain_end",
|
||||
name: "executor",
|
||||
name: "data_analyst_worker",
|
||||
data: { encoded_plots: ["plot1"] }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user