This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support lang and file filters in chat (#1132)
* Respect path filters in agent queries * Fix autocomplete for langs * Add directory indicator * Add directory indicator to autocomplete * Use central lang map instead of a separate one * Simplify this logic * Add position information to literals * Add `raw_query` to exchange * Add offsets to lang filters * Respect the clippy * Aggregate and rank languages from the executed queries * Only offer lang suggestions if there's a lang filter in the query * Partially parsed lang functions will not return results * Allow excluding results from certain kind of results * Normalize results somewhat * Show lang filters more aggressively * Add arbitrary language suggestions * Tuning * Make it a greedy regex * render parsed user query in history * add autocomplete component * automatically convert user query between input and display * show only file name in the autocomplete input * use another character for autocomplete regex * reorder query * add content=false query param * make the suggestions container bigger * Apply partial lang filter * fix and test splitUserInputAfterAutocomplete function * improve styles for highlight background * update autocomplete chip style * Add langs queries to fuzzy matcher * Autocomplete on lang even if there are no matches * More fine tuning * More fine tuning * More tweaks * Update server/bleep/src/webserver/autocomplete.rs Co-authored-by: Gabriel Gordon-Hall <[email protected]> * Nicer interface * Move `raw_query` to `query` * Fix tests * move raw_query inside query * Propagate certain filters to LLM --------- Co-authored-by: rsdy <[email protected]> Co-authored-by: rsdy <[email protected]> Co-authored-by: Gabriel Gordon-Hall <[email protected]>
- Loading branch information
1 parent
f71a58e
commit 39d94a1
Showing
34 changed files
with
1,639 additions
and
346 deletions.
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
22 changes: 22 additions & 0 deletions
22
client/src/components/Chat/ChatBody/ConversationMessage/UserParsedQuery/LangChip.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,22 @@ | ||
import FileIcon from '../../../../FileIcon'; | ||
import { getFileExtensionForLang } from '../../../../../utils'; | ||
|
||
type Props = { | ||
lang: string; | ||
}; | ||
|
||
const LangChip = ({ lang }: Props) => { | ||
return ( | ||
<span | ||
className={`inline-flex items-center bg-bg-base rounded-4 overflow-hidden | ||
text-label-base border border-bg-border align-middle`} | ||
> | ||
<span className="flex gap-1 px-1 py-0.5 items-center code-s"> | ||
<FileIcon filename={getFileExtensionForLang(lang, true)} /> | ||
<span className="">{lang}</span> | ||
</span> | ||
</span> | ||
); | ||
}; | ||
|
||
export default LangChip; |
31 changes: 31 additions & 0 deletions
31
client/src/components/Chat/ChatBody/ConversationMessage/UserParsedQuery/PathChip.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,31 @@ | ||
import { useMemo } from 'react'; | ||
import { FolderClosed, ArrowOut } from '../../../../../icons'; | ||
import FileIcon from '../../../../FileIcon'; | ||
import { splitPath } from '../../../../../utils'; | ||
|
||
type Props = { | ||
path: string; | ||
}; | ||
|
||
const PathChip = ({ path }: Props) => { | ||
const isFolder = useMemo(() => path.endsWith('/'), [path]); | ||
return ( | ||
<span | ||
className={`inline-flex items-center bg-bg-base rounded-4 overflow-hidden | ||
text-label-base border border-bg-border align-middle`} | ||
> | ||
<span className="flex gap-1 px-1 py-0.5 items-center code-s"> | ||
{isFolder ? ( | ||
<FolderClosed raw sizeClassName="w-3.5 h-3.5" /> | ||
) : ( | ||
<FileIcon filename={path} /> | ||
)} | ||
<span className=""> | ||
{isFolder ? path.replace(/\/$/, '') : splitPath(path).pop()} | ||
</span> | ||
</span> | ||
</span> | ||
); | ||
}; | ||
|
||
export default PathChip; |
32 changes: 32 additions & 0 deletions
32
client/src/components/Chat/ChatBody/ConversationMessage/UserParsedQuery/index.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,32 @@ | ||
import { memo } from 'react'; | ||
import { | ||
ParsedQueryType, | ||
ParsedQueryTypeEnum, | ||
} from '../../../../../types/general'; | ||
import PathChip from './PathChip'; | ||
import LangChip from './LangChip'; | ||
|
||
type Props = { | ||
textQuery: string; | ||
parsedQuery?: ParsedQueryType[]; | ||
}; | ||
|
||
const UserParsedQuery = ({ textQuery, parsedQuery }: Props) => { | ||
return ( | ||
<div className="pl-8"> | ||
{parsedQuery | ||
? parsedQuery.map((p, i) => | ||
p.type === ParsedQueryTypeEnum.TEXT ? ( | ||
p.text | ||
) : p.type === ParsedQueryTypeEnum.PATH ? ( | ||
<PathChip path={p.text} key={i} /> | ||
) : p.type === ParsedQueryTypeEnum.LANG ? ( | ||
<LangChip lang={p.text} key={i} /> | ||
) : null, | ||
) | ||
: textQuery} | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(UserParsedQuery); |
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
Oops, something went wrong.