@@ -17,10 +17,11 @@ import {
1717 PriceToolCallOptions ,
1818 type Dataset ,
1919 SearchToolCallOptions ,
20+ NotFilterToolCallOptions ,
2021} from "trieve-ts-sdk" ;
2122import { createWebPixel , isWebPixelInstalled } from "app/queries/webPixel" ;
2223import { getAppMetafields , setAppMetafields } from "app/queries/metafield" ;
23- import { useState , useCallback , ReactNode , useEffect } from "react" ;
24+ import { useState , useCallback , ReactNode } from "react" ;
2425import { LLMSettings } from "app/components/settings/LLMSettings" ;
2526import {
2627 PresetQuestion ,
@@ -41,6 +42,7 @@ export const loader = async ({
4142 relevanceToolCallOptions : RelevanceToolCallOptions | null ;
4243 searchToolCallOptions : SearchToolCallOptions | null ;
4344 priceToolCallOptions : PriceToolCallOptions | null ;
45+ notFilterToolCallOptions : NotFilterToolCallOptions | null ;
4446} > => {
4547 const { session } = await authenticate . admin ( request ) ;
4648 const key = await validateTrieveAuth ( request ) ;
@@ -95,6 +97,11 @@ export const loader = async ({
9597 fetcher ,
9698 "price_tool_call_options" ,
9799 ) ;
100+ const notFilterToolCallOptions =
101+ await getAppMetafields < NotFilterToolCallOptions > (
102+ fetcher ,
103+ "not_filter_tool_call_options" ,
104+ ) ;
98105
99106 return {
100107 crawlSettings : crawlSettings ?. crawlSettings ,
@@ -105,6 +112,7 @@ export const loader = async ({
105112 relevanceToolCallOptions,
106113 searchToolCallOptions,
107114 priceToolCallOptions,
115+ notFilterToolCallOptions,
108116 } ;
109117} ;
110118
@@ -213,6 +221,9 @@ export const action = async ({ request }: ActionFunctionArgs) => {
213221 ) ;
214222 const priceToolCallOptions = formData . get ( "price_tool_call_options" ) ;
215223 const searchToolCallOptions = formData . get ( "search_tool_call_options" ) ;
224+ const notFilterToolCallOptions = formData . get (
225+ "not_filter_tool_call_options" ,
226+ ) ;
216227 await setAppMetafields ( fetcher , [
217228 {
218229 key : "relevance_tool_call_options" ,
@@ -229,6 +240,11 @@ export const action = async ({ request }: ActionFunctionArgs) => {
229240 value : searchToolCallOptions as string ,
230241 type : "json" ,
231242 } ,
243+ {
244+ key : "not_filter_tool_call_options" ,
245+ value : notFilterToolCallOptions as string ,
246+ type : "json" ,
247+ } ,
232248 ] ) ;
233249 return { success : true } ;
234250 }
@@ -283,27 +299,14 @@ export default function Dataset() {
283299 relevanceToolCallOptions,
284300 searchToolCallOptions,
285301 priceToolCallOptions,
302+ notFilterToolCallOptions,
286303 } = useLoaderData < typeof loader > ( ) ;
287304 const [ selectedTab , setSelectedTab ] = useState ( 0 ) ;
288305
289- const handleTabChange = useCallback ( ( selectedTabIndex : number ) => {
290- const params = new URLSearchParams ( window . location . search ) ;
291- params . set ( "tab" , tabs [ selectedTabIndex ] . id ) ;
292- window . history . pushState (
293- { } ,
294- "" ,
295- `${ window . location . pathname } ?${ params . toString ( ) } ` ,
296- ) ;
297- setSelectedTab ( selectedTabIndex ) ;
298- } , [ ] ) ;
299-
300- useEffect ( ( ) => {
301- const params = new URLSearchParams ( window . location . search ) ;
302- const tab = params . get ( "tab" ) ;
303- if ( tab ) {
304- setSelectedTab ( tabs . findIndex ( ( t ) => t . id === tab ) ) ;
305- }
306- } , [ ] ) ;
306+ const handleTabChange = useCallback (
307+ ( selectedTabIndex : number ) => setSelectedTab ( selectedTabIndex ) ,
308+ [ ] ,
309+ ) ;
307310
308311 const tabs = [
309312 {
@@ -362,14 +365,13 @@ export default function Dataset() {
362365 existingRelevanceToolCallOptions = { relevanceToolCallOptions }
363366 existingSearchToolCallOptions = { searchToolCallOptions }
364367 existingPriceToolCallOptions = { priceToolCallOptions }
368+ existingNotFilterToolCallOptions = { notFilterToolCallOptions }
365369 />
366370 ) ,
367371 "preset-questions" : < PresetQuestions initialQuestions = { presetQuestions } /> ,
368372 "filter-settings" : < FilterSettings /> ,
369373 "integrations-settings" : < IntegrationsSettings /> ,
370- "extra-information" : (
371- < PolicySettings shopDataset = { shopDataset as Dataset } />
372- ) ,
374+ "extra-information" : < PolicySettings shopDataset = { shopDataset as Dataset } /> ,
373375 } ;
374376
375377 return (
@@ -381,4 +383,4 @@ export default function Dataset() {
381383 </ Card >
382384 </ Box >
383385 ) ;
384- }
386+ }
0 commit comments