From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Jim Porter <jporterbugs@gmail.com>
Newsgroups: gmane.emacs.devel
Subject: Re: [NonGNU ELPA] New package: llm
Date: Sun, 27 Aug 2023 11:36:15 -0700
Message-ID: <ee576b8c-4626-ec10-f09b-15255b6bd277@gmail.com>
References: <CAM6wYYJHa+tCUKO_SsnT77g-4MUM0x4FrkoCekr=T9-UF1ADDA@mail.gmail.com>
 <E1qTaA2-00038O-UA@fencepost.gnu.org>
 <CAM6wYY+E=z5VqV2xXMbhbpN7vn+-tyzfOGKFAuG0s+croRmEPA@mail.gmail.com>
 <E1qV08g-0001mb-11@fencepost.gnu.org>
 <CAM6wYYLZ26E4rpo2Ae2PyxKSBYQKAXQ6U5_QGMoGx5SQy7AMSA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="29198"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: emacs-devel@gnu.org
To: Andrew Hyatt <ahyatt@gmail.com>, rms@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 27 20:36:55 2023
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>
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 <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>)
	id 1qaKd5-0007OV-5K
	for ged-emacs-devel@m.gmane-mx.org; Sun, 27 Aug 2023 20:36:55 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-devel-bounces@gnu.org>)
	id 1qaKca-0005PM-PF; Sun, 27 Aug 2023 14:36:24 -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 <jporterbugs@gmail.com>)
 id 1qaKcX-0005OX-8M
 for emacs-devel@gnu.org; Sun, 27 Aug 2023 14:36:21 -0400
Original-Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <jporterbugs@gmail.com>)
 id 1qaKcV-0005qP-0c; Sun, 27 Aug 2023 14:36:20 -0400
Original-Received: by mail-oa1-x36.google.com with SMTP id
 586e51a60fabf-1cc87405650so1719613fac.2; 
 Sun, 27 Aug 2023 11:36:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1693161377; x=1693766177;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:mime-version:date:message-id:from:to:cc
 :subject:date:message-id:reply-to;
 bh=BW1zr3EHsMxqyNXNI/nLALiuIbJZ6Bf7uAJIHDSzphU=;
 b=ijCyVq/GQuUE4GI0fG72TSlTEmr7LACT+80kyMDdK6kYLb68JNqDfPvnmRG0NkY7LB
 4AVFxrDbZcl31PTYY+gtH+bHNedbcQU2PpM1ji8oYHj68WtiIbOxQB+jP0snl1Ujk2A4
 VFQn9P8u31WqU6mL1awNLTcXbWHiqoUP99RNCraWUq1khyvbzDDcaJmogjpAeDnF4ufl
 7/hqR9lLas8Nr2oF+0/1YNJ4Tlfoex6Fqf+3TX93FTxUkJTMFVlAfIRGagBw6ZBbQibA
 FinAs1HHRnypoXh53yUoJovJ4sji5jjSOWl/YS9gfaTKqP1HGzFZuWuttm2OucmFi6ei
 g/QQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693161377; x=1693766177;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:mime-version:date:message-id
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=BW1zr3EHsMxqyNXNI/nLALiuIbJZ6Bf7uAJIHDSzphU=;
 b=bUu+yuOXtKZo1cghwFbrN+FfHFwMwOgaa+QsLEkdAzvyDjnB3m+8jHt1mUXEzJc5bV
 cD8nOr3b3sAs3MEHQx83t5EWdSR4tiSWi8T4AgeOXhkCOzFly6wh2mncnmz4zY2npRln
 8Y6Pfre/QzYyzBJZZUir1lgb34si4lrdcSu5M6ZHUqHZf/IP6PzwxyxzpjkQmeGHt+x1
 nXBvuvoV5sEHCnhWMKaGbAuJIBu+IXtFTfv/hrOxz8+CIW4JErUsJHuhyfo1QFc2B4AE
 olowd/g36Z7Bd2JTwuHBiwVALuOVwd6ZCF0y9iWhLCJn1vEt/j2+K/UdhSIJCgIo2tw6
 /Jow==
X-Gm-Message-State: AOJu0YwIk9jSNDSMsG5Tyl6eLadcf76Gv3uNCVk8Qm0r6cdxs/tZUl6i
 xkwKrQ2sk3ZOpIkVYWuD/cA=
X-Google-Smtp-Source: AGHT+IFVQzryiPumS5KWwumBqlRv0k5RzOSMWMBq0tSOip+m81/YmkpcQYJ+hzkHP4q22XBwQq7LMw==
X-Received: by 2002:a05:6870:8a20:b0:1bf:7c28:9483 with SMTP id
 p32-20020a0568708a2000b001bf7c289483mr11106684oaq.38.1693161376816; 
 Sun, 27 Aug 2023 11:36:16 -0700 (PDT)
Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com.
 [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id
 w27-20020a63af1b000000b0056c24c2e23dsm5652983pge.25.2023.08.27.11.36.15
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 27 Aug 2023 11:36:16 -0700 (PDT)
Content-Language: en-US
In-Reply-To: <CAM6wYYLZ26E4rpo2Ae2PyxKSBYQKAXQ6U5_QGMoGx5SQy7AMSA@mail.gmail.com>
Received-SPF: pass client-ip=2001:4860:4864:20::36;
 envelope-from=jporterbugs@gmail.com; helo=mail-oa1-x36.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,
 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." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=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:309364
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/309364>

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.

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.