11'use client' ;
2- import { Button } from '@/components/ui/button' ;
3- import { Input } from '@/components/ui/input' ;
4- import { Message } from 'langbase' ;
5- import { usePipe } from 'langbase/react' ;
6- import React , { useCallback } from 'react' ;
2+ import { Button } from '@/components/ui/button' ;
3+ import { Input } from '@/components/ui/input' ;
4+ import { Message } from 'langbase' ;
5+ import { usePipe } from 'langbase/react' ;
6+ import React , { useCallback } from 'react' ;
77
88const ChatAdvanced : React . FC = ( ) => {
9- const handleResponse = useCallback (
10- ( message : Message ) => {
11- console . log (
12- 'Received response:' ,
13- message . content ?. slice ( 0 , 50 ) + '...' ,
14- ) ;
15- } ,
16- [ ] ,
17- ) ;
9+ const handleResponse = useCallback ( ( message : Message ) => {
10+ console . log (
11+ 'Received response:' ,
12+ message . content ?. slice ( 0 , 50 ) + '...' ,
13+ ) ;
14+ } , [ ] ) ;
1815
19- const handleFinish = useCallback (
20- ( messages : Message [ ] ) => {
21- console . log (
22- `Conversation finished. Total messages: ${ messages . length } ` ,
23- ) ;
24- } ,
25- [ ] ,
26- ) ;
16+ const handleFinish = useCallback ( ( messages : Message [ ] ) => {
17+ console . log (
18+ `Conversation finished. Total messages: ${ messages . length } ` ,
19+ ) ;
20+ } , [ ] ) ;
2721
2822 const handleError = useCallback ( ( error : Error ) => {
2923 console . error ( 'An error occurred:' , error ) ;
@@ -62,14 +56,14 @@ const ChatAdvanced: React.FC = () => {
6256
6357 const handleRegenerateWithOptions = ( ) => {
6458 regenerate ( {
65- headers : { 'Custom-Header' : 'Regenerate' } ,
66- body : { customOption : 'regenerateValue' } ,
59+ headers : { 'Custom-Header' : 'Regenerate' } ,
60+ body : { customOption : 'regenerateValue' } ,
6761 } ) ;
6862 } ;
6963
7064 const handleCustomMessage = ( ) => {
7165 sendMessage ( 'This is a custom message' , {
72- data : { context : 'custom context' } ,
66+ data : { context : 'custom context' } ,
7367 allowEmptySubmit : false ,
7468 } ) ;
7569 } ;
@@ -83,8 +77,9 @@ const ChatAdvanced: React.FC = () => {
8377 { messages . map ( ( m , index ) => (
8478 < div
8579 key = { index }
86- className = { `p-2 rounded ${ m . role === 'user' ? 'bg-indigo-200' : 'bg-gray-100'
87- } `}
80+ className = { `p-2 rounded ${
81+ m . role === 'user' ? 'bg-indigo-200' : 'bg-gray-100'
82+ } `}
8883 >
8984 < strong > { m . role === 'user' ? 'You: ' : 'AI: ' } </ strong >
9085 { m . content }
@@ -133,7 +128,7 @@ const ChatAdvanced: React.FC = () => {
133128 </ div >
134129
135130 < form
136- onSubmit = { e => handleSubmit ( e , { allowEmptySubmit : true } ) }
131+ onSubmit = { e => handleSubmit ( e , { allowEmptySubmit : true } ) }
137132 className = "flex space-x-2"
138133 >
139134 < Input
0 commit comments