@@ -4,9 +4,10 @@ import { FileImageFill, FileTextFill, Paperclip, Send, StopCircleFill } from 're
4
4
import useIDB from "../../utils/idb" ;
5
5
import { isModelLoaded , loadModel } from '../../utils/workers/worker'
6
6
import { getCompletionFunctions } from "../../utils/workers" ;
7
- import { setClient } from "../../utils/workers/aws-worker" ;
7
+ import { setClient as setAwsClient } from "../../utils/workers/aws-worker" ;
8
+ import { setClient as setOpenaiClient } from "../../utils/workers/openai-worker" ;
8
9
9
- export default function Conversation ( { uid, client } ) {
10
+ export default function Conversation ( { uid, client, updateClient } ) {
10
11
11
12
const [ conversation , setConversation ] = useState ( [ ] ) ;
12
13
const [ message , setMessage ] = useState ( '' ) ;
@@ -130,15 +131,21 @@ export default function Conversation({ uid, client }) {
130
131
useEffect ( ( ) => {
131
132
if ( ! chat_functions . current ) return ;
132
133
133
- if ( chat_functions . current . platform === 'AWS' ) {
134
+ const platform = chat_functions . current . platform
135
+ if ( platform ) {
134
136
( async function ( ) {
135
- if ( await setClient ( client ) ) {
136
- await idb . updateOne ( 'chat-history' , { client} , [ { uid} ] )
137
+ let set_result =
138
+ platform === "AWS" ? await setAwsClient ( client ) :
139
+ platform === "OpenAI" ? await setOpenaiClient ( client ) :
140
+ null ;
141
+
142
+ if ( set_result ) {
143
+ updateClient ( set_result ) ;
137
144
}
138
145
} ) ( )
139
146
}
140
147
// eslint-disable-next-line
141
- } , [ chat_functions , client ] )
148
+ } , [ client ] )
142
149
143
150
return (
144
151
< div className = "conversation-main" >
0 commit comments