unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Including AI into Emacs
@ 2024-12-06 17:19 Jean Louis
  2024-12-06 18:16 ` Bruno Barbier
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-06 17:19 UTC (permalink / raw)
  To: Emacs Tangents

Today, I’ve noticed that there are many free software projects that
use artificial intelligence, or AI for short. These projects are
created by developers all around the world who want to make useful
tools available to everyone. AI can help solve complex problems,
automate tasks, and improve the way we interact with technology. It’s
exciting to see so many people contributing to these projects and
making AI more accessible to everyone.

I believe it would be really beneficial to include AI into GNU
Emacs. Emacs is already a powerful tool, but adding AI features could
make it even better. For example, AI could help with writing by
suggesting improvements or catching mistakes. It could also assist
with coding by providing smart autocomplete options or debugging
help. These features would make Emacs more efficient and
user-friendly, helping users get their work done faster and with fewer
errors.

I am using AI every day, and will soon provide references on how to
use it self-contained, as every user can download it and run it on
their own computers.

Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Including AI into Emacs
@ 2024-12-06 17:22 Jean Louis
  2024-12-06 18:25 ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2024-12-06 17:22 UTC (permalink / raw)
  To: Emacs Tangents

My previous e-mail about AI was written only to test the following
function:

(defun rcd-monitor-directory-for-mail-files (directory)
  "Monitor DIRECTORY for creation of *.mail files, and call `msmtp-count-remaining` when one is created.

DIRECTORY should be the path to the directory you want to monitor.

This function sets up a file notification watch on DIRECTORY.
When a new file with the `.mail` extension is created within DIRECTORY,
the `msmtp-count-remaining` function is called."
  (file-notify-add-watch
   directory
   '(change)
   (lambda (event)
     ;; Structure of EVENT:
     ;; (ACTION EVENT-TYPE FILE)
     (let* ((event-type (cadr event))
            (file-path (caddr event))
            (file-name (file-name-nondirectory file-path)))
       (when (and (eq event-type 'created)
                  (string-suffix-p ".mail" file-name))
         (msmtp-count-remaining))))))

As I was invoking the function always manually with: M-x msmtp-count-remaining

(defun msmtp-count-remaining ()
  "Count and send any remaining MSMTP messages in the queue"
  (interactive)
  (let ((default-directory (rcd-my-home))
	(msmtp-runqueue (executable-find "msmtp-runqueue.sh")))
    (rcd-general-log "Function `msmtp-count-remaining' invoked" nil 1 nil nil nil 6)
    (let ((count (length (directory-files "~/.msmtpqueue" nil "\\.mail"))))
      (if (> count 0)
	  (progn
	    (start-process msmtp-runqueue "RCD MSMTP" msmtp-runqueue)
	    (rcd-message "MSMTP: There is %s e-mails in queue." count))
	(rcd-message "MSMTP: No emails.")))))

Now I can just put:

(rcd-monitor-directory-for-mail-files "~/.msmtpqueue")

in the Emacs configuration and as soon as e-mail is sent, it is also
dispatched with msmtp:

msmtp is an SMTP client that can be used to send mails from Mutt and
probably other MUAs (mail user agents). It forwards mails to an SMTP
server (for example at a free mail provider), which takes care of the
final delivery.  Using profiles, it can be easily configured to use
different SMTP servers with different configurations, which makes it
ideal for mobile clients.

Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 17:19 Jean Louis
@ 2024-12-06 18:16 ` Bruno Barbier
  2024-12-06 22:18   ` Jean Louis
  2024-12-06 18:22 ` Eli Zaretskii
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 22+ messages in thread
From: Bruno Barbier @ 2024-12-06 18:16 UTC (permalink / raw)
  To: Jean Louis, Emacs Tangents


Hi Jean-Louis,

Jean Louis <bugs@gnu.support> writes:
> ...
> I am using AI every day, and will soon provide references on how to
> use it self-contained, as every user can download it and run it on
> their own computers.
>

Are you aware of the gptel package ?
   https://github.com/karthink/gptel

It allows to use AI pretty much everywhere in Emacs.  And it provides
backends for many existing AI.

Cheers,
Bruno





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 17:19 Jean Louis
  2024-12-06 18:16 ` Bruno Barbier
