[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel ef8b9093d2 206/273: gptel-gemini: Use permissive API
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel ef8b9093d2 206/273: gptel-gemini: Use permissive API safety settings |
Date: |
Wed, 1 May 2024 10:02:24 -0400 (EDT) |
branch: elpa/gptel
commit ef8b9093d2a0a957be52437956245d2b3ffeaf98
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel-gemini: Use permissive API safety settings
* gptel-gemini.el (gptel-make-gemini, gptel--request-data): The
Gemini API misclassifies harmless questions (like "What's 2+2",
see #208) as harmful. Use the most permissive safety settings the
API offers.
Also respect the value of `:stream` used when defining Gemini
backends.
---
gptel-gemini.el | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/gptel-gemini.el b/gptel-gemini.el
index 27ce987a2c..90119a3cfc 100644
--- a/gptel-gemini.el
+++ b/gptel-gemini.el
@@ -60,7 +60,15 @@
(cl-defmethod gptel--request-data ((_backend gptel-gemini) prompts)
"JSON encode PROMPTS for sending to Gemini."
(let ((prompts-plist
- `(:contents [,@prompts]))
+ `(:contents [,@prompts]
+ :safetySettings [(:category "HARM_CATEGORY_HARASSMENT"
+ :threshold "BLOCK_NONE")
+ (:category "HARM_CATEGORY_SEXUALLY_EXPLICIT"
+ :threshold "BLOCK_NONE")
+ (:category "HARM_CATEGORY_DANGEROUS_CONTENT"
+ :threshold "BLOCK_NONE")
+ (:category "HARM_CATEGORY_HATE_SPEECH"
+ :threshold "BLOCK_NONE")]))
params)
(when gptel-temperature
(setq params
@@ -103,7 +111,7 @@
;;;###autoload
(cl-defun gptel-make-gemini
- (name &key header key stream
+ (name &key header key (stream nil)
(host "generativelanguage.googleapis.com")
(protocol "https")
(models '("gemini-pro"))
@@ -146,12 +154,17 @@ function that returns the key."
:stream stream
:key key
:url
- (lambda ()
- (concat protocol "://" host endpoint
- (if gptel-stream
- "streamGenerateContent"
- "generateContent")
- "?key=" (gptel--get-api-key))))))
+ (if stream
+ (lambda ()
+ (concat protocol "://" host endpoint
+ (if gptel-stream
+ "streamGenerateContent"
+ "generateContent")
+ "?key=" (gptel--get-api-key)))
+ (lambda ()
+ (concat protocol "://" host endpoint
+ "generateContent" "?key="
+ (gptel--get-api-key)))))))
(prog1 backend
(setf (alist-get name gptel--known-backends
nil nil #'equal)
- [nongnu] elpa/gptel de6d8089cd 136/273: gptel-transient: Fix system-message setting function, (continued)
- [nongnu] elpa/gptel de6d8089cd 136/273: gptel-transient: Fix system-message setting function, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 6af89254b7 124/273: README: Document breaking changes (mainly `gptel-host` deprecation), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 84cd7bf5a4 144/273: gptel-gemini: Add Gemini support, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 38095eaed5 146/273: gptel: Fix prompt collection bug + linting, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 4775ade6e0 150/273: gptel: add custom gptel-update-destination, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 7271d0e408 154/273: gptel: Try to save/restore gptel-backend in files, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 7b19cdf117 188/273: Sanitize gpt-model value just in time, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 89decb4201 192/273: README: Mention transient menu option saving, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel c41a53f526 194/273: gptel: save/restore multi-line directives (#180), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel e2eccd8b08 205/273: gptel: Remove references to gptel--debug (fix #205), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel ef8b9093d2 206/273: gptel-gemini: Use permissive API safety settings,
ELPA Syncer <=
- [nongnu] elpa/gptel 5e9e36d854 219/273: gptel: rear-nonsticky text-property by default, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 3d6147830e 220/273: gptel: Fix model/backend mismatch (#242), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 07992f79cc 227/273: gptel-anthropic: Support for the Claude haiku model, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel fbb0ee29c4 224/273: gptel-org-test: Add mores tests for org conversion, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 376fb4b423 234/273: gptel-transient: Additional directives option (#249), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 34a52aa047 246/273: gptel-anthropic: Remove debug code, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel e3b3591d73 240/273: README: Add support for Groq (#257), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 81bb467104 250/273: gptel: Set window when running post-response hook, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel b4088e3f7b 261/273: README: New pacakge based on gptel, magit-gptcommit (#281), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 9b094b8b1e 265/273: gptel: Fix url-retrieve response parser bug, ELPA Syncer, 2024/05/01