@@ -75,7 +75,6 @@ const ChatContext = createContext<{
7575 groupIds ?: string [ ] ,
7676 systemPrompt ?: string ,
7777 displayUserMessage ?: boolean ,
78- imageUrl ?: string ,
7978 ) => Promise < void > ;
8079 isLoading : boolean ;
8180 loadingText : string ;
@@ -140,8 +139,6 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
140139 const [ productsWithClicks , setProductsWithClicks ] = useState <
141140 ChunkIdWithIndex [ ]
142141 > ( [ ] ) ;
143- let localImageUrl = imageUrl ;
144-
145142
146143 const createTopic = async ( {
147144 question,
@@ -523,6 +520,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
523520 let referenceImageUrls : string [ ] = [ ] ;
524521 let referenceChunks : Chunk [ ] = [ ] ;
525522
523+
526524 if ( ! groupIds || groupIds . length === 0 ) {
527525 chatMessageAbortController . current = new AbortController ( ) ;
528526 const toolCallTimeout = setTimeout (
@@ -542,7 +540,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
542540 if ( props . type === "ecommerce" && ! curGroup ) {
543541 return await trieveSDK . getToolCallFunctionParams ( {
544542 user_message_text : questionProp || currentQuestion ,
545- image_url : localImageUrl ? localImageUrl : null ,
543+ image_url : imageUrl ? imageUrl : null ,
546544 audio_input : curAudioBase64 ? curAudioBase64 : null ,
547545 tool_function : {
548546 name : "get_price_filters" ,
@@ -602,7 +600,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
602600 }
603601 } ,
604602 ) } \n\n${ props . searchToolCallOptions ?. userMessageTextPrefix ?? defaultSearchToolCallOptions . userMessageTextPrefix } : ${ questionProp || currentQuestion } .`,
605- image_url : localImageUrl ? localImageUrl : null ,
603+ image_url : imageUrl ? imageUrl : null ,
606604 audio_input : curAudioBase64 ? curAudioBase64 : null ,
607605 tool_function : {
608606 name : "skip_search" ,
@@ -623,10 +621,10 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
623621 } )
624622
625623 const imageFiltersPromise = retryOperation ( async ( ) => {
626- if ( localImageUrl ) {
624+ if ( imageUrl ) {
627625 return await trieveSDK . getToolCallFunctionParams ( {
628626 user_message_text : questionProp || currentQuestion ,
629- image_url : localImageUrl ? localImageUrl : null ,
627+ image_url : imageUrl ? imageUrl : null ,
630628 tool_function : {
631629 name : "get_image_filters" ,
632630 description :
@@ -667,7 +665,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
667665 ( message ) => `\n\n${ message . text } ` ,
668666 ) } \n\n ${ questionProp || currentQuestion } `
669667 : null ,
670- image_url : localImageUrl ? localImageUrl : null ,
668+ image_url : imageUrl ? imageUrl : null ,
671669 audio_input : curAudioBase64 ? curAudioBase64 : null ,
672670 tool_function : {
673671 name : "get_filters" ,
@@ -717,7 +715,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
717715 text : transcribedQuery ?? "" ,
718716 additional : null ,
719717 queryId : null ,
720- imageUrl : localImageUrl ? localImageUrl : null ,
718+ imageUrl : imageUrl ? imageUrl : null ,
721719 } ,
722720 {
723721 type : "system" ,
@@ -730,7 +728,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
730728 }
731729
732730 useImage = ( imageFiltersResp ?. parameters &&
733- ( imageFiltersResp . parameters as any ) [ "image" ] === true && localImageUrl ) as boolean ;
731+ ( imageFiltersResp . parameters as any ) [ "image" ] === true && imageUrl ) as boolean ;
734732
735733 const match_any_tags = [ ] ;
736734 if ( tagFiltersResp ?. parameters ) {
@@ -1059,6 +1057,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
10591057 }
10601058
10611059 const handleImageEdit = async ( ) => {
1060+ console . log ( "REFERENCE IMAGE URLS" , referenceImageUrls ) ;
10621061 if ( useImage ) {
10631062 setLoadingText ( "Editing image..." ) ;
10641063
@@ -1067,7 +1066,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
10671066 input_images : [
10681067 {
10691068 image_src : {
1070- url : localImageUrl ,
1069+ url : imageUrl ,
10711070 } ,
10721071 file_name : "input_image" ,
10731072 } ,
@@ -1303,13 +1302,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
13031302 groupIds ?: string [ ] ,
13041303 systemPrompt ?: string ,
13051304 displayUserMessage ?: boolean ,
1306- imageUrl ?: string ,
13071305 ) => {
1308- if ( imageUrl ) {
1309- localImageUrl = imageUrl ;
1310- setImageUrl ( imageUrl ) ;
1311- }
1312-
13131306 const questionProp = question ;
13141307 setIsDoneReading ( false ) ;
13151308 setCurrentQuestion ( "" ) ;
@@ -1363,7 +1356,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
13631356 ( displayUserMessage ?? true ) ? questionProp || currentQuestion : "" ,
13641357 additional : null ,
13651358 queryId : null ,
1366- imageUrl : localImageUrl ? localImageUrl : null ,
1359+ imageUrl : imageUrl ? imageUrl : null ,
13671360 } ,
13681361 {
13691362 type : "system" ,
@@ -1380,7 +1373,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
13801373 text : "Loading..." ,
13811374 additional : null ,
13821375 queryId : null ,
1383- imageUrl : localImageUrl ? localImageUrl : null ,
1376+ imageUrl : imageUrl ? imageUrl : null ,
13841377 } ,
13851378 {
13861379 type : "system" ,
@@ -1406,7 +1399,6 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
14061399 systemPrompt,
14071400 } ) ;
14081401 }
1409- setImageUrl ( "" ) ;
14101402 } ;
14111403
14121404 const switchToChatAndAskQuestion = async ( query : string ) => {
0 commit comments