Project file path in LLM context for highlighted code (#1509)
This commit is contained in:
parent
a3b5146374
commit
cecbdf3ecc
2 changed files with 7 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ import {
|
|||
RangeInFile,
|
||||
} from "core";
|
||||
import { modelSupportsImages } from "core/llm/autodetect";
|
||||
import { getBasename } from "core/util";
|
||||
import { getBasename, getRelativePath } from "core/util";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
|
|
@ -590,12 +590,13 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
const rif: RangeInFile & { contents: string } =
|
||||
data.rangeInFileWithContents;
|
||||
const basename = getBasename(rif.filepath);
|
||||
const relativePath = getRelativePath(rif.filepath, await ideMessenger.ide.getWorkspaceDirs());
|
||||
const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1})`;
|
||||
const item: ContextItemWithId = {
|
||||
content: rif.contents,
|
||||
name: `${basename} (${rif.range.start.line + 1}-${
|
||||
rif.range.end.line + 1
|
||||
})`,
|
||||
description: rif.filepath,
|
||||
name: `${basename} ${rangeStr}`,
|
||||
// Description is passed on to the LLM to give more context on file path
|
||||
description: `${relativePath} ${rangeStr}`,
|
||||
id: {
|
||||
providerTitle: "code",
|
||||
itemId: rif.filepath,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ async function resolveEditorContent(
|
|||
} else if (p.type === "codeBlock") {
|
||||
if (!p.attrs.item.editing) {
|
||||
const text =
|
||||
"```" + p.attrs.item.name + "\n" + p.attrs.item.content + "\n```";
|
||||
"```" + p.attrs.item.description + "\n" + p.attrs.item.content + "\n```";
|
||||
if (parts[parts.length - 1]?.type === "text") {
|
||||
parts[parts.length - 1].text += "\n" + text;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue