all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Bruno Barbier <brubar.cs@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Including AI into Emacs
Date: Sat, 7 Dec 2024 13:30:56 +0300	[thread overview]
Message-ID: <Z1Qj4LIevz2EzVgP@lco2> (raw)
In-Reply-To: <67541628.050a0220.1c50f6.91ff@mx.google.com>

* Bruno Barbier <brubar.cs@gmail.com> [2024-12-07 12:32]:
> > I was using in invalidated manner the emacs-chatgpt but in general I
> > can do myself Curl and http requests. My usage is totally specific, I
> > have memories, various memories that I select from Dynamic Knowledge
> > Repository, then I can replace region with the information, or add new
> > information into buffer.
> >
> > I could not try gptel, it doesn't work. But will try in future.

I found out why, tried it out and it works. But programming, inside,
is for me too difficult as I am not used to that type of
programming. I am used for functions which always return something,
but gptel is more than that. Actually I just see too many
complications for my uses.

I need to be able to get result without complications. Synchronous
request is fine and better, rather than asynchronous, where it is
vague what is going to happen with the buffer information.

This is how I prefer it:

(defun rcd-chatgpt-shell (prompt memory model)
  (chatgpt-shell-post :context (list (cons memory nil) (cons prompt nil) ) :version model))

or

(defun rcd-llamafile (prompt memory model)
  "Return answer by using llamafile."
  (let ((model)
	(buffer (let ((url-request-method "POST")
		      (url-request-extra-headers
		       '(("Content-Type" . "application/json")
			 ("Authorization" . "Bearer no-key")))
		      (url-request-data
		       (json-encode
			`((model . "LLaMA_CPP")
			  (messages . [
				       ((role . "system")
					(content . "You are my AI assistant."))
				       ((role . "user") 
				       (content . ,prompt))
				    ])))))
		  (url-retrieve-synchronously
		   "http://localhost:8080/v1/chat/completions"))))
    (when buffer
      (let* ((json-response (setq my-json (rcd-parse-http-json-string (buffer-to-string buffer))))
	     (content (cdr (assoc 'content (cdr (assoc 'message (aref (cdr (assq 'choices my-json)) 0))))))
	     (content (string-replace "</s>" "\n" content)))
	content))))

and 3-4 functions replace all of the catch-all functions in gptel

I have tried understanding gptel code, but I don't. And it doesn't look like I should be going into it.

Yes, it works, but I do not know how to get clear, easy to capture
response, to be returned for easy database logging.

Another issue, I don't see why I need too many files, whole package with many models, not needed.

Like for llamafile, I can easily change the model and same function can work, as above.

-- 
Jean Louis



  reply	other threads:[~2024-12-07 10:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 17:19 Including AI into Emacs Jean Louis
2024-12-06 18:16 ` Bruno Barbier
2024-12-06 22:18   ` Jean Louis
2024-12-07  9:32     ` Bruno Barbier
2024-12-07 10:30       ` Jean Louis [this message]
2024-12-07 11:29         ` Bruno Barbier
2024-12-09 21:06           ` Jean Louis
2024-12-09 22:56             ` Bruno Barbier
2024-12-10  8:03               ` Jean Louis
2024-12-10 10:37                 ` Bruno Barbier
2024-12-10 14:27                   ` Jean Louis
2024-12-06 18:22 ` Eli Zaretskii
2024-12-06 19:11 ` Basile Starynkevitch
2024-12-06 21:14   ` Jean Louis
2024-12-06 22:26   ` Jean Louis
2024-12-06 22:59 ` Christopher Howard
2024-12-06 23:21   ` Jean Louis
2024-12-10 10:45   ` Basile Starynkevitch
2024-12-10 15:04     ` Jean Louis
2024-12-10 17:01       ` Christopher Howard
2024-12-10 17:24         ` Jean Louis
2024-12-10 18:14           ` Christopher Howard
2024-12-11  0:11             ` Jean Louis
  -- strict thread matches above, loose matches on Subject: below --
2024-12-06 17:22 Jean Louis
2024-12-06 18:25 ` Eli Zaretskii
2024-12-06 18:32   ` John Yates
2024-12-06 19:06   ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z1Qj4LIevz2EzVgP@lco2 \
    --to=bugs@gnu.support \
    --cc=brubar.cs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.