Skip to content

Commit a2d41f2

Browse files
author
Harry Li
committed
added icons
1 parent 80d1593 commit a2d41f2

File tree

8 files changed

+111
-19
lines changed

8 files changed

+111
-19
lines changed

src/App.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Chat } from 'components/Chat/Chat';
77
import { DemoModeModal } from 'components/DemoModeModal';
88
import { ErrorMessage } from 'components/ErrorMessage';
99
import { IDTableContainer } from 'components/IDTable/IDTable';
10+
import { InfoModal } from 'components/InfoModal';
11+
import { LLMWarning } from 'components/LLMWarning';
1012
import { QueryEditor } from 'components/QueryEditor/QueryEditor'
1113
import { QueryVisualization } from "components/QueryVisualization/QueryVisualization";
1214
import { ResultsTable } from 'components/ResultsTable/ResultsTable';
@@ -67,9 +69,26 @@ function Results() {
6769
return (
6870
<>
6971
<Title order={4}>Results Summary from LLM</Title>
70-
{results.summary ? <p>{results.summary}</p> : <ErrorMessage>There was an error generating a summary.</ErrorMessage>}
72+
{results.summary ? (
73+
<div>
74+
<LLMWarning>
75+
<p>This results summary was generated by an LLM that can make mistakes. Refer below to the Results Table from KG for ground-truth data.</p>
76+
<p>Note that the absence of data does not necessairly mean that there is no data. It is possible that the query did not find what that you are looking for.</p>
77+
</LLMWarning>
78+
79+
<p>{results.summary}</p>
80+
</div>
81+
) : <ErrorMessage>There was an error generating a summary.</ErrorMessage>}
82+
7183
<hr/>
72-
<Title order={4}>Results Table from KG</Title>
84+
85+
<Title order={4}>
86+
Results Table from KG
87+
<InfoModal title="Results Table from KG">
88+
<p>These are ground-truth results retrieved from the KG using the query you executed.</p>
89+
<p>Note that the absence of data does not necessairly mean that there is no data. It is possible that the query did not find what that you are looking for.</p>
90+
</InfoModal>
91+
</Title>
7392
<ResultsTable data={results.data}/>
7493
</>
7594
)

src/components/Chat/Chat.module.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
padding: 0.5rem;
4444
margin-bottom: 0.5rem;
4545
border-radius: 5px;
46-
47-
button {
48-
margin-top: 0.5rem;
49-
}
5046
}
5147

5248
&.user {

src/components/Chat/Chat.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useMutation } from "@tanstack/react-query";
1010
import { IconCaretRight, IconSettings, IconZoomCode } from '@tabler/icons-react';
1111

1212
import { ErrorMessage } from 'components/ErrorMessage';
13+
import { LLMWarning } from 'components/LLMWarning';
1314

