emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/llm cff9ab8f3c 22/34: Centralize nonfree llm warnings,


From: Andrew Hyatt
Subject: [elpa] externals/llm cff9ab8f3c 22/34: Centralize nonfree llm warnings, and warn with a targeted type
Date: Sat, 16 Sep 2023 01:32:49 -0400 (EDT)

branch: externals/llm
commit cff9ab8f3c65f7ad92f0f0cb133df980cbcd4d6e
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>

    Centralize nonfree llm warnings, and warn with a targeted type
---
 llm-openai.el | 4 +---
 llm-vertex.el | 4 +---
 llm.el        | 6 ++++++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/llm-openai.el b/llm-openai.el
index ec20d34875..a0e0c4fe56 100644
--- a/llm-openai.el
+++ b/llm-openai.el
@@ -51,9 +51,7 @@ will use a reasonable default."
   key chat-model embedding-model)
 
 (defun llm-openai--maybe-warn ()
-  (when llm-warn-on-nonfree
-    (warn "Open AI's API is not free software, and your freedom to use it is 
restricted by Open AI's terms of service.
-See https://openai.com/policies/terms-of-use for the restrictions on use.")))
+  (llm--warn-on-nonfree "Open AI" "https://openai.com/policies/terms-of-use";))
 
 (defun llm-openai--embedding-make-request (provider string vector-callback 
error-callback sync)
   "Make a request to Open AI to get an embedding for STRING.
diff --git a/llm-vertex.el b/llm-vertex.el
index 551403a59e..e072ee533a 100644
--- a/llm-vertex.el
+++ b/llm-vertex.el
@@ -70,9 +70,7 @@ KEY-GENTIME keeps track of when the key was generated, 
because the key must be r
     (setf (llm-vertex-key-gentime provider) (current-time))))
 
 (defun llm-vertex-maybe-warn ()
-  (when llm-warn-on-nonfree
-    (warn "Google Cloud's Vertex AI is not free software, and your freedom to 
use it is restricted by Google's terms of service.
-See https://policies.google.com/terms/generative-ai for more information.")))
+  (llm--warn-on-nonfree "Google Cloud Vertex" 
"https://policies.google.com/terms/generative-ai";))
 
 (defun llm-vertex--embedding (provider string vector-callback error-callback 
sync)
   "Get the embedding for STRING.
diff --git a/llm.el b/llm.el
index de2e05bbe3..408a5ab17b 100644
--- a/llm.el
+++ b/llm.el
@@ -48,6 +48,12 @@
   "Whether to issue a warning when using a non-free LLM."
   :type 'boolean)
 
+(defun llm--warn-on-nonfree (name tos)
+  "Issue a warning if `llm-warn-on-nonfree' is non-nil."
+  (when llm-warn-on-nonfree
+    (lwarn '(llm nonfree) :warning "%s API is not free software, and your 
freedom to use it restricted.
+See %s for the details on the restrictions on use." name tos)))
+
 (cl-defstruct llm-chat-prompt
   "This stores all the information needed for a structured chat prompt.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]