Skip to content

Commit 49056a1

Browse files
skeptrunedevcdxker
authored andcommitted
bugfix(shoify): cannot export from components, move export to utils
1 parent 0e1dcc6 commit 49056a1

4 files changed

Lines changed: 16 additions & 22 deletions

File tree

clients/trieve-shopify-extension/app/auth.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { getTrieveBaseUrlEnv } from "./env.server";
66
import { buildAdminApiFetcherForServer } from "./loaders/serverLoader";
77
import { AdminApiCaller } from "./loaders";
88
import { AppInstallData } from "./routes/app.setup";
9-
import {
10-
DEFAULT_RAG_PROMPT,
11-
DEFAULT_SYSTEM_PROMPT,
12-
} from "./components/onboarding/SetPromptsOnboarding";
13-
import { k } from "node_modules/vite/dist/node/types.d-aGj9QkWt";
9+
import { DEFAULT_RAG_PROMPT, DEFAULT_SYSTEM_PROMPT } from "./utils/onboarding";
1410

1511
export const validateTrieveAuth = async <S extends boolean = true>(
1612
request: LoaderFunctionArgs["request"],

clients/trieve-shopify-extension/app/components/onboarding/SetPromptsOnboarding.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@ import {
66
} from "@tanstack/react-query";
77
import { useTrieve } from "app/context/trieveContext";
88
import { shopDatasetQuery } from "app/queries/shopDataset";
9-
import { OnboardingBody } from "app/utils/onboarding";
9+
import { DEFAULT_RAG_PROMPT, DEFAULT_SYSTEM_PROMPT, OnboardingBody } from "app/utils/onboarding";
1010
import { FormEvent, useEffect, useMemo, useState } from "react";
1111
import { DatasetConfig } from "../DatasetSettings";
1212
import { withSuspense } from "app/utils/suspense";
1313
import { trackCustomerEvent } from "app/processors/shopifyTrackers";
1414

15-
export const DEFAULT_SYSTEM_PROMPT =
16-
"[[personality]]\nYou are a friendly, helpful, and knowledgeable ecommerce sales associate. Your communication style is warm, patient, and enthusiastic without being pushy. You're approachable and conversational while maintaining professionalism. You balance being personable with being efficient, understanding that customers value both connection and their time. You're solution-oriented and genuinely interested in helping customers find the right products for their needs.\n\n[[goal]]\nYour primary goal is to help customers find products that genuinely meet their needs while providing an exceptional shopping experience. You aim to:\n1. Understand customer requirements through thoughtful questions\n2. Provide relevant product recommendations based on customer preferences\n3. Offer detailed, accurate information about products\n4. Address customer concerns and objections respectfully\n5. Guide customers through the purchasing process\n6. Encourage sales without being pushy or manipulative\n7. Create a positive impression that builds long-term customer loyalty\n\n[[response structure]]\n1. Begin with a warm greeting and acknowledgment of the customer's query or concern\n2. Ask clarifying questions if needed to better understand their requirements\n3. Provide concise, relevant information that directly addresses their needs\n4. Include specific product recommendations when appropriate, with brief explanations of why they might be suitable\n5. Address any potential concerns proactively\n6. Close with a helpful next step or question that moves the conversation forward\n7. Keep responses conversational yet efficient, balancing thoroughness with respect for the customer's time.\n";
17-
18-
export const DEFAULT_RAG_PROMPT =
19-
"You may use the retrieved context to help you respond. When discussing products, prioritize information from the provided product data while using your general knowledge to create helpful, natural responses. If a customer asks about products or specifications not mentioned in the context, acknowledge the limitation and offer to check for more information rather than inventing details.";
20-
2115
export const SetPromptsOnboarding: OnboardingBody = withSuspense(
2216
({ broadcastCompletion, goToNextStep }) => {
2317
const { trieve, organization, trieveKey } = useTrieve();

clients/trieve-shopify-extension/app/queries/onboarding.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,14 @@ export const lastStepIdQuery = (fetcher: AdminApiCaller) => {
143143
queryKey: ["last_step_id"],
144144
queryFn: async () => {
145145
const result = await getMetafield(fetcher, ONBOARD_STEP_META_FIELD);
146-
if (!result || result.error || !result.data) {
146+
if (
147+
!result ||
148+
result.error ||
149+
!result.data ||
150+
!onboardingSteps.some((s) => s.id === result.data)
151+
) {
147152
return onboardingSteps[0].id;
148153
}
149-
if (!onboardingSteps.some((s) => s.id === result.data)) {
150-
return onboardingSteps[0].id;
151-
}
152-
if (result.data === "null") {
153-
return null;
154-
}
155154
return result.data;
156155
},
157156
};

clients/trieve-shopify-extension/app/utils/onboarding.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import {
1515
} from "app/queries/onboarding";
1616
import { FC, useCallback, useEffect, useMemo, useState } from "react";
1717

18+
export const DEFAULT_SYSTEM_PROMPT =
19+
"[[personality]]\nYou are a friendly, helpful, and knowledgeable ecommerce sales associate. Your communication style is warm, patient, and enthusiastic without being pushy. You're approachable and conversational while maintaining professionalism. You balance being personable with being efficient, understanding that customers value both connection and their time. You're solution-oriented and genuinely interested in helping customers find the right products for their needs.\n\n[[goal]]\nYour primary goal is to help customers find products that genuinely meet their needs while providing an exceptional shopping experience. You aim to:\n1. Understand customer requirements through thoughtful questions\n2. Provide relevant product recommendations based on customer preferences\n3. Offer detailed, accurate information about products\n4. Address customer concerns and objections respectfully\n5. Guide customers through the purchasing process\n6. Encourage sales without being pushy or manipulative\n7. Create a positive impression that builds long-term customer loyalty\n\n[[response structure]]\n1. Begin with a warm greeting and acknowledgment of the customer's query or concern\n2. Ask clarifying questions if needed to better understand their requirements\n3. Provide concise, relevant information that directly addresses their needs\n4. Include specific product recommendations when appropriate, with brief explanations of why they might be suitable\n5. Address any potential concerns proactively\n6. Close with a helpful next step or question that moves the conversation forward\n7. Keep responses conversational yet efficient, balancing thoroughness with respect for the customer's time.\n";
20+
21+
export const DEFAULT_RAG_PROMPT =
22+
"You may use the retrieved context to help you respond. When discussing products, prioritize information from the provided product data while using your general knowledge to create helpful, natural responses. If a customer asks about products or specifications not mentioned in the context, acknowledge the limitation and offer to check for more information rather than inventing details.";
23+
1824
export type OnboardingBody = FC<{
1925
goToNextStep: () => void;
2026
goToPreviousStep: () => void;
@@ -34,7 +40,7 @@ type OnboardingStep = {
3440

3541
export const onboardingSteps: OnboardingStep[] = [
3642
{
37-
id: "set-chat-messages",
43+
id: "set-ai-prompts",
3844
title: "Customize AI Prompts",
3945
defaultComplete: false,
4046
body: SetPromptsOnboarding,
@@ -50,7 +56,6 @@ export const onboardingSteps: OnboardingStep[] = [
5056
},
5157
},
5258
{
53-
// Name in a way that changing the step + adding more will not require id rename
5459
id: "after-welcome",
5560
title: "Add the widgets to your site",
5661
body: AddComponentOnboarding,
@@ -81,7 +86,7 @@ export const useOnboarding = () => {
8186
>(
8287
onboardingSteps.reduce(
8388
(acc, step) => {
84-
acc[step.id] = step.defaultComplete || false;
89+
acc[step.id] = step.defaultComplete ?? false;
8590
return acc;
8691
},
8792
{} as Record<string, boolean>,

0 commit comments

Comments
 (0)