branch: elpa/gptel commit bed2402c5442fec21cc336a76821a5c89c1b254b Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
gptel: Include full file path in context (#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. --- NEWS | 8 ++++++++ gptel.el | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ac4f52e1fd..3e9ca6747a 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,14 @@ ** New features and UI changes +- When including a file in the context, the abbreviated full path of + the file is included is now included instead of the basename. + Specifically, =/home/user/path/to/file= is included as + =~/path/to/file=. This is to provide additional context for LLM + actions, including tool-use in subsequent conversation turns. This + applies to context included via ~gptel-add~ or as a link in a + buffer. + - Structured output support: ~gptel-request~ can now take an optional schema argument to constrain LLM output to the specified JSON schema. The JSON schema can be provided as a serialized JSON string diff --git a/gptel.el b/gptel.el index eacfbd0261..24a1a08658 100644 --- a/gptel.el +++ b/gptel.el @@ -996,7 +996,7 @@ Later plists in the sequence take precedence over earlier ones." (defun gptel--insert-file-string (path) "Insert at point the contents of the file at PATH as context." - (insert (format "In file `%s`:" (file-name-nondirectory path)) + (insert (format "In file `%s`:" (abbreviate-file-name path)) "\n\n```\n") (let ((pm (point-marker))) (set-marker-insertion-type pm t)