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

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

[elpa] externals/llm e7682ad502: Increase and make customizable request


From: ELPA Syncer
Subject: [elpa] externals/llm e7682ad502: Increase and make customizable request timeouts
Date: Thu, 18 Jan 2024 21:58:09 -0500 (EST)

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

    Increase and make customizable request timeouts
    
    This fixes https://github.com/ahyatt/llm/issues/17, although it doesn't 
make a
    Gemini-specific timeout.  I'm still not sure the extent to which we need
    different timeouts for different providers, but a longer timeout in general
    seems sane right now.
---
 NEWS.org       |  2 ++
 llm-request.el | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/NEWS.org b/NEWS.org
index 12d46bea89..47794e6185 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,5 @@
+* Version 0.9.1
+- Add request timeout customization.
 * Version 0.9
 - Add =llm-chat-token-limit= to find the token limit based on the model.
 * Version 0.8
diff --git a/llm-request.el b/llm-request.el
index a8ee5d489b..4241793c02 100644
--- a/llm-request.el
+++ b/llm-request.el
@@ -25,6 +25,18 @@
 (require 'url-http)
 (require 'rx)
 
+(defcustom llm-request-timeout 20
+  "The number of seconds to wait for a response from a HTTP server.
+
+Request timings are depending on the request. Requests that need
+more output may take more time, and there is other processing
+besides just token generation that can take a while. Sometimes
+the LLM can get stuck, and you don't want it to take too long.
+This should be balanced to be good enough for hard requests but
+not very long so that we can end stuck requests."
+  :type 'integer
+  :group 'llm)
+
 (defun llm-request--content ()
   "From the current buffer, return the content of the response."
   (decode-coding-string
@@ -57,7 +69,7 @@ TIMEOUT is the number of seconds to wait for a response."
         (url-request-extra-headers
          (append headers '(("Content-Type" . "application/json"))))
         (url-request-data (encode-coding-string (json-encode data) 'utf-8)))
-    (let ((buf (url-retrieve-synchronously url t nil (or timeout 5))))
+    (let ((buf (url-retrieve-synchronously url t nil (or timeout 
llm-request-timeout))))
       (if buf
           (with-current-buffer buf
             (url-http-parse-response)



reply via email to

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