MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / ChatAdvanced

Function ChatAdvanced

examples/remix/app/components/chat-advanced.tsx:6–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { usePipe } from '@baseai/core/react';
5
6const ChatAdvanced: React.FC = () => {
7 const handleResponse = useCallback(
8 (message: { role: string; content: string }) => {
9 console.log(
10 'Received response:',
11 message.content.slice(0, 50) + '...',
12 );
13 },
14 [],
15 );
16
17 const handleFinish = useCallback(
18 (messages: { role: string; content: string }[]) => {
19 console.log(
20 `Conversation finished. Total messages: ${messages.length}`,
21 );
22 },
23 [],
24 );
25
26 const handleError = useCallback((error: Error) => {
27 console.error('An error occurred:', error);
28 }, []);
29
30 const {
31 messages,
32 input,
33 handleInputChange,
34 handleSubmit,
35 isLoading,
36 error,
37 regenerate,
38 stop,
39 setMessages,
40 threadId,
41 sendMessage,
42 } = usePipe({
43 stream: true,
44 apiRoute: '/api/langbase/pipes/run-stream',
45 onResponse: handleResponse,
46 onFinish: handleFinish,
47 onError: handleError,
48 });
49
50 const handleClearChat = () => {
51 setMessages([]);
52 };
53
54 const handleRegenerateWithOptions = () => {
55 regenerate({
56 headers: { 'Custom-Header': 'Regenerate' },
57 body: { customOption: 'regenerateValue' },
58 });
59 };
60
61 const handleCustomMessage = () => {
62 sendMessage('This is a custom message', {
63 data: { context: 'custom context' },

Callers

nothing calls this directly

Calls 3

usePipeFunction · 0.90
logMethod · 0.80
handleSubmitFunction · 0.70

Tested by

no test coverage detected