From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU ELPA] New package: llm Date: Sun, 27 Aug 2023 20:19:08 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000036371b0603f0a5d7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31036"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rms@gnu.org, emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 28 02:20:20 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qaPzP-0007qZ-F5 for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Aug 2023 02:20:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qaPyY-0000J2-BZ; Sun, 27 Aug 2023 20:19:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qaPyW-0000Id-Ew for emacs-devel@gnu.org; Sun, 27 Aug 2023 20:19:24 -0400 Original-Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qaPyT-0003BB-Pg; Sun, 27 Aug 2023 20:19:24 -0400 Original-Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-52a3ff5f0abso3606131a12.1; Sun, 27 Aug 2023 17:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693181959; x=1693786759; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AbCXH2aDwnmqdpzGUCV6RWoltM3Rftucn2fb/8hdEUU=; b=o6NdowZANdLDQ3GEtlKqT6pr8M1J2CrzPCo9vxN1CW6KNV5VV/HlN9W6lGr2pyyB9s lRbUYnyoaZOD2fzCP5b6Z0MWD5Q4qZNmTizdokkQ0oDAcwtc6USuv/WOBCv8rMdZeR9X pL+ToQX2sreyMgmgV1HOsGbMcPcvZzK8eiaPs4g8oYcZ4Hy8dn6SwtuO4SZSvB7VEkUF an3bveGg74qymogR/9YCSjlFfsaGQ9oVwkpJKzAiy0194DdQmvOrMsEvGIBuX42HLeqO r1MLk+ACYnJdhxFrjmgLfkdLcCL9Jy+T7nnJlEx7jSWIyeilJQescvqOaHdjjzre8/AU dVUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693181959; x=1693786759; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AbCXH2aDwnmqdpzGUCV6RWoltM3Rftucn2fb/8hdEUU=; b=GKMNUQjWOBoUgrV071MpF1PB35s7pw8QU7QPuhbybS3kKdVuXhuGRAQI3IXb49Vqv2 R6MMrNeQQ8aMD61dni0QtF3G4iFipcqyyrXWlhla1Th7S9T+pF9mWMhxel5ofNs1QS77 siTDpNh6/uy9uIy0XM/ZMS1yM20lgOIZ8En/vsesHPCzPSs7A3t7ZvWJmE4ennjwz058 b+JmXl5fLg+ZfvtxleLzmmZQlwZtYLyBH5NlZ5rc+bx8SHIi5kN7NGDpg2kuyjIe5Hco UsGNC0GbU8UhygQqmYygOcggOBtN1tOPI2R1eVchIIjpPbgBtUuwS74wOFtHxXbGrPfc FxoA== X-Gm-Message-State: AOJu0Yz1zhNbRMLkERfHeEOhNyjQkUItEoaBsnoS2dVg9z7XGF/PkHsW pd+mqgOln/yDSXVxTgshXJ+TERlGJwlDCaUzcXQ= X-Google-Smtp-Source: AGHT+IGDeGqm9LTFjj18gNe8+EB+1PKn3KjzbjlkIwjnIaf+txwdQmBz6i9zQY+1G0dRK1QLiYBJzSMMnZDnMwaunNU= X-Received: by 2002:aa7:d651:0:b0:525:570c:566b with SMTP id v17-20020aa7d651000000b00525570c566bmr19319573edr.22.1693181959090; Sun, 27 Aug 2023 17:19:19 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=ahyatt@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:309380 Archived-At: --00000000000036371b0603f0a5d7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Aug 27, 2023 at 2:36=E2=80=AFPM Jim Porter = wrote: > On 8/26/2023 6:07 PM, Andrew Hyatt wrote: > > To save you the trouble of looking at the code to see what exactly it > > says, here's the function I'm using to warn: > > > > (defun llm--warn-on-nonfree (name tos) > > "Issue a warning if `llm-warn-on-nonfree' is non-nil. > > NAME is the human readable name of the LLM (e.g 'Open AI'). > > > > TOS is the URL of the terms of service for the LLM. > > > > All non-free LLMs should call this function on each llm function > > invocation." > > (when llm-warn-on-nonfree > > (lwarn '(llm nonfree) :warning "%s API is not free software, and > > your freedom to use it is restricted. > > See %s for the details on the restrictions on use." name tos))) > > To make this easier on third parties writing their own implementations > for other LLMs, maybe you could make this (mostly) automatic? I see that > you're using 'cl-defgeneric' in the code, so what about something like > this? > > (cl-defgeneric llm-free-p (provider) > "Return non-nil if PROVIDER is a freedom-respecting model." > nil) > > (cl-defmethod llm-free-p ((provider my-free-llm)) > t) > > Then, if all user-facing functions have some implementation that always > calls this (maybe using the ":before" key for the generic functions?), > third parties won't forget to set up the warning code; instead, they'll > need to explicitly mark their LLM provider as free. > Good idea. I implemented something close to what you suggest, but I had to make a few changes to get it to be workable. Thank you for the suggestion! > I also see that there's a defcustom ('llm-warn-on-nonfree') that lets > people opt out of this. I think it's a good idea to give users that > control, but should this follow a similar pattern to > 'inhibit-startup-echo-area-message'? Its docstring says: > > > The startup message is in the echo area as it provides information > > about GNU Emacs and the GNU system in general, which we want all > > users to see. As this is the least intrusive startup message, > > this variable gets specialized treatment to prevent the message > > from being disabled site-wide by systems administrators, while > > still allowing individual users to do so. > > > > Setting this variable takes effect only if you do it with the > > customization buffer or if your init file contains a line of this > > form: > > (setq inhibit-startup-echo-area-message "YOUR-USER-NAME") > > If we want it to be easy for users to opt out of the message, but hard > for admins (or other packages) to automate opting out, something like > the above might make sense. > Very interesting, thanks. I took a look at the implementation, and I'd prefer not to do anything like that (which involves looking through the user's init file, and seems like it would miss at least some cases). For now, I'll keep it simple. --00000000000036371b0603f0a5d7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Aug 27, 2023 at 2:36=E2=80=AFPM J= im Porter <jporterbugs@gmail.co= m> wrote:
On 8/26/2023 6:07 PM, Andrew Hyatt wrote:
> To save you the trouble of looking at the code to see what exactly it =
> says, here's the function I'm using to warn:
>
> (defun llm--warn-on-nonfree (name tos)
>=C2=A0 =C2=A0 "Issue a warning if `llm-warn-on-nonfree' is non= -nil.
> NAME is the human readable name of the LLM (e.g 'Open AI'). >
> TOS is the URL of the terms of service for the LLM.
>
> All non-free LLMs should call this function on each llm function
> invocation."
>=C2=A0 =C2=A0 (when llm-warn-on-nonfree
>=C2=A0 =C2=A0 =C2=A0 (lwarn '(llm nonfree) :warning "%s API is= not free software, and
> your freedom to use it is restricted.
> See %s for the details on the restrictions on use." name tos)))
To make this easier on third parties writing their own implementations
for other LLMs, maybe you could make this (mostly) automatic? I see that you're using 'cl-defgeneric' in the code, so what about somethi= ng like this?

=C2=A0 =C2=A0(cl-defgeneric llm-free-p (provider)
=C2=A0 =C2=A0 =C2=A0"Return non-nil if PROVIDER is a freedom-respectin= g model."
=C2=A0 =C2=A0 =C2=A0nil)

=C2=A0 =C2=A0(cl-defmethod llm-free-p ((provider my-free-llm))
=C2=A0 =C2=A0 =C2=A0t)

Then, if all user-facing functions have some implementation that always calls this (maybe using the ":before" key for the generic functio= ns?),
third parties won't forget to set up the warning code; instead, they= 9;ll
need to explicitly mark their LLM provider as free.
Good idea.=C2=A0 I implemented something close to what you sug= gest, but I had to make a few changes to get it to be workable.
T= hank you for the suggestion!
=C2=A0
I also see that there's a defcustom ('llm-warn-on-nonfree') tha= t lets
people opt out of this. I think it's a good idea to give users that control, but should this follow a similar pattern to
'inhibit-startup-echo-area-message'? Its docstring says:

> The startup message is in the echo area as it provides information
> about GNU Emacs and the GNU system in general, which we want all
> users to see.=C2=A0 As this is the least intrusive startup message, > this variable gets specialized treatment to prevent the message
> from being disabled site-wide by systems administrators, while
> still allowing individual users to do so.
>
> Setting this variable takes effect only if you do it with the
> customization buffer or if your init file contains a line of this
> form:
>=C2=A0 (setq inhibit-startup-echo-area-message "YOUR-USER-NAME&quo= t;)

If we want it to be easy for users to opt out of the message, but hard
for admins (or other packages) to automate opting out, something like
the above might make sense.

Very intere= sting, thanks.=C2=A0 I took a look at the implementation, and I'd prefe= r not to do anything like that (which involves looking through the user'= ;s init file, and seems like it would miss at least some cases).=C2=A0 For = now, I'll keep it simple.=C2=A0
--00000000000036371b0603f0a5d7--