add isInAgentMode in retreival pipeline
This commit is contained in:
parent
fc47e27df8
commit
ed49258fd6
9 changed files with 35 additions and 8 deletions
|
|
@ -85,12 +85,15 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
);
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
{
|
||||
...INSTRUCTIONS_BASE_ITEM,
|
||||
content: "No results were found. Try using other tools.",
|
||||
},
|
||||
];
|
||||
if (extras.isInAgentMode) {
|
||||
return [
|
||||
{
|
||||
...INSTRUCTIONS_BASE_ITEM,
|
||||
content: "No results were found. Try using other tools.",
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -1021,6 +1021,7 @@ export class Core {
|
|||
query: string;
|
||||
fullInput: string;
|
||||
selectedCode: RangeInFile[];
|
||||
isInAgentMode: boolean;
|
||||
}>,
|
||||
) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
|
|
@ -1068,6 +1069,7 @@ export class Core {
|
|||
reranker: config.selectedModelByRole.rerank,
|
||||
fetch: (url, init) =>
|
||||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
isInAgentMode: msg.data.isInAgentMode,
|
||||
});
|
||||
|
||||
void Telemetry.capture(
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -186,6 +186,7 @@ export interface ContextProviderExtras {
|
|||
ide: IDE;
|
||||
selectedCode: RangeInFile[];
|
||||
fetch: FetchFunction;
|
||||
isInAgentMode: boolean;
|
||||
}
|
||||
|
||||
export interface LoadSubmenuItemsArgs {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
query: string;
|
||||
fullInput: string;
|
||||
selectedCode: RangeInFile[];
|
||||
isInAgentMode: boolean;
|
||||
},
|
||||
ContextItemWithId[],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
vscQuickInputBackground,
|
||||
} from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../util";
|
||||
import FileIcon from "../../FileIcon";
|
||||
|
|
@ -159,6 +160,9 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
|
|||
const dispatch = useDispatch();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const isInAgentMode = useAppSelector(
|
||||
(store) => store.session.mode === "agent",
|
||||
);
|
||||
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
|
||||
|
|
@ -187,6 +191,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
|
|||
query,
|
||||
fullInput: "",
|
||||
selectedCode,
|
||||
isInAgentMode,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export async function getRenderedV1Prompt(
|
|||
name,
|
||||
query: "",
|
||||
selectedCode,
|
||||
isInAgentMode: false,
|
||||
});
|
||||
if (response.status === "success") {
|
||||
return response.content.map((item) => item.content).join("\n\n");
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {
|
|||
import { stripImages } from "core/util/messageContent";
|
||||
import { IIdeMessenger } from "../../../../context/IdeMessenger";
|
||||
import { setIsGatheringContext } from "../../../../redux/slices/sessionSlice";
|
||||
import { RootState } from "../../../../redux/store";
|
||||
import { processEditorContent } from "./processEditorContent";
|
||||
import { renderSlashCommandPrompt } from "./renderSlashCommand";
|
||||
import { GetContextRequest } from "./types";
|
||||
|
|
@ -23,6 +24,7 @@ interface ResolveEditorContentInput {
|
|||
defaultContextProviders: DefaultContextProvider[];
|
||||
availableSlashCommands: SlashCommandDescWithSource[];
|
||||
dispatch: Dispatch;
|
||||
getState: () => RootState;
|
||||
}
|
||||
|
||||
interface ResolveEditorContentOutput {
|
||||
|
|
@ -48,6 +50,7 @@ export async function resolveEditorContent({
|
|||
defaultContextProviders,
|
||||
availableSlashCommands,
|
||||
dispatch,
|
||||
getState,
|
||||
}: ResolveEditorContentInput): Promise<ResolveEditorContentOutput> {
|
||||
const {
|
||||
parts,
|
||||
|
|
@ -87,6 +90,7 @@ export async function resolveEditorContent({
|
|||
defaultContextProviders,
|
||||
parts: slashedParts,
|
||||
selectedCode,
|
||||
getState,
|
||||
});
|
||||
|
||||
if (shouldGatherContext) {
|
||||
|
|
@ -111,6 +115,7 @@ async function gatherContextItems({
|
|||
defaultContextProviders,
|
||||
parts,
|
||||
selectedCode,
|
||||
getState,
|
||||
}: {
|
||||
contextRequests: GetContextRequest[];
|
||||
modifiers: InputModifiers;
|
||||
|
|
@ -118,6 +123,7 @@ async function gatherContextItems({
|
|||
defaultContextProviders: DefaultContextProvider[];
|
||||
parts: MessagePart[];
|
||||
selectedCode: RangeInFile[];
|
||||
getState: () => RootState;
|
||||
}): Promise<ContextItemWithId[]> {
|
||||
const defaultRequests: GetContextRequest[] = defaultContextProviders.map(
|
||||
(def) => ({
|
||||
|
|
@ -139,6 +145,8 @@ async function gatherContextItems({
|
|||
);
|
||||
let contextItems: ContextItemWithId[] = [];
|
||||
|
||||
const isInAgentMode = getState().session.mode === "agent";
|
||||
|
||||
// Process context item attributes
|
||||
for (const item of deduplicatedInputs) {
|
||||
const result = await ideMessenger.request("context/getContextItems", {
|
||||
|
|
@ -146,6 +154,7 @@ async function gatherContextItems({
|
|||
query: item.query ?? "",
|
||||
fullInput: stripImages(parts),
|
||||
selectedCode,
|
||||
isInAgentMode,
|
||||
});
|
||||
if (result.status === "success") {
|
||||
contextItems.push(...result.content);
|
||||
|
|
@ -162,6 +171,7 @@ async function gatherContextItems({
|
|||
query: "",
|
||||
fullInput: stripImages(parts),
|
||||
selectedCode,
|
||||
isInAgentMode,
|
||||
});
|
||||
|
||||
if (result.status === "success") {
|
||||
|
|
@ -181,6 +191,7 @@ async function gatherContextItems({
|
|||
query: "non-mention-usage",
|
||||
fullInput: "",
|
||||
selectedCode: [],
|
||||
isInAgentMode,
|
||||
},
|
||||
);
|
||||
if (currentFileResponse.status === "success") {
|
||||
|
|
|
|||
|
|
@ -35,10 +35,11 @@ export const streamEditThunk = createAsyncThunk<
|
|||
ThunkApiType
|
||||
>(
|
||||
"edit/streamResponse",
|
||||
async ({ editorState, codeToEdit }, { dispatch, extra }) => {
|
||||
async ({ editorState, codeToEdit }, { dispatch, extra, getState }) => {
|
||||
await dispatch(
|
||||
streamThunkWrapper(async () => {
|
||||
dispatch(setActive());
|
||||
|
||||
const { selectedContextItems, content } = await resolveEditorContent({
|
||||
editorState,
|
||||
modifiers: {
|
||||
|
|
@ -49,6 +50,7 @@ export const streamEditThunk = createAsyncThunk<
|
|||
defaultContextProviders: [],
|
||||
availableSlashCommands: [],
|
||||
dispatch,
|
||||
getState,
|
||||
});
|
||||
|
||||
const prompt = [
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
defaultContextProviders,
|
||||
availableSlashCommands: state.config.config.slashCommands,
|
||||
dispatch,
|
||||
getState,
|
||||
});
|
||||
|
||||
// symbols for both context items AND selected codeblocks
|
||||
|
|
@ -77,7 +78,7 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
.map((item) => item.uri!.value),
|
||||
...selectedCode.map((rif) => rif.filepath),
|
||||
];
|
||||
dispatch(updateFileSymbolsFromFiles(filesForSymbols));
|
||||
void dispatch(updateFileSymbolsFromFiles(filesForSymbols));
|
||||
|
||||
dispatch(
|
||||
updateHistoryItemAtIndex({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue