mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 23:46:18 -05:00
ai: the Chat tab — SSE streaming chat with modes
The app's first streaming client: sse.js reads the /api/chat POST body with fetch + a stream reader (apiCall's 60s JSON path cannot stream), parsing SSE events with abort support. AiChatContext holds the conversation (browser-only, per design) so it survives visiting the Manage tab; switching modes starts a fresh conversation. The Chat tab has the three-button mode picker, per-mode suggestion chips, streamed answers with clickable relative WROLPi links, tool-activity indicators, a slow-hardware banner, and a "not ready" state pointing at Manage. ChatMessage states are in the theme-sample gallery. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
15552c2da7
commit
a123794f19
6 changed files with 488 additions and 11 deletions
|
|
@ -45,6 +45,7 @@ import {
|
|||
import {paletteColorNames} from '../themes/mantine';
|
||||
import {contrastingColor} from './Common';
|
||||
import {AiModelRow} from './Ai';
|
||||
import {ChatMessage} from './AiChat';
|
||||
import {navBarStyle, navColorNames, useNavColors} from '../themes/navColors';
|
||||
import {IconMenu2} from '@tabler/icons-react';
|
||||
|
||||
|
|
@ -721,6 +722,25 @@ export function ThemeSamplePage() {
|
|||
</Table>
|
||||
</Section>
|
||||
|
||||
<Section label='AI chat'>
|
||||
{/* The real ChatMessage from the AI Chat tab, in each of its states. */}
|
||||
<ChatMessage message={{role: 'user', content: 'Find videos about canning'}}/>
|
||||
<ChatMessage message={{
|
||||
role: 'assistant',
|
||||
content: 'I found one video: Pressure Canning Basics — /videos/123',
|
||||
activity: [{tool: 'search_videos', pending: false, success: true}],
|
||||
}}/>
|
||||
<ChatMessage message={{
|
||||
role: 'assistant', content: '',
|
||||
activity: [{tool: 'search_archives', pending: true}], streaming: true,
|
||||
}}/>
|
||||
<ChatMessage message={{
|
||||
role: 'assistant', content: '',
|
||||
activity: [{tool: 'get_video_captions', pending: false, success: false}],
|
||||
error: 'The AI failed to answer. Check the logs.',
|
||||
}}/>
|
||||
</Section>
|
||||
|
||||
<Section label='Form controls'>
|
||||
<Panel>
|
||||
<div style={{display: 'grid', gridTemplateColumns: '2fr 1fr 1fr', gap: 12}}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue