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

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

[elpa] externals/llm ad230d9d6b 10/34: Add methods for nil provider, to


From: Andrew Hyatt
Subject: [elpa] externals/llm ad230d9d6b 10/34: Add methods for nil provider, to throw more meaningful errors
Date: Sat, 16 Sep 2023 01:32:48 -0400 (EDT)

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

    Add methods for nil provider, to throw more meaningful errors
---
 llm.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/llm.el b/llm.el
index e527dd9273..f513489f09 100644
--- a/llm.el
+++ b/llm.el
@@ -93,6 +93,9 @@ The return value will be the value passed into the success 
callback."
 PROMPT is a `llm-chat-prompt'. The response is a string."
   (llm--run-async-as-sync #'llm-chat-response-async provider prompt))
 
+(cl-defmethod llm-chat-response ((_ (eql nil)) _)
+  (error "LLM provider was nil.  Please set the provider in the application 
you are using."))
+
 (cl-defgeneric llm-chat-response-async (provider prompt response-callback 
error-callback)
   "Return a response to PROMPT from PROVIDER.
 PROMPT is a `llm-chat-prompt'.
@@ -101,10 +104,16 @@ ERROR-CALLBACK receives the error response."
   (ignore provider prompt response-callback error-callback)
   (signal 'not-implemented nil))
 
+(cl-defmethod llm-chat-response-async ((_ (eql nil)) _ _ _)
+  (error "LLM provider was nil.  Please set the provider in the application 
you are using."))
+
 (cl-defgeneric llm-embedding (provider string)
   "Return a vector embedding of STRING from PROVIDER."
   (llm--run-async-as-sync #'llm-embedding-async provider string))
 
+(cl-defmethod llm-chat-embedding ((_ (eql nil)) _)
+  (error "LLM provider was nil.  Please set the provider in the application 
you are using."))
+
 (cl-defgeneric llm-embedding-async (provider string vector-callback 
error-callback)
   "Calculate a vector embedding of STRING from PROVIDER.
 VECTOR-CALLBACK will be called with the vector embedding.
@@ -113,6 +122,9 @@ error signal and a string message."
   (ignore provider string vector-callback error-callback)
   (signal 'not-implemented nil))
 
+(cl-defmethod llm-embedding-async ((_ (eql nil)) _ _ _)
+  (error "LLM provider was nil.  Please set the provider in the application 
you are using."))
+
 (cl-defgeneric llm-count-tokens (provider string)
   "Return the number of tokens in STRING from PROVIDER.
 This may be an estimate if the LLM does not provide an exact



reply via email to

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