@ 2024-12-06 18:22 ` Eli Zaretskii
  2024-12-06 19:11 ` Basile Starynkevitch
  2024-12-06 22:59 ` Christopher Howard
  3 siblings, 0 replies; 22+ messages in thread
From: Eli Zaretskii @ 2024-12-06 18:22 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 06 Dec 2024 20:19:47 +0300
> From: Jean Louis <bugs@gnu.support>
> 
> Today, I’ve noticed that there are many free software projects that
> use artificial intelligence, or AI for short. These projects are
> created by developers all around the world who want to make useful
> tools available to everyone. AI can help solve complex problems,
> automate tasks, and improve the way we interact with technology. It’s
> exciting to see so many people contributing to these projects and
> making AI more accessible to everyone.
> 
> I believe it would be really beneficial to include AI into GNU
> Emacs. Emacs is already a powerful tool, but adding AI features could
> make it even better. For example, AI could help with writing by
> suggesting improvements or catching mistakes. It could also assist
> with coding by providing smart autocomplete options or debugging
> help. These features would make Emacs more efficient and
> user-friendly, helping users get their work done faster and with fewer
> errors.
> 
> I am using AI every day, and will soon provide references on how to
> use it self-contained, as every user can download it and run it on
> their own computers.

There are many 3rd-party packages that add "AI" support to Emacs.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 17:22 Including AI into Emacs Jean Louis
@ 2024-12-06 18:25 ` Eli Zaretskii
  2024-12-06 18:32   ` John Yates
  2024-12-06 19:06   ` Jean Louis
  0 siblings, 2 replies; 22+ messages in thread
From: Eli Zaretskii @ 2024-12-06 18:25 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 06 Dec 2024 20:22:23 +0300
> From: Jean Louis <bugs@gnu.support>
> 
> My previous e-mail about AI was written only to test the following
> function:

Please avoid using Emacs public mailing lists for testing your code.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 18:25 ` Eli Zaretskii
@ 2024-12-06 18:32   ` John Yates
  2024-12-06 19:06   ` Jean Louis
  1 sibling, 0 replies; 22+ messages in thread
From: John Yates @ 2024-12-06 18:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Fri, Dec 6, 2024 at 1:26 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Fri, 06 Dec 2024 20:22:23 +0300
> > From: Jean Louis <bugs@gnu.support>
> >
> > My previous e-mail about AI was written only to test the following
> > function:
>
> Please avoid using Emacs public mailing lists for testing your code.


Thank you, Eli, for your many examples of polite, gentle, respectful
project leadership.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 18:25 ` Eli Zaretskii
  2024-12-06 18:32   ` John Yates
@ 2024-12-06 19:06   ` Jean Louis
  1 sibling, 0 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-06 19:06 UTC (permalink / raw)
  To: help-gnu-emacs, Eli Zaretskii

On December 6, 2024 9:25:34 PM GMT+03:00, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Fri, 06 Dec 2024 20:22:23 +0300
>> From: Jean Louis <bugs@gnu.support>
>> 
>> My previous e-mail about AI was written only to test the following
>> function:
>
>Please avoid using Emacs public mailing lists for testing your code.
>

I am not expressing myself well as usual. I should have avoid to say "only" as it wasn't.

Mailing list wasn't used for testing my code, it can be seen in the function. 

The fact that email was written on my personal computer was used to run the code, as when specific file appears in directory the function is invoked.

I hope it's now clear.


