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

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

[elpa] externals/llm 9e3040bad2 20/34: Add warnings requested by GNU abo


From: Andrew Hyatt
Subject: [elpa] externals/llm 9e3040bad2 20/34: Add warnings requested by GNU about nonfree software
Date: Sat, 16 Sep 2023 01:32:49 -0400 (EDT)

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

    Add warnings requested by GNU about nonfree software
    
    Also this correctly sets up the LLM customization group.
---
 llm-openai.el | 7 +++++++
 llm-vertex.el | 7 +++++++
 llm.el        | 8 ++++++++
 3 files changed, 22 insertions(+)

diff --git a/llm-openai.el b/llm-openai.el
index 199ee86f14..ec20d34875 100644
--- a/llm-openai.el
+++ b/llm-openai.el
@@ -50,11 +50,17 @@ EMBEDDING-MODEL is the model to use for embeddings.  If 
unset, it
 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.")))
+
 (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.
 PROVIDER, VECTOR-CALLBACK and ERROR-CALLBACK are as in the
 `llm-embedding-async' call. SYNC is non-nil when the request
 should wait until the response is received."
+  (llm-openai--maybe-warn)
   (unless (llm-openai-key provider)
     (error "To call Open AI API, add a key to the `llm-openai' provider."))
   (request "https://api.openai.com/v1/embeddings";
@@ -98,6 +104,7 @@ ERROR-CALLBACK is called if there is an error, with the error
 signal and message.
 
 SYNC is non-nil when the request should wait until the response is received."
+  (llm-openai--maybe-warn)
   (unless (llm-openai-key provider)
     (error "To call Open AI API, the key must have been set"))
   (let (request-alist system-prompt)
diff --git a/llm-vertex.el b/llm-vertex.el
index 25f0be4259..551403a59e 100644
--- a/llm-vertex.el
+++ b/llm-vertex.el
@@ -69,12 +69,18 @@ KEY-GENTIME keeps track of when the key was generated, 
because the key must be r
       (setf (llm-vertex-key provider) result))
     (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.")))
+
 (defun llm-vertex--embedding (provider string vector-callback error-callback 
sync)
   "Get the embedding for STRING.
 PROVIDER, VECTOR-CALLBACK, ERROR-CALLBACK are all the same as
 `llm-embedding-async'. SYNC, when non-nil, will wait until the
 response is available to return."
   (llm-vertex-refresh-key provider)
+  (llm-vertex-maybe-warn)
   (request (format 
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:predict";
                                llm-vertex-gcloud-region
                                (llm-vertex-project provider)
@@ -112,6 +118,7 @@ PROVIDER, RESPONSE-CALLBACK, ERROR-CALLBACK are all the 
same as
 `llm-chat-response-async'. SYNC, when non-nil, will wait until
 the response is available to return."
   (llm-vertex-refresh-key provider)
+  (llm-vertex-maybe-warn)
   (let ((request-alist))
     (when (llm-chat-prompt-context prompt)
       (push `("context" . ,(llm-chat-prompt-context prompt)) request-alist))
diff --git a/llm.el b/llm.el
index f01a130cf8..de2e05bbe3 100644
--- a/llm.el
+++ b/llm.el
@@ -40,6 +40,14 @@
 
 (require 'cl-lib)
 
+(defgroup llm nil
+  "Interface to pluggable llm backends."
+  :group 'external)
+
+(defcustom llm-warn-on-nonfree t
+  "Whether to issue a warning when using a non-free LLM."
+  :type 'boolean)
+
 (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]