Skip to content

Commit

Permalink
Add Intents panel for SQL support (#901)
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
  • Loading branch information
iseabock and Ian Seabock (Centific Technologies Inc) authored Jun 3, 2024
1 parent f62f3ff commit 18ffc72
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 105 deletions.
1 change: 1 addition & 0 deletions frontend/src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type ExecResults = {
intent: string
search_query: string | null
search_result: string | null
code_generated: string | null
}

export type Conversation = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ export const Answer = ({ answer, onCitationClicked, onExectResultClicked }: Prop
<Text
className={styles.accordionTitle}
onClick={() => onExectResultClicked()}
aria-label="Open exec results"
aria-label="Open Intents"
tabIndex={0}
role="button">
<span>
Show Exec Results
Show Intents
</span>
</Text>
<FontIcon
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/pages/chat/Chat.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@
.exectResultList {
display: flex;
flex-direction: column;
gap: 8px;
border-bottom: 1px solid #323130;
gap: 2px;
border-bottom: 1px solid #ccc;
margin-top: 12px;
}

Expand All @@ -328,10 +328,11 @@
display: flex;
flex-direction: row;
gap: 4px;
margin: 3px 0;
margin: 0;
margin-bottom: 16px;
}

.exectResultList > p > span {
.exectResultList > span {
font-weight: 600;
}

Expand Down
30 changes: 25 additions & 5 deletions frontend/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import rehypeRaw from 'rehype-raw'
import uuid from 'react-uuid'
import { isEmpty } from 'lodash'
import DOMPurify from 'dompurify'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import { nord } from 'react-syntax-highlighter/dist/esm/styles/prism'

import styles from './Chat.module.css'
import Contoso from '../../assets/Contoso.svg'
Expand Down Expand Up @@ -959,15 +961,15 @@ const Chat = () => {
</Stack.Item>
)}
{messages && messages.length > 0 && isIntentsPanelOpen && (
<Stack.Item className={styles.citationPanel} tabIndex={0} role="tabpanel" aria-label="Exec Results Panel">
<Stack.Item className={styles.citationPanel} tabIndex={0} role="tabpanel" aria-label="Intents Panel">
<Stack
aria-label="Intents Panel Header Container"
horizontal
className={styles.citationPanelHeaderContainer}
horizontalAlign="space-between"
verticalAlign="center">
<span aria-label="Intents" className={styles.citationPanelHeader}>
Exec Results
Intents
</span>
<IconButton
iconProps={{ iconName: 'Cancel' }}
Expand All @@ -979,9 +981,27 @@ const Chat = () => {
{execResults.map((execResult) => {
return (
<Stack className={styles.exectResultList} verticalAlign="space-between">
<p><span>Intent:</span> {execResult.intent}</p>
{execResult.search_query && <p><span>Search Query:</span> {execResult.search_query}</p>}
{execResult.search_result && <p><span>Search Result:</span> {execResult.search_result}</p>}
<><span>Intent:</span> <p>{execResult.intent}</p></>
{execResult.search_query && <><span>Search Query:</span>
<SyntaxHighlighter
style={nord}
wrapLines={true}
lineProps={{ style: { wordBreak: 'break-all', whiteSpace: 'pre-wrap' } }}
language="sql"
PreTag="p">
{execResult.search_query}
</SyntaxHighlighter></>}
{execResult.search_result && <><span>Search Result:</span> <p>{execResult.search_result}</p></>}
{execResult.code_generated && <><span>Code Generated:</span>
<SyntaxHighlighter
style={nord}
wrapLines={true}
lineProps={{ style: { wordBreak: 'break-all', whiteSpace: 'pre-wrap' } }}
language="python"
PreTag="p">
{execResult.code_generated}
</SyntaxHighlighter>
</>}
</Stack>
)
})}
Expand Down
25 changes: 0 additions & 25 deletions static/assets/Contoso-ff70ad88.svg

This file was deleted.

1 change: 1 addition & 0 deletions static/assets/index-61492790.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 18ffc72

Please sign in to comment.