Jean



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 17:19 Jean Louis
  2024-12-06 18:16 ` Bruno Barbier
  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
  3 siblings, 2 replies; 22+ messages in thread
From: Basile Starynkevitch @ 2024-12-06 19:11 UTC (permalink / raw)
  To: Jean Louis, Emacs Tangents

On Fri, 2024-12-06 at 20:19 +0300, Jean Louis wrote:
> Today, I’ve noticed that there are many free software projects that
> use artificial intelligence, or AI for short. These projects are
> created by developers all around the world who want to make useful
> tools available to everyone. AI can help solve complex problems,
> automate tasks, and improve the way we interact with technology. It’s
> exciting to see so many people contributing to these projects and
> making AI more accessible to everyone.
> 
> I believe it would be really beneficial to include AI into GNU
> Emacs. Emacs is already a powerful tool, but adding AI features could
> make it even better. For example, AI could help with writing by
> suggesting improvements or catching mistakes. It could also assist
> with coding by providing smart autocomplete options or debugging
> help. These features would make Emacs more efficient and
> user-friendly, helping users get their work done faster and with
> fewer
> errors.
> 
> I am using AI every day, and will soon provide references on how to
> use it self-contained, as every user can download it and run it on
> their own computers.


On of the issues is to define what is an open source AI system.

Is https://clipsrules.net/ an AI system? (On Linux you could run it
from GNU emacs)?

Can https://github.com/RefPerSys/RefPerSys be extended (or the basis
of) to become an AI system? It is GPLv3+ licensed?

Both software are open source... See also http://refpersys.org/ 

Regards from near Paris in France....

-- 
Basile STARYNKEVITCH <basile@starynkevitch.net>
8 rue de la Faïencerie
92340 Bourg-la-Reine, France
http://starynkevitch.net/Basile & https://github.com/bstarynk 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 19:11 ` Basile Starynkevitch
@ 2024-12-06 21:14   ` Jean Louis
  2024-12-06 22:26   ` Jean Louis
  1 sibling, 0 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-06 21:14 UTC (permalink / raw)
  To: Basile Starynkevitch; +Cc: Emacs Tangents

* Basile Starynkevitch <basile@starynkevitch.net> [2024-12-06 22:14]:
> On of the issues is to define what is an open source AI system.

I like to use "Free Software" instead of "Open Source" as many times Open Source is not really free, so there are differences. But one has to distinguish it with licenses and research to verify if anything open source is really free.

There are Large Language Models that are allegedly free software, it requires research. Here is one list of it:

eugeneyan/open-llms: 📋 A list of open LLMs available for commercial use.
https://github.com/eugeneyan/open-llms

> Is https://clipsrules.net/ an AI system? (On Linux you could run it
> from GNU emacs)?

That sounds like US government financed software and such is always
released to public domain if I am not mistaken.

There is MIT No Attribution license in the documentation.

> Can https://github.com/RefPerSys/RefPerSys be extended (or the basis
> of) to become an AI system? It is GPLv3+ licensed?

I think yes, why not.

> Both software are open source... See also http://refpersys.org/ 

I wish to see use for me personally, managing documents, understanding my workflows, implementing them in code, like that.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 18:16 ` Bruno Barbier
@ 2024-12-06 22:18   ` Jean Louis
  2024-12-07  9:32     ` Bruno Barbier
  0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2024-12-06 22:18 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: help-gnu-emacs

* Bruno Barbier <brubar.cs@gmail.com> [2024-12-06 21:16]:
> 
> Hi Jean-Louis,
> 
> Jean Louis <bugs@gnu.support> writes:
> > ...
> > I am using AI every day, and will soon provide references on how to
> > use it self-contained, as every user can download it and run it on
> > their own computers.
> >
> 
> Are you aware of the gptel package ?
>    https://github.com/karthink/gptel

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.

> It allows to use AI pretty much everywhere in Emacs.  And it provides
> backends for many existing AI.

Soon I will buy Nvidia RTX 4xxx and then I will be using it offline
exclusively.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 19:11 ` Basile Starynkevitch
  2024-12-06 21:14   ` Jean Louis
@ 2024-12-06 22:26   ` Jean Louis
  1 sibling, 0 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-06 22:26 UTC (permalink / raw)
  To: Basile Starynkevitch; +Cc: help-gnu-emacs

