-
Notifications
You must be signed in to change notification settings - Fork 237
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
feat: add LLM powered text2sql support #1276
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ ai_assistant: | |
enabled: true | ||
|
||
query_generation: | ||
enabled: false | ||
enabled: true | ||
|
||
query_auto_fix: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
querybook/webapp/components/AIAssistant/AIModeSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
import { Dropdown } from 'ui/Dropdown/Dropdown'; | ||
import { ListMenu } from 'ui/Menu/ListMenu'; | ||
|
||
export enum AIMode { | ||
GENERATE = 'GENERATE', | ||
EDIT = 'EDIT', | ||
} | ||
|
||
interface IAIModeSelectorProps { | ||
aiMode: AIMode; | ||
aiModes: AIMode[]; | ||
onModeSelect: (mode: AIMode) => any; | ||
} | ||
|
||
export const AIModeSelector: React.FC<IAIModeSelectorProps> = ({ | ||
jczhong84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
aiMode, | ||
aiModes, | ||
onModeSelect, | ||
}) => { | ||
const engineItems = aiModes.map((mode) => ({ | ||
name: <span>{mode}</span>, | ||
onClick: onModeSelect.bind(null, mode), | ||
checked: aiMode === mode, | ||
})); | ||
|
||
return ( | ||
<Dropdown | ||
customButtonRenderer={() => <div>{aiMode}</div>} | ||
layout={['bottom', 'left']} | ||
className="engine-selector-dropdown" | ||
> | ||
{engineItems.length > 1 && ( | ||
<div className="engine-selector-wrapper"> | ||
<ListMenu items={engineItems} type="select" /> | ||
</div> | ||
)} | ||
</Dropdown> | ||
); | ||
}; |
59 changes: 59 additions & 0 deletions
59
querybook/webapp/components/AIAssistant/QueryGenerationButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import PublicConfig from 'config/querybook_public_config.yaml'; | ||
import { IQueryEngine } from 'const/queryEngine'; | ||
import { IconButton } from 'ui/Button/IconButton'; | ||
|
||
import { QueryGenerationModal } from './QueryGenerationModal'; | ||
|
||
const AIAssistantConfig = PublicConfig.ai_assistant; | ||
|
||
interface IProps { | ||
dataCellId: number; | ||
query: string; | ||
engineId: number; | ||
queryEngines: IQueryEngine[]; | ||
queryEngineById: Record<number, IQueryEngine>; | ||
onUpdateQuery?: (query: string) => void; | ||
onUpdateEngineId: (engineId: number) => void; | ||
} | ||
|
||
export const QueryGenerationButton = ({ | ||
dataCellId, | ||
query = '', | ||
engineId, | ||
queryEngines, | ||
queryEngineById, | ||
onUpdateQuery, | ||
onUpdateEngineId, | ||
}: IProps) => { | ||
const [show, setShow] = useState(false); | ||
|
||
return ( | ||
<> | ||
{AIAssistantConfig.enabled && | ||
AIAssistantConfig.query_generation.enabled && ( | ||
<IconButton | ||
className="QueryGenerationButton" | ||
icon="Stars" | ||
size={18} | ||
tooltip="AI: generate/edit query" | ||
color={!query ? 'accent' : undefined} | ||
onClick={() => setShow(true)} | ||
/> | ||
)} | ||
{show && ( | ||
<QueryGenerationModal | ||
dataCellId={dataCellId} | ||
query={query} | ||
engineId={engineId} | ||
queryEngines={queryEngines} | ||
queryEngineById={queryEngineById} | ||
onUpdateQuery={onUpdateQuery} | ||
onUpdateEngineId={onUpdateEngineId} | ||
onHide={() => setShow(false)} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
querybook/webapp/components/AIAssistant/QueryGenerationModal.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.QueryGenerationModal { | ||
.title { | ||
font-size: var(--text-size); | ||
font-weight: var(--bold-font); | ||
margin-bottom: var(--margin); | ||
} | ||
|
||
.Modal-box { | ||
.Modal-content { | ||
min-height: 40vh; | ||
} | ||
|
||
.Modal-bottom { | ||
margin-top: 0 !important; | ||
} | ||
} | ||
.question-bar { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
background-color: var(--bg-light); | ||
border-radius: var(--border-radius-sm); | ||
margin-top: 24px; | ||
|
||
&:hover { | ||
background-color: var(--bg-hover); | ||
} | ||
|
||
.stars-icon { | ||
position: relative; | ||
color: var(--icon); | ||
padding: 8px; | ||
|
||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.ai-mode { | ||
color: var(--color-pink-dark); | ||
} | ||
|
||
.DebouncedInput { | ||
flex: 1; | ||
|
||
input { | ||
line-height: 1.8rem; | ||
border-radius: 0; | ||
background-color: transparent; | ||
} | ||
} | ||
} | ||
|
||
.action-buttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
margin-top: var(--margin); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of data cell, use original_query so it is not limited to data doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is I realized that for GET http request, it has length limit on the query string. So it may not be safe to pass along the whole query.
Can reconsider the EventSource solution in future and change it back to use POST method. For this specific case, I can move the get query from the data cell into this api endpoint and make
ai_assistant
to accept the original query.