Skip to content

Commit addba72

Browse files
vid277skeptrunedev
authored andcommitted
feature: add not filter tool options to shopify
1 parent 0c0aa41 commit addba72

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

clients/trieve-shopify-extension/app/components/settings/LLMSettings.tsx

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
PriceToolCallOptions,
2525
RelevanceToolCallOptions,
2626
SearchToolCallOptions,
27+
NotFilterToolCallOptions,
2728
} from "trieve-ts-sdk";
2829

2930
export const defaultRelevanceToolCallOptions: RelevanceToolCallOptions = {
@@ -54,20 +55,28 @@ export const defaultSearchToolCallOptions: SearchToolCallOptions = {
5455
"Call this tool anytime it seems like we need to skip the search step. This tool tells our system that the user is asking about what they were previously shown.",
5556
};
5657

58+
export const defaultNotFilterToolCallOptions: NotFilterToolCallOptions = {
59+
userMessageTextPrefix: "Here is the user query:",
60+
toolDescription:
61+
"Set to true if the query is not interested in the products they were shown previously or would like to see something different. Ensure that this is only set to true when the user wants to see something different from the previously returned results or is not interested in those previously returned results.",
62+
};
63+
5764
interface LLMSettingsProps {
5865
shopDataset: Dataset;
5966
existingPdpPrompt: string;
6067
existingRelevanceToolCallOptions: RelevanceToolCallOptions | null;
6168
existingPriceToolCallOptions: PriceToolCallOptions | null;
6269
existingSearchToolCallOptions: SearchToolCallOptions | null;
70+
existingNotFilterToolCallOptions: NotFilterToolCallOptions | null;
6371
}
6472

6573
export function LLMSettings({
6674
shopDataset,
6775
existingPdpPrompt,
6876
existingRelevanceToolCallOptions,
6977
existingPriceToolCallOptions,
70-
existingSearchToolCallOptions
78+
existingSearchToolCallOptions,
79+
existingNotFilterToolCallOptions,
7180
}: LLMSettingsProps) {
7281
const shopify = useAppBridge();
7382
const submit = useSubmit();
@@ -92,6 +101,10 @@ export function LLMSettings({
92101
existingSearchToolCallOptions ?? defaultSearchToolCallOptions,
93102
);
94103

104+
const [notFilterToolCallOptions, setNotFilterToolCallOptions] = useState(
105+
existingNotFilterToolCallOptions ?? defaultNotFilterToolCallOptions,
106+
);
107+
95108
const onLLMSettingsSave = async () => {
96109
submit(
97110
{
@@ -114,6 +127,7 @@ export function LLMSettings({
114127
relevance_tool_call_options: JSON.stringify(relevanceToolCallOptions),
115128
price_tool_call_options: JSON.stringify(priceToolCallOptions),
116129
search_tool_call_options: JSON.stringify(searchToolCallOptions),
130+
not_filter_tool_call_options: JSON.stringify(notFilterToolCallOptions),
117131
dataset_id: shopDataset.id,
118132
type: "tool_call_options",
119133
},
@@ -518,6 +532,48 @@ export function LLMSettings({
518532
<Button onClick={saveToolCallOptions}>Save</Button>
519533
</InlineStack>
520534
</Card>
535+
<Card roundedAbove="sm">
536+
<BlockStack gap="400">
537+
<FormLayout>
538+
<Text as="h1" variant="headingMd">
539+
Not Filter Tool Configuration
540+
</Text>
541+
<BlockStack gap="400">
542+
<TextField
543+
label="Tool Description"
544+
helpText="The description of the tool"
545+
value={notFilterToolCallOptions.toolDescription ?? ""}
546+
onChange={(e) =>
547+
setNotFilterToolCallOptions({
548+
...notFilterToolCallOptions,
549+
toolDescription: e,
550+
})
551+
}
552+
multiline={3}
553+
autoComplete="off"
554+
/>
555+
<TextField
556+
label="User Message Text Prefix"
557+
helpText="The prefix to use before showing the the users message"
558+
value={
559+
notFilterToolCallOptions.userMessageTextPrefix ?? ""
560+
}
561+
onChange={(e) =>
562+
setNotFilterToolCallOptions({
563+
...notFilterToolCallOptions,
564+
userMessageTextPrefix: e,
565+
})
566+
}
567+
multiline={3}
568+
autoComplete="off"
569+
/>
570+
</BlockStack>
571+
</FormLayout>
572+
</BlockStack>
573+
<InlineStack align="end" gap="200">
574+
<Button onClick={saveToolCallOptions}>Save</Button>
575+
</InlineStack>
576+
</Card>
521577
</BlockStack>
522578
</InlineGrid>
523579
</BlockStack>

clients/trieve-shopify-extension/app/routes/app._dashboard.settings.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
PriceToolCallOptions,
1818
type Dataset,
1919
SearchToolCallOptions,
20+
NotFilterToolCallOptions,
2021
} from "trieve-ts-sdk";
2122
import { createWebPixel, isWebPixelInstalled } from "app/queries/webPixel";
2223
import { getAppMetafields, setAppMetafields } from "app/queries/metafield";
@@ -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,6 +299,7 @@ export default function Dataset() {
283299
relevanceToolCallOptions,
284300
searchToolCallOptions,
285301
priceToolCallOptions,
302+
notFilterToolCallOptions,
286303
} = useLoaderData<typeof loader>();
287304
const [selectedTab, setSelectedTab] = useState(0);
288305

@@ -348,6 +365,7 @@ export default function Dataset() {
348365
existingRelevanceToolCallOptions={relevanceToolCallOptions}
349366
existingSearchToolCallOptions={searchToolCallOptions}
350367
existingPriceToolCallOptions={priceToolCallOptions}
368+
existingNotFilterToolCallOptions={notFilterToolCallOptions}
351369
/>
352370
),
353371
"preset-questions": <PresetQuestions initialQuestions={presetQuestions} />,

0 commit comments

Comments
 (0)