* Basile Starynkevitch <basile@starynkevitch.net> [2024-12-06 22:12]:
> On of the issues is to define what is an open source AI system.

Without referring to common definitions, all of computing can be
considered artificial intelligence as it extends the mind functions
and memory of humans.

It is just a matter of development level to determine how far it may go.

At first, it might handle tasks like invoices. It could ask the user
every day, "Is there any invoice to enter?" If the user answers "Yes,"
the computer could then request the details.

On the next level, the computer may not need to ask the user but
could, through observation, understand that an invoice needs to be
entered. For example, it could recognize a customer's face through a
camera, identify the customer, and automatically generate an invoice.

All Emacs programs and essentially all programs in the world are forms
of artificial intelligence.

But now there are fantastic new developments where computers can
recognize pictures, generate new images through imagination, create
videos, correct text, and more easily understand what we think. This
is what we have been striving for.

And common users now can use it without tedious programming, and that
is huge advance.

It is like jumping from shell usage of Internet to graphics
browser. That happened in past, and is now happening with the AI
accessibility for all.

Of course, the notorious Emacs psychotherapist is predating all of the
modern chatbots. 

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 17:19 Jean Louis
                   ` (2 preceding siblings ...)
  2024-12-06 19:11 ` Basile Starynkevitch
@ 2024-12-06 22:59 ` Christopher Howard
  2024-12-06 23:21   ` Jean Louis
  2024-12-10 10:45   ` Basile Starynkevitch
  3 siblings, 2 replies; 22+ messages in thread
From: Christopher Howard @ 2024-12-06 22:59 UTC (permalink / raw)
  To: Jean Louis; +Cc: Emacs Tangents

Jean Louis <bugs@gnu.support> writes:

> I believe it would be really beneficial to include AI into GNU
> Emacs. Emacs is already a powerful tool, but adding AI features could
> make it even better. For example, AI could help with writing by
> suggesting improvements or catching mistakes. It could also assist
> with coding by providing smart autocomplete options or debugging
> help. These features would make Emacs more efficient and
> user-friendly, helping users get their work done faster and with fewer
> errors.
>

Could you clarify what you mean exactly but "including AI into GNU Emacs"? I know for sure I don't want Emacs sending information about my system, or questions that I have about Emacs or my project, off to some company's LLM chat system, or however that works exactly. I do not want to become dependent on some remote computer program or AI in order to be able to write code or figure out how Emacs works.

I'm certain interested in running tools locally (same computer, or my network) that help me with "suggesting improvements, catching mistakes", etc. Do you need something massive like ChatGPT to accomplish that, or just some Emacs-centric expert systems? Or maybe something like MycroftAI, running locally?

-- 
Christopher Howard



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 22:59 ` Christopher Howard
@ 2024-12-06 23:21   ` Jean Louis
  2024-12-10 10:45   ` Basile Starynkevitch
  1 sibling, 0 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-06 23:21 UTC (permalink / raw)
  To: Christopher Howard; +Cc: Emacs Tangents

* Christopher Howard <christopher@librehacker.com> [2024-12-07 01:59]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > I believe it would be really beneficial to include AI into GNU
> > Emacs. Emacs is already a powerful tool, but adding AI features could
> > make it even better. For example, AI could help with writing by
> > suggesting improvements or catching mistakes. It could also assist
> > with coding by providing smart autocomplete options or debugging
> > help. These features would make Emacs more efficient and
> > user-friendly, helping users get their work done faster and with fewer
> > errors.
> >
> 
> Could you clarify what you mean exactly but "including AI into GNU Emacs"? I know for sure I don't want Emacs sending information about my system, or questions that I have about Emacs or my project, off to some company's LLM chat system, or however that works exactly. I do not want to become dependent on some remote computer program or AI in order to be able to write code or figure out how Emacs works.

