@@ -14,7 +14,8 @@ import { Checkbox } from "./ui/checkbox";
14
14
// import MyComponent from "./route";
15
15
interface gptargs {
16
16
message ?:FileItem ,
17
- fgptendpoint ?:string
17
+ fgptendpoint ?:string ,
18
+ setasollama :boolean
18
19
// localorremote:boolean
19
20
}
20
21
interface mitem {
@@ -24,12 +25,16 @@ interface mitem{
24
25
timestamp :number
25
26
}
26
27
function getchattime ( ) {
27
- return `${ new Date ( ) . getHours ( ) } :${ new Date ( ) . getMinutes ( ) < 10 ? '0' : '' } ${ new Date ( ) . getMinutes ( ) } `
28
+ return `${ new Date ( ) . getHours ( ) } :${ new Date ( ) . getMinutes ( ) < 10 ? '0' : '' } ${ new Date ( ) . getMinutes ( ) } : ${ new Date ( ) . getSeconds ( ) < 10 ? '0' : '' } ${ new Date ( ) . getSeconds ( ) } `
28
29
}
29
30
function getchattimestamp ( ) {
30
31
return new Date ( ) . getTime ( )
31
32
}
32
- export default function GPTchatinterface ( { message, fgptendpoint= "localhost" } :gptargs ) {
33
+ export default function GPTchatinterface ( { message, fgptendpoint= "localhost" , setasollama= false } :gptargs ) {
34
+ // let sao=(value:boolean)=>{setasollama=value};
35
+ const [ isollama , sao ] = useState ( setasollama )
36
+
37
+ // const [useollama,seto]=useState(setasollama)
33
38
console . log ( "endpoint-->" + fgptendpoint )
34
39
// const [time, setTime] = useState(new Date());
35
40
// useEffect(() => {
@@ -66,27 +71,31 @@ export default function GPTchatinterface({message,fgptendpoint="localhost"}:gpta
66
71
// const [querystring, setqs] = useState([message.path]);
67
72
68
73
const embed = async ( ) => {
69
- // if(localorremote){
70
- try {
71
- const response = await axios . post ( `${ filegptendpoint } /embed` , { files : filePaths } ) ;
72
- setchathistory ( ( old ) => [ ...old , {
73
- from :"bot" ,
74
- message :`${ message ?message . path :"The file(s)" } is ready for your questions` ,
75
- time :getchattime ( ) ,
76
- timestamp :getchattimestamp ( )
77
- } ] )
78
- setcbs ( false )
79
- console . log ( response . data ) ;
80
- } catch ( error ) {
81
- setchathistory ( ( old ) => [ ...old , {
82
- from :"bot" ,
83
- message :`Issue finding Filegpt endpoint, maybe its not be running.` ,
84
- time :getchattime ( ) ,
85
- timestamp :getchattimestamp ( )
86
- } ] )
87
- console . error ( 'Error:' , error ) ;
88
- }
89
- // }
74
+ if ( message . path ) {
75
+ console . log ( "embed" )
76
+ // if(localorremote){
77
+ try {
78
+ const response = await axios . post ( `${ filegptendpoint } /embed` , { files : filePaths } ) ;
79
+ sao ( false )
80
+ setchathistory ( ( old ) => [ ...old , {
81
+ from :"bot" ,
82
+ message :`${ message ?message . path :"The file(s)" } is ready for your questions` ,
83
+ time :getchattime ( ) ,
84
+ timestamp :getchattimestamp ( )
85
+ } ] )
86
+ setcbs ( false )
87
+ console . log ( response . data ) ;
88
+ } catch ( error ) {
89
+ setchathistory ( ( old ) => [ ...old , {
90
+ from :"bot" ,
91
+ message :`Issue finding Filegpt endpoint, maybe its not be running.` ,
92
+ time :getchattime ( ) ,
93
+ timestamp :getchattimestamp ( )
94
+ } ] )
95
+ console . error ( 'Error:' , error ) ;
96
+ }
97
+ // }
98
+ }
90
99
} ;
91
100
//scroll to bottom in chatview
92
101
useEffect ( ( ) => {
@@ -158,7 +167,7 @@ else{
158
167
method : "POST" ,
159
168
body : JSON . stringify ( {
160
169
query :question ,
161
- where :question . toLocaleLowerCase ( ) . startsWith ( "generally" ) ?"ollama" :""
170
+ where :question . toLocaleLowerCase ( ) . startsWith ( "generally" ) || isollama ?"ollama" :""
162
171
} ) ,
163
172
headers : { 'Content-Type' : 'application/json' , Accept : "text/event-stream" } ,
164
173
onopen : async ( res ) => {
@@ -321,6 +330,9 @@ else{
321
330
}
322
331
} , [ cmsg ] )
323
332
const [ autoscroll , setas ] = useState ( false )
333
+ useEffect ( ( ) => {
334
+ console . log ( setasollama )
335
+ } , [ setasollama ] )
324
336
return ( < >
325
337
{ /* <MyComponent/> */ }
326
338
{ /* {time.toLocaleString()} */ }
@@ -329,7 +341,7 @@ else{
329
341
< div className = "flex flex-row p-2 border-2 place-items-center" > { filedimegptisrunning ?< CheckIcon className = "w-4 h-4" /> :< XIcon className = "w-4 h-4" /> } FiledimeGPT</ div >
330
342
</ div >
331
343
{ localorremote ?( < h1 className = "flex flex-row gap-2" > < BotIcon className = "h-4 w-4" /> FileGPT : { message ?message . path :null } </ h1 > ) :( < >
332
- < FileUploadComponent fge = { filegptendpoint } setcmsg = { setcmsg } />
344
+ < FileUploadComponent fge = { filegptendpoint } setcmsg = { setcmsg } setasollama = { sao } />
333
345
</ > ) }
334
346
335
347
< div className = "overflow-auto grid gap-4 p-4 h-[70%] mb-5" >
0 commit comments