[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/llm c322577b9b 13/34: Test both sync and async commands
From: |
Andrew Hyatt |
Subject: |
[elpa] externals/llm c322577b9b 13/34: Test both sync and async commands |
Date: |
Sat, 16 Sep 2023 01:32:48 -0400 (EDT) |
branch: externals/llm
commit c322577b9b31f3b17e4540812fddad0156965144
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
Test both sync and async commands
---
llm-tester.el | 46 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/llm-tester.el b/llm-tester.el
index 78a578d8a1..c6e09c9e09 100644
--- a/llm-tester.el
+++ b/llm-tester.el
@@ -34,8 +34,8 @@
(require 'llm)
-(defun llm-tester-embedding (provider)
- "Test that PROVIDER can provide embeddings."
+(defun llm-tester-embedding-async (provider)
+ "Test that PROVIDER can provide embeddings in an async call."
(message "Testing provider %s for embeddings" (type-of provider))
(llm-embedding-async provider "This is a test."
(lambda (embedding)
@@ -50,7 +50,20 @@
(lambda (type message)
(message "ERROR: Provider %s returned an error of
type %s with message %s" (type-of provider) type message))))
-(defun llm-tester-chat (provider)
+(defun llm-tester-embedding-sync (provider)
+ "Test that PROVIDER can provide embeddings in a sync call."
+ (message "Testing provider %s for embeddings" (type-of provider))
+ (let ((embedding (llm-embedding provider "This is a test.")))
+ (if embedding
+ (if (eq (type-of embedding) 'vector)
+ (if (> (length embedding) 0)
+ (message "SUCCESS: Provider %s provided an embedding of length
%d. First 10 values: %S" (type-of provider)
+ (length embedding)
+ (seq-subseq embedding 0 (min 10 (length embedding))))
+ (message "ERROR: Provider %s returned an empty embedding"
(type-of provider))))
+ (message "ERROR: Provider %s did not return any embedding" (type-of
provider)))))
+
+(defun llm-tester-chat-async (provider)
"Test that PROVIDER can interact with the LLM chat."
(message "Testing provider %s for chat" (type-of provider))
(llm-chat-response-async
@@ -74,10 +87,33 @@
(lambda (type message)
(message "ERROR: Provider %s returned an error of type %s with message
%s" (type-of provider) type message))))
+(defun llm-tester-chat-sync (provider)
+ "Test that PROVIDER can interact with the LLM chat."
+ (message "Testing provider %s for chat" (type-of provider))
+ (let ((response (llm-chat-response
+ provider
+ (make-llm-chat-prompt
+ :interactions (list
+ (make-llm-chat-prompt-interaction
+ :role 'user
+ :content "Tell me a random cool feature of
emacs."))
+ :context "You must answer all questions as if you were the
butler Jeeves from Jeeves and Wooster. Start all interactions with the phrase,
'Very good, sir.'"
+ :examples '(("Tell me the capital of France." . "Very
good, sir. The capital of France is Paris, which I expect you to be familiar
with, since you were just there last week with your Aunt Agatha.")
+ ("Could you take me to my favorite place?" .
"Very good, sir. I believe you are referring to the Drone's Club, which I will
take you to after you put on your evening attire."))
+ :temperature 0.5
+ :max-tokens 100))))
+ (if response
+ (if (> (length response) 0)
+ (message "SUCCESS: Provider %s provided a response %s" (type-of
provider) response)
+ (message "ERROR: Provider %s returned an empty response" (type-of
provider)))
+ (message "ERROR: Provider %s did not return any response" (type-of
provider)))))
+
(defun llm-tester-all (provider)
"Test all llm functionality for PROVIDER."
- (llm-tester-embedding provider)
- (llm-tester-chat provider))
+ (llm-tester-embedding-sync provider)
+ (llm-tester-chat-sync provider)
+ (llm-tester-embedding-async provider)
+ (llm-tester-chat-async provider))
(provide 'llm-tester)
- [elpa] branch externals/llm created (now 39ae6fc794), Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 3b761aca25 02/34: Add README.org, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm ad76cff80b 01/34: Initial checkin of the llm package for emacs., Andrew Hyatt, 2023/09/16
- [elpa] externals/llm cff5db8ad5 16/34: Add unit tests and fix all brokenness detected by them, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 131a7ee5d3 12/34: Solve flaky errors when using sync llm commands, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 48ae59d149 14/34: Fix llm-chat-prompt-to-text, which was unusable, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 636014bf64 08/34: Make all remaining code async-friendly, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 9e3040bad2 20/34: Add warnings requested by GNU about nonfree software, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm c8b14b4d9c 19/34: Fix fake provider embedding func and remove async unit tests, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 9057a50df4 11/34: Fix indenting in llm--run-async-as-sync, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm c322577b9b 13/34: Test both sync and async commands,
Andrew Hyatt <=
- [elpa] externals/llm cff9ab8f3c 22/34: Centralize nonfree llm warnings, and warn with a targeted type, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm ad230d9d6b 10/34: Add methods for nil provider, to throw more meaningful errors, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 650bba65d5 25/34: Improve the docstring for llm--warn-on-nonfree, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm b2f1605514 33/34: Delete some trailing whitespace, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 39ae6fc794 34/34: Assign copyright to FSF, in preparation of inclusion to GNU ELPA, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 9a3fc01cac 17/34: Switch from generic to per-provider sync solution, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm eba797b295 04/34: Implement error handling for gcloud auth issues, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 16ee85fd11 05/34: Add async options, and made the sync options just use those and wait, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm 3919b77383 06/34: Implement confusion and typos in README.org, Andrew Hyatt, 2023/09/16
- [elpa] externals/llm b52958757a 18/34: Fix docstring wider than 80 characters in llm-vertex, Andrew Hyatt, 2023/09/16