Commit graph

222 commits

Author SHA1 Message Date
Karthik Chikmagalur
a3109a4b68 gptel: Insert response below point, not at point-max
gptel.el (gptel--update-header-line, gptel-send, gptel--playback,
gptel--create-prompt): Add helper function to update the header-line,
and only call when `gptel-mode' is on.  Use markers to track where the
response should be inserted, and insert it after (point) by default.
2023-03-10 22:27:31 -08:00
Karthik Chikmagalur
9f8fc0e519 gptel-transient: Commands to act on region
gptel.el (gptel): When calling `gptel' with a selected region, insert it
into a new session.

gptel-transient.el (gptel--suffix-send-existing,
gptel--suffix-send-new): Transient suffixes available when a region is
selected.  These send the text as a prompt in a existing or new gptel
session.
2023-03-10 06:14:46 -08:00
Karthik Chikmagalur
39376aa3f4 gptel-transient: Add transient menus for setting parameters
gptel-transient (gptel-send-menu): Add new transient-prefix
`gptel-send-menu' for setting API options for the buffer
and (optionally) sending queries. Various infix options are supported.

2023-03-09: Some transient menus are generated dynamically, which
requires a more recent version of transient than the latest tagged
release. As a result, the dynamic generation code is commented out for
now.
2023-03-10 06:13:19 -08:00
Karthik Chikmagalur
8fca5bc762 gptel: Add org-mode support and update README
gptel.el (gptel-response-filter-functions, gptel-send,
gptel--create-prompt, gptel--transform-response, gptel--convert-org,
gptel--convert-markdown->org): Add support for org-mode by transforming
the response manually.  (Note: Asking ChatGPT to format its results in
org-mode markup produces inconsistent results.)

Additionally, the abnormal hook `gptel-resposne-filter-functions' is
added for arbitrary transformations of the response.  Its implementation
seems needlessly complex, and in the future we should change it to
use `run-hook-wrapped' with a local accumulator.
2023-03-10 05:13:29 -08:00
Karthik Chikmagalur
b212c24c4a gptel: tweak prompt, rename url functions
gptel.el (gptel--system-message-alist, gptel--url-get-response,
gptel--url-parse-response): Tweak default programming prompt.  Rename
`gptel--get-response' to the more specific `gptel--url-parse-response'.
Likewise `gptel--parse-response' -> `gptel--url-parse-response'.
2023-03-10 03:55:43 -08:00
Karthik Chikmagalur
de70a066d7 gptel: Pulse inserted text 2023-03-09 22:01:28 -08:00
Karthik Chikmagalur
f98293f004 gptel: Check header-line-format before updating
gptel.el: A header-line is not required for using `gptel-send'. gptel
can now be used from any buffer by selecting a region.
2023-03-09 14:14:06 -08:00
Karthik Chikmagalur
3f7c81012b gptel: Bump version and prepare for transient menus
gptel.el (gptel-send): Prepare to include transient dispatch menus from
`gptel-transient.el'.  This is WIP and not part of the project yet.
2023-03-08 19:25:14 -08:00
Karthik Chikmagalur
4e35e998a8 gptel-curl: Rename functions for linting
gptel-curl.el (gptel-curl--process-alist, gptel-curl--get-args,
gptel--curl-sentinel, gptel-curl--parse-response): Rename internal
functions and variables to use the `gptel-curl--` prefix instead of
`gptel--curl-`.
2023-03-08 19:23:17 -08:00
Karthik Chikmagalur
65e6d73372 gptel: Include more API parameters
gptel.el (gptel--system-message, gptel--system-message-alist,
gptel--model, gptel--temperature, gptel--max-tokens,
gptel--request-data): Add new buffer-local variables to hold API
parameters.  Generating the full request data plist is now done in a
separate function, `gptel--request-data'.
2023-03-08 19:20:00 -08:00
Karthik Chikmagalur
172059060a gptel-curl: Autoload gptel-curl-get-response
gptel-curl.el (gptel-curl-get-response): Rename from `gptel--curl-get-response'
and autoload it to ease its use in `gptel-send'.  Remove Version header
identifying gptel-curl as a separate package and make it require `gptel' instead.
2023-03-08 19:17:14 -08:00
Karthik Chikmagalur
5159a773a0 gptel: Use text-property based delimiting
gptel.el (gptel--prompt-markers, gptel-send, gptel--create-prompt,
gptel--numberize): Switch from using markers to text-properties to
distinguish queries from responses. The former method was very brittle.
Remove `gptel--prompt-markers', add the function `gptel--create-prompt'
and the variable `gptel--num-messages-to-send'. This variable limits the
context of the conversation that is sent with each request.
2023-03-08 19:13:52 -08:00
Karthik Chikmagalur
77d1010fbc gptel-curl: Add package version 2023-03-08 03:58:50 -08:00
Karthik Chikmagalur
3c10147a72 gptel: Tweak README, minor linting 2023-03-08 01:22:14 -08:00
Karthik Chikmagalur
03113afd50 gptel: Rename internal functions
gptel.el (gptel-parse-response, gptel-get-response): These functions
have been renamed to mark them for internal use.
2023-03-08 01:22:14 -08:00
Karthik Chikmagalur
88995a6436 gptel-curl: Add curl module and playback feature.
Conditionally solves #2.

gptel.el (gptel-use-curl, gptel-parse-response, gptel--playback,
gptel-send, gptel-playback): New user options `gptel-playback',
`gptel-use-curl`. The former controls whether the response is played
back in chunks, which is done by the function `gptel--playback'. The
response returned by `gptel-get-response' and `gptel--curl-get-response'
is now a plist with the content and status.

gptel-curl.el (gptel--curl-get-args, gptel--curl-get-response,
gptel--curl-sentinel): Add support for curl when available.  Set it to
the default. `url-retrieve' is full of fangs that multibyte you.
2023-03-08 01:22:14 -08:00
Karthik Chikmagalur
33d8434f3e gptel: Tweak header line format
Add a status indicator to the header line.
2023-03-06 00:58:32 -08:00
Karthik Chikmagalur
a5fe30312f gptel: Fix spacing issues in response 2023-03-05 18:56:41 -08:00
Karthik Chikmagalur
86bf0c9f74 gptel: Avoid logging url-retrieve messages
- Use `read-passwd' to read the API key.
2023-03-05 18:43:49 -08:00
Karthik Chikmagalur
deeb606409 Update license.
Also update README.
2023-03-05 18:13:32 -08:00
Karthik Chikmagalur
cf6999ac12 Fix byte-compile warnings 2023-03-05 18:13:32 -08:00
Karthik Chikmagalur
99aa8dcc5f Add gptel.el and a README. 2023-03-05 18:13:32 -08:00