There are large language models (LLMs) that may be downloaded and used
in local network, Ethernet or on the local computer. Emacs itself is
huge contribution to general artificial intelligence. LLMs help in
correction of text, answering the questions, correcting the text,
making headings, emphasizing words.

It is not question of releasing private data, asking remote computer
what, those are other issues, I don't agree to it.

There are local models and free software that shall be accessible
through Emacs. 

Examples: https://github.com/Mozilla-Ocho/llamafile/

> I'm certain interested in running tools locally (same computer, or
> my network) that help me with "suggesting improvements, catching
> mistakes", etc. Do you need something massive like ChatGPT to
> accomplish that, or just some Emacs-centric expert systems? Or maybe
> something like MycroftAI, running locally?

There is huge knowledge built-in, it can't be compared to our Emacs only
based artificial intelligence.

When offline, lot of knowledge is accessible on fingertips by using
large language models. Since 11 months 8 days I have logged 3623
requests and interactions with the large language models, and created
so much, it greatly helped me enhance my common Emacs experience, and
it is great extension to editor.

Simple run:

$ ./llava-v1.5-7b-q4.llamafile

Louis: What is GNU Emacs?

Llama: GNU Emacs is a powerful text editor that's been around since 1984. It was designed by Richard Stallman and is part of the GNU project which promotes free software development.

What makes it stand out from other editors is its extensibility, thanks to an extensive set of packages or plugins known as "emacs modes." These modes allow you to customize Emacs' features based on your needs, making it a versatile and powerful tool for various programming languages, web browsing, organizing files, emailing, and more.

Another notable feature is the use of key bindings called "keys" in place of traditional menus or shortcuts. This unique approach to navigation allows users to personalize their editing experience further by creating customized mappings for specific tasks within Emacs.

In summary, GNU Emacs is a highly versatile and customizable text editor that has been widely used for decades due to its extensibility, robustness, and the extensive community support it enjoys.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 22:18   ` Jean Louis
@ 2024-12-07  9:32     ` Bruno Barbier
  2024-12-07 10:30       ` Jean Louis
  0 siblings, 1 reply; 22+ messages in thread
From: Bruno Barbier @ 2024-12-07  9:32 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> * Bruno Barbier <brubar.cs@gmail.com> [2024-12-06 21:16]:
>> 
>> Jean Louis <bugs@gnu.support> writes:
>> 
>> Are you aware of the gptel package ?
>>    https://github.com/karthink/gptel
>
> 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'm not sure why it doesn't work for you: when I tried it, it just
worked.  As far as I understand, it does exactly what you need: it uses
curl to make asynchronous http requests and to replace or add
information in any buffer, even the minibuffer.


> Soon I will buy Nvidia RTX 4xxx and then I will be using it offline
> exclusively.

gptel probably already has a backend for this too ;)

Best,

Bruno



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-07  9:32     ` Bruno Barbier
@ 2024-12-07 10:30       ` Jean Louis
  2024-12-07 11:29         ` Bruno Barbier
  0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2024-12-07 10:30 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: help-gnu-emacs

* 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



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-07 10:30       ` Jean Louis
@ 2024-12-07 11:29         ` Bruno Barbier
  2024-12-09 21:06           ` Jean Louis
  0 siblings, 1 reply; 22+ messages in thread
From: Bruno Barbier @ 2024-12-07 11:29 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs


Jean Louis <bugs@gnu.support> writes:

> * 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.

gptel works asynchronously indeed (which IMHO is a good thing), but I
understand that it might not fit in your workflow.

> ...
> 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.

IIUC, all you would need is to use the documented API ('gptel-request')
and use its callback.

But, if you don't need integration with org, conversations, multiple
backends, etc. , or just for fun, it makes sense to roll your own
solution.

I just wanted to mention gptel in case you weren't aware of it.

Best regards,
Bruno



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-07 11:29         ` Bruno Barbier
@ 2024-12-09 21:06           ` Jean Louis
  2024-12-09 22:56             ` Bruno Barbier
  0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2024-12-09 21:06 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: help-gnu-emacs

