Skip to content

Commit

Permalink
update chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Qadri authored and Ahmed Qadri committed Feb 9, 2025
1 parent a7fb660 commit dd99af9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/demo_provisioning_scripts/DemoBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ def create_togglebot_ai_config(self):
},
[
{
"content": "As an AI bot for a banking site ToggleBank, your purpose is to answer questions related to banking services and financial products. Act as a customer representative. Only answer queries related to banking and finance. Remove quotation in response. Limit response to 20 words. Do not exceed this limit and do not specify any limits in responses. Here is the user prompt: ${userInput}.",
"content": "You are an AI assistant for ToggleBank, providing expert guidance on banking services and financial products. Act as a professional customer representative. Only respond to banking and finance-related queries.\n\n- Response Format:\n - Keep answers concise (maximum 20 words).\n - Do not include quotations in responses.\n - Avoid mentioning response limitations.\n\nUser Context:\n- City: {{ ldctx.location }}\n- Account Tier: {{ ldctx.user.tier }}\n- User Name: {{ ldctx.user.name }}\n\nUser Query: {{ userInput }}",
"role": "system"
}
]
Expand All @@ -990,7 +990,7 @@ def create_togglebot_ai_config(self):
},
[
{
"content": "As an AI bot for a banking site ToggleBank, your purpose is to answer questions related to banking services and financial products. Act as a customer representative. Only answer queries related to banking and finance. Remove quotation in response. Limit response to 20 words. Do not exceed this limit and do not specify any limits in responses. Here is the user prompt: ${userInput}.",
"content": "You are an AI assistant for ToggleBank, providing expert guidance on banking services and financial products. Act as a professional customer representative. Only respond to banking and finance-related queries.\n\n- Response Format:\n - Keep answers concise (maximum 20 words).\n - Do not include quotations in responses.\n - Avoid mentioning response limitations.\n\nUser Context:\n- City: {{ ldctx.location }}\n- Account Tier: {{ ldctx.user.tier }}\n- User Name: {{ ldctx.user.name }}\n\nUser Query: {{ userInput }}",
"role": "system"
}
]
Expand Down
5 changes: 2 additions & 3 deletions pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default async function chatResponse(
): Message[] {
return prompt.map((item) => ({
role: item.role !== 'system' ? item.role : 'user',
content: [{ text: item.content.replace('${userInput}', userInput) }],
content: [{ text: item.content }],
}));
}

Expand All @@ -49,8 +49,7 @@ export default async function chatResponse(
key: uuidv4(),
};

const aiConfig = await aiClient.config(aiConfigKey, context, {}, {});
console.log("AI Config:", aiConfig);
const aiConfig = await aiClient.config(aiConfigKey, context, {}, {userInput: userInput});
if (!aiConfig.enabled) {
throw new Error("AI config is disabled");
} else {
Expand Down
2 changes: 1 addition & 1 deletion utils/contexts/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const [userObject, setUserObject] = useState<Persona | {}>({});
const osOptions = context.user.device === "Mobile" ? ["iOS", "Android"] : ["macOS", "Windows"];
context.user.operating_system = osOptions[Math.floor(Math.random() * osOptions.length)];
context.user.location = `America/${["New_York", "Chicago", "Los_Angeles", "Denver"][Math.floor(Math.random() * 4)]}`;
context.user.tier = ["Gold", "Silver", "Platinum"][Math.floor(Math.random() * 3)];
context.user.tier = ["Gold", "Silver", "Platinum", "Standard"][Math.floor(Math.random() * 3)];
context.user.anonymous = false;
setAppMultiContext(context);
setCookie(LD_CONTEXT_COOKIE_KEY, context);
Expand Down

0 comments on commit dd99af9

Please sign in to comment.