Skip to content

Commit 26e3dac

Browse files
karthinkjdormit
authored andcommitted
gptel: Include full file path in context (karthink#863)
* gptel.el (gptel--insert-file-string): Include the full file path in the context for included files. The file name is passed through `abbreviate-file-name'. * NEWS (New features and UI changes): Mention change and reason.
1 parent cac22aa commit 26e3dac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313

1414
** New features and UI changes
1515

16+
- When including a file in the context, the abbreviated full path of
17+
the file is included is now included instead of the basename.
18+
Specifically, =/home/user/path/to/file= is included as
19+
=~/path/to/file=. This is to provide additional context for LLM
20+
actions, including tool-use in subsequent conversation turns. This
21+
applies to context included via ~gptel-add~ or as a link in a
22+
buffer.
23+
1624
- Structured output support: ~gptel-request~ can now take an optional
1725
schema argument to constrain LLM output to the specified JSON
1826
schema. The JSON schema can be provided as a serialized JSON string

gptel.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ Later plists in the sequence take precedence over earlier ones."
996996

997997
(defun gptel--insert-file-string (path)
998998
"Insert at point the contents of the file at PATH as context."
999-
(insert (format "In file `%s`:" (file-name-nondirectory path))
999+
(insert (format "In file `%s`:" (abbreviate-file-name path))
10001000
"\n\n```\n")
10011001
(let ((pm (point-marker)))
10021002
(set-marker-insertion-type pm t)

0 commit comments

Comments
 (0)