* Bruno Barbier <brubar.cs@gmail.com> [2024-12-07 14:29]:
> IIUC, all you would need is to use the documented API ('gptel-request')
> and use its callback.

I am still using my own function, it works well for me. My workflow is
that I press C-F5 to invoke the prompt, and prompt takes whatever is
in the region and it is added to it. 

It is of course possible to interpolate the response in any text, like
in Org, I can of course enter it, just that I don't use Org too
often. From meta level I may generate Org or just use snippets, I am
using all kinds of markups which can be converted to each other.

But I am curious how do you use AI with integration in Org?

How do you use it in conversations?

I can mark region of what customer said, I can say use 123 memory and
answer to customer, and I get pretty good answer based on my previous
AI memory. Is that what you mean?

Or do you mean some kind of automatic conversation?

> But, if you don't need integration with org, conversations, multiple
> backends, etc. , or just for fun, it makes sense to roll your own
> solution.

Multiple backends I have and it works well.

But which other uses do you have?

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-09 21:06           ` Jean Louis
@ 2024-12-09 22:56             ` Bruno Barbier
  2024-12-10  8:03               ` Jean Louis
  0 siblings, 1 reply; 22+ messages in thread
From: Bruno Barbier @ 2024-12-09 22:56 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs


Jean Louis <bugs@gnu.support> writes:

> * Bruno Barbier <brubar.cs@gmail.com> [2024-12-07 14:29]:
>> IIUC, all you would need is to use the documented API ('gptel-request')
>> and use its callback.
>
> I am still using my own function, it works well for me. My workflow is
> that I press C-F5 to invoke the prompt, and prompt takes whatever is
> in the region and it is added to it. 
>
> It is of course possible to interpolate the response in any text, like
> in Org, I can of course enter it, just that I don't use Org too
> often. From meta level I may generate Org or just use snippets, I am
> using all kinds of markups which can be converted to each other.
>
> But I am curious how do you use AI with integration in Org?
>
> How do you use it in conversations?
>
> I can mark region of what customer said, I can say use 123 memory and
> answer to customer, and I get pretty good answer based on my previous
> AI memory. Is that what you mean?
>
> Or do you mean some kind of automatic conversation?

The package repository has a nice video that shows this package in
action.  I think it will answer your questions better than I could
(I discovered this package recently; I just tried it out of curiosity,
no real needs).

>> But, if you don't need integration with org, conversations, multiple
>> backends, etc. , or just for fun, it makes sense to roll your own
>> solution.
>
> Multiple backends I have and it works well.
>
> But which other uses do you have?

I'm not sure I understand your question.  I hope the video did answer
it for me ;)

Cheers,

Bruno



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-09 22:56             ` Bruno Barbier
@ 2024-12-10  8:03               ` Jean Louis
  2024-12-10 10:37                 ` Bruno Barbier
  0 siblings, 1 reply; 22+ messages in thread
From: Jean Louis @ 2024-12-10  8:03 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 2429 bytes --]

* Bruno Barbier <brubar.cs@gmail.com> [2024-12-10 01:57]:
> The package repository has a nice video that shows this package in
> action.  I think it will answer your questions better than I could
> (I discovered this package recently; I just tried it out of curiosity,
> no real needs).

I have so much real need. It is indispensable, and I can't wait buying
strong GPU to run it locally and fast. It already works locally, just
it is so slow as I don't have GPU. I will upgrade memory, GPU so that
I can run free LLMs locally.

