Skip to content

Commit 10df80b

Browse files
committed
add conversation ID
1 parent 1508ed4 commit 10df80b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

chat-ui/.env.qa

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_SERVER_BASE_URL=https://chat-qa.docs.staging.corp.mongodb.com/api/v1
2+
VITE_QA=true

chat-ui/src/Chatbot.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Badge from "@leafygreen-ui/badge";
44
import Banner from "@leafygreen-ui/banner";
55
// import Card from "@leafygreen-ui/card";
66
import Box from "@leafygreen-ui/box";
7-
import { Subtitle, Body, Link } from "@leafygreen-ui/typography";
7+
import { Subtitle, Body, Link, InlineCode } from "@leafygreen-ui/typography";
88
import useConversation, { Conversation } from "./useConversation";
99
import { CSSTransition } from "react-transition-group";
1010
import { useClickAway } from "@uidotdev/usehooks";
@@ -44,7 +44,7 @@ function ErrorBanner() {
4444
return (
4545
<Banner className={styles.lg_banner} variant="danger">
4646
Something went wrong. Try reloading the page and starting a new
47-
conversation.
47+
conversation.
4848
</Banner>
4949
);
5050
}
@@ -58,6 +58,16 @@ function VerifyInformationBanner() {
5858
);
5959
}
6060

61+
function ConversationIdInfo({ conversation }: { conversation: Conversation }) {
62+
return import.meta.env.VITE_QA ? (
63+
<div>
64+
<Body>
65+
Conversation ID: <InlineCode>{conversation.conversationId}</InlineCode>
66+
</Body>
67+
</div>
68+
) : null;
69+
}
70+
6171
type CTACardProps = {
6272
active: boolean;
6373
cardRef: React.RefObject<HTMLDivElement>;
@@ -96,6 +106,7 @@ function CTACard({
96106
<Box ref={cardRef} className={styles.card}>
97107
{active && !isEmptyConversation ? (
98108
<>
109+
<ConversationIdInfo conversation={conversation} />
99110
<div className={styles.card_content_title}>
100111
<Subtitle>MongoDB AI</Subtitle>
101112
<Badge variant="blue">Experimental</Badge>
@@ -112,7 +123,8 @@ function CTACard({
112123
<MessageList>
113124
{conversation.messages.map((message) => {
114125
const showLoadingSkeleton = conversation.isStreamingMessage
115-
? message.id === conversation.streamingMessage?.id && conversation.streamingMessage?.content === ""
126+
? message.id === conversation.streamingMessage?.id &&
127+
conversation.streamingMessage?.content === ""
116128
: awaitingReply;
117129
return showLoadingSkeleton ? (
118130
<Message key={message.id} role="assistant">
@@ -131,7 +143,7 @@ function CTACard({
131143
) : null}
132144

133145
{active && conversation.error ? <ErrorBanner /> : null}
134-
146+
135147
{active ? <VerifyInformationBanner /> : null}
136148

137149
{!active || !conversation.error ? (

chat-ui/src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference types="vite/client" />
22
interface ImportMetaEnv {
33
readonly VITE_SERVER_BASE_URL: string;
4+
readonly VITE_QA: string?;
45
// more env variables...
56
}
67

0 commit comments

Comments
 (0)