Skip to content

Commit 3e45ad0

Browse files
committed
Done content
1 parent 8ab18a6 commit 3e45ad0

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

google-gemini-content.el

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,32 @@
2929
;;
3030
;;; API
3131

32-
(defun google-gemini-content-make-contents (text)
33-
"Create a contents value."
34-
`((parts . [((text . ,text))])))
35-
3632
;;;###autoload
37-
(cl-defun google-gemini-content-generate ( contents callback
33+
(cl-defun google-gemini-content-generate ( text callback
3834
&key
39-
(content-type "application/json"))
35+
(content-type "application/json")
36+
(category "HARM_CATEGORY_DANGEROUS_CONTENT")
37+
(threshold "BLOCK_ONLY_HIGH")
38+
stop-sequences
39+
temperature
40+
max-output-tokens
41+
top-p
42+
top-k)
4043
"Send generate content request."
4144
(request (format "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=%s"
4245
google-gemini-key)
4346
:type "POST"
4447
:headers (google-gemini--headers content-type)
4548
:data (google-gemini--json-encode
46-
`(("contents" . [,contents])))
49+
`(("contents" . [((parts . [((text . ,text))]))])
50+
("safetySettings" . [(("category" . ,category)
51+
("threshold" . ,threshold))])
52+
("generationConfig" .
53+
(("stopSequences" . ,stop-sequences)
54+
("temperature" . ,temperature)
55+
("maxOutputTokens" . ,max-output-tokens)
56+
("topP" . ,top-p)
57+
("topK" . ,top-k)))))
4758
:parser 'json-read
4859
:complete (cl-function
4960
(lambda (&key data &allow-other-keys)
@@ -56,9 +67,8 @@
5667
(defun google-gemini-content-prompt ()
5768
"Start making a conversation to Google Gemini."
5869
(interactive)
59-
(if-let* ((text (read-string "Content: "))
60-
(contents (google-gemini-content-make-contents text)))
61-
(google-gemini-content-generate contents
70+
(if-let ((text (read-string "Content: ")))
71+
(google-gemini-content-generate text
6272
(lambda (data)
6373
(let-alist data
6474
(let-alist (elt .candidates 0)

0 commit comments

Comments
 (0)