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

Support lang and file filters in chat #1132

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
50c3395
Respect path filters in agent queries
rsdy Nov 7, 2023
b6425f5
Fix autocomplete for langs
rsdy Nov 7, 2023
db5ff0d
Add directory indicator
rsdy Nov 9, 2023
66d9b43
Add directory indicator to autocomplete
rsdy Nov 9, 2023
2618e49
Use central lang map instead of a separate one
rsdy Nov 9, 2023
b1c0ee2
Simplify this logic
rsdy Nov 10, 2023
e99d355
Add position information to literals
rsdy Nov 10, 2023
2da46ef
Add `raw_query` to exchange
rsdy Nov 10, 2023
fdf93ee
Add offsets to lang filters
rsdy Nov 10, 2023
ed5497c
Respect the clippy
rsdy Nov 10, 2023
0659a1d
Aggregate and rank languages from the executed queries
rsdy Nov 13, 2023
7730b4d
Only offer lang suggestions if there's a lang filter in the query
rsdy Nov 13, 2023
4612961
Partially parsed lang functions will not return results
rsdy Nov 13, 2023
eb318b5
Allow excluding results from certain kind of results
rsdy Nov 13, 2023
ae78fa9
Normalize results somewhat
rsdy Nov 13, 2023
571ef86
Show lang filters more aggressively
rsdy Nov 14, 2023
a5c03f7
Add arbitrary language suggestions
rsdy Nov 14, 2023
4cd44a9
Tuning
rsdy Nov 14, 2023
ba67c69
Make it a greedy regex
rsdy Nov 14, 2023
cec32c7
render parsed user query in history
anastasiya1155 Nov 10, 2023
2157eed
add autocomplete component
anastasiya1155 Nov 13, 2023
d1474f6
automatically convert user query between input and display
anastasiya1155 Nov 13, 2023
4c97b27
show only file name in the autocomplete input
anastasiya1155 Nov 13, 2023
bef2bca
use another character for autocomplete regex
anastasiya1155 Nov 13, 2023
093c467
reorder query
anastasiya1155 Nov 13, 2023
6fbc90d
add content=false query param
anastasiya1155 Nov 14, 2023
c918945
make the suggestions container bigger
anastasiya1155 Nov 14, 2023
c179ecc
Apply partial lang filter
rsdy Nov 14, 2023
57aaece
fix and test splitUserInputAfterAutocomplete function
anastasiya1155 Nov 14, 2023
f16a4f0
improve styles for highlight background
anastasiya1155 Nov 14, 2023
b3a8bd2
update autocomplete chip style
anastasiya1155 Nov 15, 2023
7cb1896
Add langs queries to fuzzy matcher
rsdy Nov 14, 2023
98b12c7
Merge branch 'main' into anastasiia/blo-1817-support-lang-and-file-fi…
anastasiya1155 Nov 15, 2023
73a7c7e
Autocomplete on lang even if there are no matches
rsdy Nov 15, 2023
1fbed4b
More fine tuning
rsdy Nov 15, 2023
0ca1d4a
More fine tuning
rsdy Nov 15, 2023
3bfcfb2
More tweaks
rsdy Nov 15, 2023
e20d00a
Update server/bleep/src/webserver/autocomplete.rs
rsdy Nov 16, 2023
468bc47
Nicer interface
rsdy Nov 16, 2023
af34a1a
Move `raw_query` to `query`
rsdy Nov 16, 2023
4abc322
Fix tests
rsdy Nov 16, 2023
acca329
move raw_query inside query
anastasiya1155 Nov 16, 2023
b7f4426
Propagate certain filters to LLM
rsdy Nov 17, 2023
7e9e1c0
Merge branch 'main' into anastasiia/blo-1817-support-lang-and-file-fi…
anastasiya1155 Nov 17, 2023
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
9 changes: 7 additions & 2 deletions client/src/components/Chat/ChatBody/AllCoversations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {
OpenChatHistoryItem,
} from '../../../../types/general';
import { conversationsCache } from '../../../../services/cache';
import { mapLoadingSteps } from '../../../../mappers/conversation';
import {
mapLoadingSteps,
mapUserQuery,
} from '../../../../mappers/conversation';
import { LocaleContext } from '../../../../context/localeContext';
import { getDateFnsLocale } from '../../../../utils';
import ConversationListItem from './ConversationListItem';
Expand Down Expand Up @@ -63,9 +66,11 @@ const AllConversations = ({
resp.forEach((m) => {
// @ts-ignore
const userQuery = m.search_steps.find((s) => s.type === 'QUERY');
const parsedQuery = mapUserQuery(m);
conv.push({
author: ChatMessageAuthor.User,
text: m.query?.target?.Plain || userQuery?.content?.query || '',
text: m.query.raw_query || userQuery?.content?.query || '',
parsedQuery,
isFromHistory: true,
});
conv.push({
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/Chat/ChatBody/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const Conversation = ({
isHistory={isHistory}
author={m.author}
message={m.text}
parsedQuery={
m.author === ChatMessageAuthor.Server ? undefined : m.parsedQuery
}
error={m.author === ChatMessageAuthor.Server ? m.error : ''}
showInlineFeedback={
m.author === ChatMessageAuthor.Server &&
Expand Down
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;
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;
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);
16 changes: 13 additions & 3 deletions client/src/components/Chat/ChatBody/ConversationMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
WrenchAndScrewdriver,
} from '../../../../icons';
import { DeviceContext } from '../../../../context/deviceContext';
import { ChatLoadingStep, ChatMessageAuthor } from '../../../../types/general';
import {
ChatLoadingStep,
ChatMessageAuthor,
ParsedQueryType,
} from '../../../../types/general';
import { ChatContext } from '../../../../context/chatContext';
import Button from '../../../Button';
import { LocaleContext } from '../../../../context/localeContext';
Expand All @@ -24,10 +28,12 @@ import {
} from '../../../../services/storage';
import MessageFeedback from './MessageFeedback';
import FileChip from './FileChip';
import UserParsedQuery from './UserParsedQuery';

type Props = {
author: ChatMessageAuthor;
message?: string;
parsedQuery?: ParsedQueryType[];
error?: string;
threadId: string;
queryId: string;
Expand Down Expand Up @@ -61,6 +67,7 @@ const ConversationMessage = ({
onMessageEdit,
responseTimestamp,
singleFileExplanation,
parsedQuery,
}: Props) => {
const { t } = useTranslation();
const [isLoadingStepsShown, setLoadingStepsShown] = useState(
Expand Down Expand Up @@ -172,7 +179,7 @@ const ConversationMessage = ({
)}
</div>
</div>
{message && (
{!!message && (
<div className="body-s text-label-title code-studio-md padding-start w-full break-word overflow-auto">
{author === ChatMessageAuthor.Server ? (
<MarkdownWithCode
Expand All @@ -184,7 +191,10 @@ const ConversationMessage = ({
/>
) : (
<>
<div className="pl-8">{message}</div>
<UserParsedQuery
textQuery={message}
parsedQuery={parsedQuery}
/>
{!isHistory && !!queryId && (
<div className="absolute bottom-1 right-1 opacity-0 group-summary-hover:opacity-100 transition-opacity">
<Button
Expand Down
Loading