MCPcopy Create free account
hub / github.com/Azure-Samples/llama-index-python / ChatSection

Function ChatSection

frontend/app/components/chat-section.tsx:7–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { useClientConfig } from "./ui/chat/hooks/use-config";
6
7export default function ChatSection() {
8 const { chatAPI } = useClientConfig();
9 const {
10 messages,
11 input,
12 isLoading,
13 handleSubmit,
14 handleInputChange,
15 reload,
16 stop,
17 append,
18 setInput,
19 } = useChat({
20 api: chatAPI,
21 headers: {
22 "Content-Type": "application/json", // using JSON because of vercel/ai 2.2.26
23 },
24 onError: (error: unknown) => {
25 if (!(error instanceof Error)) throw error;
26 const message = JSON.parse(error.message);
27 alert(message.detail);
28 },
29 });
30
31 return (
32 <div className="space-y-4 w-full h-full flex flex-col">
33 <ChatMessages
34 messages={messages}
35 isLoading={isLoading}
36 reload={reload}
37 stop={stop}
38 append={append}
39 />
40 <ChatInput
41 input={input}
42 handleSubmit={handleSubmit}
43 handleInputChange={handleInputChange}
44 isLoading={isLoading}
45 messages={messages}
46 append={append}
47 setInput={setInput}
48 />
49 </div>
50 );
51}

Callers

nothing calls this directly

Calls 1

useClientConfigFunction · 0.90

Tested by

no test coverage detected