Skip to content

Commit 27fdb88

Browse files
committed
experiment works
1 parent 84e0475 commit 27fdb88

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

components/chatbot/ChatBot.tsx

+36-39
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ export default function Chatbot() {
4545
const response = await fetch("/api/chat", {
4646
method: "POST",
4747
body: JSON.stringify(`
48-
48+
As an AI bot for a travel airline,
49+
your purpose is to answer questions related to flights and traveling.
50+
Act as customer representative.
51+
Only answer queries related to traveling and airlines.
52+
Remove quotation in response.
4953
Limit response to 100 characters.
5054
Here is the user prompt: ${userInput}.`),
5155
});
5256

53-
// As an AI bot for a travel airline,
54-
// your purpose is to answer questions related to flights and traveling.
55-
// Act as customer representative.
56-
// Only answer queries related to traveling and airlines.
57-
// Remove quotation in response.
5857

5958

6059
const data = await response.json();
@@ -74,7 +73,6 @@ export default function Chatbot() {
7473
content: aiAnswer,
7574
id: uuidv4().slice(0, 4),
7675
};
77-
//TODO: remove loader if you get don't aiAnswer
7876

7977
if(aiAnswer === undefined){
8078
assistantMessage.content = "I'm sorry. Please try again."
@@ -90,10 +88,11 @@ export default function Chatbot() {
9088
useEffect(() => {
9189
console.log("aiChatBot",flags["ai-chatbot"])
9290
console.log(messages);
93-
console.log("aiChaaweftBot",client?.getContext());
9491
}, [messages]);
9592

96-
const surveyResponseNotification = () => {
93+
const surveyResponseNotification = (surveyResponse:string) => {
94+
client?.track(surveyResponse, client.getContext());
95+
client?.flush();
9796
toast({
9897
title: `Thank you for your response!`,
9998
wrapperStyle: "bg-green-600 text-white font-sohne text-base border-none",
@@ -135,34 +134,32 @@ export default function Chatbot() {
135134
title="How was our service today?"
136135
className="rounded-full bg-[#55efc4] text-gray-900 hover:bg-[#00b894] dark:bg-[#55efc4] dark:text-gray-900 dark:hover:bg-[#00b894]"
137136
onClick={() => {
138-
surveyResponseNotification();
139-
client?.track("ai-chatbot-good-service", client.getContext());
137+
surveyResponseNotification("AI chatbot good service");
140138
}}
141139
>
142140
<SmileIcon className="h-6 w-6" />
143141
<span className="sr-only">Good</span>
144142
</Button>
145-
<Button
143+
{/* <Button
146144
variant="ghost"
147145
size="icon"
148146
title="How was our service today?"
149147
className="rounded-full bg-[#ffeaa7] text-gray-900 hover:bg-[#fdcb6e] dark:bg-[#ffeaa7] dark:text-gray-900 dark:hover:bg-[#fdcb6e]"
150-
onClick={() => {
151-
surveyResponseNotification();
152-
client?.track("ai-chatbot-neutral-service", client.getContext());
148+
onClick={(e) => {
149+
surveyResponseNotification("AI Chatbot Netural Service");
150+
// client?.track("ai-chatbot-neutral-service", client.getContext());
153151
}}
154152
>
155153
<MehIcon className="h-6 w-6" />
156154
<span className="sr-only">Neutral</span>
157-
</Button>
155+
</Button> */}
158156
<Button
159157
variant="ghost"
160158
size="icon"
161159
title="How was our service today?"
162160
className="rounded-full bg-[#ff7675] text-gray-50 hover:bg-[#d63031] dark:bg-[#ff7675] dark:text-gray-50 dark:hover:bg-[#d63031]"
163161
onClick={() => {
164-
surveyResponseNotification();
165-
client?.track("ai-chatbot-bad-service", client.getContext());
162+
surveyResponseNotification("AI Chatbot Bad Service");
166163
}}
167164
>
168165
<FrownIcon className="h-6 w-6" />
@@ -347,24 +344,24 @@ function FrownIcon(props) {
347344
);
348345
}
349346

350-
function MehIcon(props) {
351-
return (
352-
<svg
353-
{...props}
354-
xmlns="http://www.w3.org/2000/svg"
355-
width="24"
356-
height="24"
357-
viewBox="0 0 24 24"
358-
fill="none"
359-
stroke="currentColor"
360-
strokeWidth="2"
361-
strokeLinecap="round"
362-
strokeLinejoin="round"
363-
>
364-
<circle cx="12" cy="12" r="10" />
365-
<line x1="8" x2="16" y1="15" y2="15" />
366-
<line x1="9" x2="9.01" y1="9" y2="9" />
367-
<line x1="15" x2="15.01" y1="9" y2="9" />
368-
</svg>
369-
);
370-
}
347+
// function MehIcon(props) {
348+
// return (
349+
// <svg
350+
// {...props}
351+
// xmlns="http://www.w3.org/2000/svg"
352+
// width="24"
353+
// height="24"
354+
// viewBox="0 0 24 24"
355+
// fill="none"
356+
// stroke="currentColor"
357+
// strokeWidth="2"
358+
// strokeLinecap="round"
359+
// strokeLinejoin="round"
360+
// >
361+
// <circle cx="12" cy="12" r="10" />
362+
// <line x1="8" x2="16" y1="15" y2="15" />
363+
// <line x1="9" x2="9.01" y1="9" y2="9" />
364+
// <line x1="15" x2="15.01" y1="9" y2="9" />
365+
// </svg>
366+
// );
367+
// }

pages/api/chat.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { getCookie } from "cookies-next";
2222
// export const runtime = "edge";
2323
import { LD_CONTEXT_COOKIE_KEY } from "@/utils/constants";
2424
import { v4 as uuidv4 } from "uuid";
25-
import { cookies } from "next/headers";
2625

2726
//https://sdk.vercel.ai/providers/legacy-providers/aws-bedrock
2827
export default async function chatResponse(req: NextApiRequest, res: NextApiResponse) {

0 commit comments

Comments
 (0)