1415
import { useMakeChatGPTAPIInstance } from 'hooks/useMakeChatGPTAPIInstance';
1516
import { useRunQuery } from 'hooks/useRunQuery';
@@ -152,6 +153,10 @@ function RenderLLMResponse({
152153
if(parsedQuery) {
153154
return (
154155
<div className={styles.chat}>
156+
<LLMWarning>
157+
<p>This was generated by an LLM that can make mistakes.</p>
158+
</LLMWarning>
159+
155160
<RenderSparqlQuery
156161
pre={parsedQuery.pre}
157162
query={parsedQuery.query.trim()}
@@ -163,7 +168,15 @@ function RenderLLMResponse({
163168
)
164169
}
165170

166-
return <pre className={styles.chat}>{text}</pre>
171+
return (
172+
<div className={styles.chat}>
173+
<LLMWarning>
174+
<p>This was generated by an LLM that can make mistakes.</p>
175+
</LLMWarning>
176+
177+
<pre>{text}</pre>
178+
</div>
179+
)
167180
}
168181

169182

@@ -204,9 +217,9 @@ function RenderSparqlQuery({
204217
</div>
205218
<pre>{post}</pre>
206219
<br/>
207-
<Button onClick={() => setInputText("You identified the wrong data. I was actually looking for: ")}>You identified the wrong data</Button>
220+
<Button onClick={() => setInputText("You identified the wrong data. I was actually looking for: ")} style={{marginTop:"0.5rem"}}>You identified the wrong data</Button>
208221
<br/>
209-
<Button onClick={() => setInputText("You misunderstood my question. I was actually asking about: ")}>You misunderstood my question</Button>
222+
<Button onClick={() => setInputText("You misunderstood my question. I was actually asking about: ")} style={{marginTop:"0.5rem"}}>You misunderstood my question</Button>
210223
<br/>
211224
<Button onClick={() => setInputText("I want to ask something different: ")}>I want to ask something different</Button>
212225
</>

src/components/IDTable/IDTable.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
55
import { Table, Title } from "@mantine/core";
66

7+
import { InfoModal } from "components/InfoModal";
8+
79
import { useAppSelector } from "redux/store";
810

911
import { IDTableEntitiesType } from "types/idTable";
@@ -38,7 +40,12 @@ export function IDTableContainer () {
3840

3941
return (
4042
<div id={styles["id-table-container"]}>
41-
<Title order={4}>Entity-Relation Table from KG</Title>
43+
<Title order={4}>
44+
Entity-Relation Table from KG
45+
<InfoModal title="Entity-Relation Table from KG">
46+
<p>This table extracts the IDs from your query and explains what they mean in the KG.</p>
47+
</InfoModal>
48+
</Title>
4249
{content}
4350
</div>
4451
)

src/components/InfoModal.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useDisclosure } from '@mantine/hooks';
2+
import { Modal, ActionIcon } from '@mantine/core';
3+
import { IconQuestionMark } from '@tabler/icons-react';
4+
5+
export const InfoModal = ({
6+
children,
7+
title,
8+
}:{
9+
children: React.ReactNode,
10+
title: string,
11+
}) => {
12+
const [opened, { open, close }] = useDisclosure(false);
13+
14+
return (
15+
<>
16+
<Modal opened={opened} onClose={close} title={title}>
17+
{children}
18+
</Modal>
19+
20+
<ActionIcon size="xs" variant="filled" aria-label={title} color="gray" onClick={open} style={{
21+
marginLeft: "0.5em",
22+
transform: "translateY(0.1em)",
23+
}}>
24+
<IconQuestionMark/>
25+
</ActionIcon>
26+
</>
27+
);
28+
}

src/components/LLMWarning.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useDisclosure } from '@mantine/hooks';
2+
import { Modal, ActionIcon } from '@mantine/core';
3+
import { IconAlertTriangle } from '@tabler/icons-react';
4+
5+
export const LLMWarning = ({
6+
children,
7+
}:{
8+
children: React.ReactNode,
9+
}) => {
10+
const [opened, { open, close }] = useDisclosure(false);
11+
12+
return (
13+
<>
14+
<Modal opened={opened} onClose={close} title="LLM Hallucination Warning">
15+
{children}
16+
</Modal>
17+
18+
<ActionIcon size="xs" variant="filled" aria-label="LLM Hallucination Warning" color="yellow" onClick={open} style={{float:"right"}}>
19+
<IconAlertTriangle/>
20+
</ActionIcon>
21+
</>
22+
);
23+
}

src/components/QueryEditor/QueryEditor.module.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66
background-color: #fff;
77
width: 100%;
88
overflow-x: auto;
9+
}
10+
11+
.query-history-button {
12+
margin-top: 1em;
13+
14+
span {
15+
white-space: wrap;
16+
overflow: auto;
17+
}
918
}

src/components/QueryEditor/QueryEditor.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,12 @@ export function QueryEditor() {
5252
<Divider/>
5353
{queryHistory.map((record,i) => {
5454
return (
55-
<div key={i}>
56-
<br/>
57-
<Button key={i} variant='default' onClick={() => {
58-
dispatch(setQueryValue(record.query))
59-
dispatch(setResults(record.results))
60-
}}>
61-
{i+1}: {record.name || "There was an error generating a name for this query"}
62-
</Button>
63-
</div>
55+
<Button key={i} className={styles["query-history-button"]} fullWidth variant='default' onClick={() => {
56+
dispatch(setQueryValue(record.query))
57+
dispatch(setResults(record.results))
58+
}}>
59+
{i+1}: {record.name || "There was an error generating a name for this query"}
60+
</Button>
6461
)
6562
})}
6663

0 commit comments

Comments
 (0)