Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added icons with popup modals #11

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Chat } from 'components/Chat/Chat';
import { DemoModeModal } from 'components/DemoModeModal';
import { ErrorMessage } from 'components/ErrorMessage';
import { IDTableContainer } from 'components/IDTable/IDTable';
import { InfoModal } from 'components/InfoModal';
import { LLMWarning } from 'components/LLMWarning';
import { QueryEditor } from 'components/QueryEditor/QueryEditor'
import { QueryVisualization } from "components/QueryVisualization/QueryVisualization";
import { ResultsTable } from 'components/ResultsTable/ResultsTable';
Expand Down Expand Up @@ -67,9 +69,26 @@ function Results() {
return (
<>
<Title order={4}>Results Summary from LLM</Title>
{results.summary ? <p>{results.summary}</p> : <ErrorMessage>There was an error generating a summary.</ErrorMessage>}
{results.summary ? (
<div>
<LLMWarning>
<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>
<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>
</LLMWarning>

<p>{results.summary}</p>
</div>
) : <ErrorMessage>There was an error generating a summary.</ErrorMessage>}

<hr/>
<Title order={4}>Results Table from KG</Title>

<Title order={4}>
Results Table from KG
<InfoModal title="Results Table from KG">
<p>These are ground-truth results retrieved from the KG using the query you executed.</p>
<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>
</InfoModal>
</Title>
<ResultsTable data={results.data}/>
</>
)
Expand Down
4 changes: 0 additions & 4 deletions src/components/Chat/Chat.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
padding: 0.5rem;
margin-bottom: 0.5rem;
border-radius: 5px;

button {
margin-top: 0.5rem;
}
}

&.user {
Expand Down
19 changes: 16 additions & 3 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useMutation } from "@tanstack/react-query";
import { IconCaretRight, IconSettings, IconZoomCode } from '@tabler/icons-react';

import { ErrorMessage } from 'components/ErrorMessage';
import { LLMWarning } from 'components/LLMWarning';

import { useMakeChatGPTAPIInstance } from 'hooks/useMakeChatGPTAPIInstance';
import { useRunQuery } from 'hooks/useRunQuery';
Expand Down Expand Up @@ -152,6 +153,10 @@ function RenderLLMResponse({
if(parsedQuery) {
return (
<div className={styles.chat}>
<LLMWarning>
<p>This was generated by an LLM that can make mistakes.</p>
</LLMWarning>

<RenderSparqlQuery
pre={parsedQuery.pre}
query={parsedQuery.query.trim()}
Expand All @@ -163,7 +168,15 @@ function RenderLLMResponse({
)
}

return <pre className={styles.chat}>{text}</pre>
return (
<div className={styles.chat}>
<LLMWarning>
<p>This was generated by an LLM that can make mistakes.</p>
</LLMWarning>

<pre>{text}</pre>
</div>
)
}


Expand Down Expand Up @@ -204,9 +217,9 @@ function RenderSparqlQuery({
</div>
<pre>{post}</pre>
<br/>
<Button onClick={() => setInputText("You identified the wrong data. I was actually looking for: ")}>You identified the wrong data</Button>
<Button onClick={() => setInputText("You identified the wrong data. I was actually looking for: ")} style={{marginTop:"0.5rem"}}>You identified the wrong data</Button>
<br/>
<Button onClick={() => setInputText("You misunderstood my question. I was actually asking about: ")}>You misunderstood my question</Button>
<Button onClick={() => setInputText("You misunderstood my question. I was actually asking about: ")} style={{marginTop:"0.5rem"}}>You misunderstood my question</Button>
<br/>
<Button onClick={() => setInputText("I want to ask something different: ")}>I want to ask something different</Button>
</>
Expand Down
9 changes: 8 additions & 1 deletion src/components/IDTable/IDTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import { Table, Title } from "@mantine/core";

import { InfoModal } from "components/InfoModal";

import { useAppSelector } from "redux/store";

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

return (
<div id={styles["id-table-container"]}>
<Title order={4}>Entity-Relation Table from KG</Title>
<Title order={4}>
Entity-Relation Table from KG
<InfoModal title="Entity-Relation Table from KG">
<p>This table extracts the IDs from your query and explains what they mean in the KG.</p>
</InfoModal>
</Title>
{content}
</div>
)
Expand Down
28 changes: 28 additions & 0 deletions src/components/InfoModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useDisclosure } from '@mantine/hooks';
import { Modal, ActionIcon } from '@mantine/core';
import { IconQuestionMark } from '@tabler/icons-react';

export const InfoModal = ({
children,
title,
}:{
children: React.ReactNode,
title: string,
}) => {
const [opened, { open, close }] = useDisclosure(false);

return (
<>
<Modal opened={opened} onClose={close} title={title}>
{children}
</Modal>

<ActionIcon size="xs" variant="filled" aria-label={title} color="gray" onClick={open} style={{
marginLeft: "0.5em",
transform: "translateY(0.1em)",
}}>
<IconQuestionMark/>
</ActionIcon>
</>
);
}
23 changes: 23 additions & 0 deletions src/components/LLMWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useDisclosure } from '@mantine/hooks';
import { Modal, ActionIcon } from '@mantine/core';
import { IconAlertTriangle } from '@tabler/icons-react';

export const LLMWarning = ({
children,
}:{
children: React.ReactNode,
}) => {
const [opened, { open, close }] = useDisclosure(false);

return (
<>
<Modal opened={opened} onClose={close} title="LLM Hallucination Warning">
{children}
</Modal>

<ActionIcon size="xs" variant="filled" aria-label="LLM Hallucination Warning" color="yellow" onClick={open} style={{float:"right"}}>
<IconAlertTriangle/>
</ActionIcon>
</>
);
}
9 changes: 9 additions & 0 deletions src/components/QueryEditor/QueryEditor.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@
background-color: #fff;
width: 100%;
overflow-x: auto;
}

.query-history-button {
margin-top: 1em;

span {
white-space: wrap;
overflow: auto;
}
}
15 changes: 6 additions & 9 deletions src/components/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ export function QueryEditor() {
<Divider/>
{queryHistory.map((record,i) => {
return (
<div key={i}>
<br/>
<Button key={i} variant='default' onClick={() => {
dispatch(setQueryValue(record.query))
dispatch(setResults(record.results))
}}>
{i+1}: {record.name || "There was an error generating a name for this query"}
</Button>
</div>
<Button key={i} className={styles["query-history-button"]} fullWidth variant='default' onClick={() => {
dispatch(setQueryValue(record.query))
dispatch(setResults(record.results))
}}>
{i+1}: {record.name || "There was an error generating a name for this query"}
</Button>
)
})}

Expand Down
Loading