(defun rcd-pie-llm-usage-per-day ()
  "Generate an R PNG image showing LLM usage per day."
  (interactive)
  (rcd-sql-pie-chart "LLM usage per day" 
		     "SELECT extract(day from log_datecreated)::text AS day, 
                             count(log_id) AS count 
                        FROM log 
                    WHERE log_logtypes IN (8, 11, 12, 14)
                      AND log_datecreated > (current_date - 30)
                    GROUP BY day 
                    ORDER BY day ASC"))

The above higher level function uses GNU R Langugage to generate the
attached file `llm-usage-per-day.png'

(defun rcd-llm-usage-by-day ()
  (interactive)
  (cf-chart-bar-quickie "SELECT date_part('day', log_datecreated)::int AS day, 
                                count(log_name) 
                           FROM log 
                          WHERE log_logtypes IN (8, 11, 12, 14)
                       GROUP BY date_part('day', log_datecreated)::int
                       ORDER BY day DESC" 
			"LLM usage by day" 
			"LLM usage by day" 
			"Totals"))

The above higher level function uses Emacs Lisp function
`chart-bar-quickie' to generate the attached file
`LLM-usage-per-day2.png'

I can't agree to asynchronous injection of text, it sounds dangerous
to me. When there is any lag in computer, my text anyway doesn't get
well written due to whatever problems and often my speed writing.

And I am often using temporary buffers for that reason that I do not
disturb my other buffers with whatever changes.

My LLM usage is such that I just do C-u F5 and then text will be added
to the previous text, or I do F5 and text will be inserted, if region
was marked it is used as part of the prompt.

Everything is logged in the database, so I can convert each response
later to other objects.

Basically I get fundamentally same result as gptel with just few functions in background.

-- 
Jean Louis

[-- Attachment #2: LLM-usage-per-day2.png --]
[-- Type: image/png, Size: 30742 bytes --]

[-- Attachment #3: llm-usage-per-day.png --]
[-- Type: image/png, Size: 51068 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-10  8:03               ` Jean Louis
@ 2024-12-10 10:37                 ` Bruno Barbier
  2024-12-10 14:27                   ` Jean Louis
  0 siblings, 1 reply; 22+ messages in thread
From: Bruno Barbier @ 2024-12-10 10:37 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> * Bruno Barbier <brubar.cs@gmail.com> [2024-12-10 01:57]:
>> The package repository has a nice video that shows this package in
>> action.  I think it will answer your questions better than I could
>> (I discovered this package recently; I just tried it out of curiosity,
>> no real needs).
>
> I have so much real need. It is indispensable, and I can't wait buying
> strong GPU to run it locally and fast. It already works locally, just
> it is so slow as I don't have GPU. I will upgrade memory, GPU so that
> I can run free LLMs locally.

That's why I pick asynchronous calls when possible: I don't have to care
about how fast I will get the result.

> ...
> I can't agree to asynchronous injection of text, it sounds dangerous
> to me. When there is any lag in computer, my text anyway doesn't get
> well written due to whatever problems and often my speed writing.

Emacs does this all the time when running processes asynchronously.

> And I am often using temporary buffers for that reason that I do not
> disturb my other buffers with whatever changes.

Then asynchronous injection should be 100% safe.

> My LLM usage is such that I just do C-u F5 and then text will be added
> to the previous text, or I do F5 and text will be inserted, if region
> was marked it is used as part of the prompt.
>
> Everything is logged in the database, so I can convert each response
> later to other objects.
>
> Basically I get fundamentally same result as gptel with just few
> functions in background.

That's all that matters!

Best regards,

Bruno




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-06 22:59 ` Christopher Howard
  2024-12-06 23:21   ` Jean Louis
@ 2024-12-10 10:45   ` Basile Starynkevitch
  1 sibling, 0 replies; 22+ messages in thread
From: Basile Starynkevitch @ 2024-12-10 10:45 UTC (permalink / raw)
  To: Christopher Howard, Jean Louis; +Cc: Emacs Tangents

On Fri, 2024-12-06 at 13:59 -0900, Christopher Howard wrote:
> Jean Louis <bugs@gnu.support> writes:
> 
> > I believe it would be really beneficial to include AI into GNU
> > Emacs. Emacs is already a powerful tool, but adding AI features
> > could
> > make it even better. For example, AI could help with writing by
> > suggesting improvements or catching mistakes. It could also assist
> > with coding by providing smart autocomplete options or debugging
> > help. These features would make Emacs more efficient and
> > user-friendly, helping users get their work done faster and with
> > fewer
> > errors.
> > 
> 
> Could you clarify what you mean exactly but "including AI into GNU
> Emacs"? I know for sure I don't want Emacs sending information about
> my system, or questions that I have about Emacs or my project, off to
> some company's LLM chat system, or however that works exactly. I do
> not want to become dependent on some remote computer program or AI in
> order to be able to write code or figure out how Emacs works.
> 
> I'm certain interested in running tools locally (same computer, or my
> network) that help me with "suggesting improvements, catching
> mistakes", etc. Do you need something massive like ChatGPT to
> accomplish that, or just some Emacs-centric expert systems? Or maybe
> something like MycroftAI, running locally?
> 

Without needing a remote supercomputer, you could run
https://clipsrules.net/ on your Linux desktop (supplying it a rules
source file), or extend https://github.com/RefPerSys/RefPerSys (it is
GPLv3+ work-in-progress inference engine) to run locally on it and
suggest some improvement (or contextual autocompletion) to some EMACS
edited source file.

ChatGPT is certainly not the only possible open source symbolic AI
software, and they don't require a supercomputer or datacenter. For
example GNU prolog is also an open source AI software.

As a concrete example GNU chess is some open source AI program and you
don't need a datacenter to run it.

Very probably, both CLIPSRULES and RefPerSys could be extended (in a
few months of work) for simple tasks like English grammar checking or
English spellchecking.

Regards.
-- 
Basile STARYNKEVITCH           <basile@starynkevitch.net>
8 rue de la Faïencerie
92340 Bourg-la-Reine,          France
http://starynkevitch.net/Basile & https://github.com/bstarynk 



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Including AI into Emacs
  2024-12-10 10:37                 ` Bruno Barbier
@ 2024-12-10 14:27                   ` Jean Louis
  0 siblings, 0 replies; 22+ messages in thread
From: Jean Louis @ 2024-12-10 14:27 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: help-gnu-emacs

* Bruno Barbier <brubar.cs@gmail.com> [2024-12-10 13:38]:
> That's why I pick asynchronous calls when possible: I don't have to care
> about how fast I will get the result.

I see, I can understand that, just I can't be writing and expecting
inconclusive results. I am also not in country with so good
Internet. I can understand you are there, and all is good and fine,
but me no. Location where I am is not reliable for Internet.

Too many times I have lost connection, cannot connect, etc. That is because of Internet.

> > I can't agree to asynchronous injection of text, it sounds dangerous
> > to me. When there is any lag in computer, my text anyway doesn't get
> > well written due to whatever problems and often my speed writing.
> 
> Emacs does this all the time when running processes asynchronously.

Running local process asynchronously is fine and I do it myself many
times. But asking anything from Internet servers is quite different.

I could maybe adopt that approach, just I must be on reliable Internet
connection.

-- 
Jean Louis



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-12-10 14:27 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06 17:22 Including AI into Emacs Jean Louis
2024-12-06 18:25 ` Eli Zaretskii
2024-12-06 18:32   ` John Yates
2024-12-06 19:06   ` Jean Louis
  -- strict thread matches above, loose matches on Subject: below --
2024-12-06 17:19 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).