Enable llm.el to work with ollama models
This commit is contained in:
parent
71c86332c5
commit
3c09eb3cbd
@ -121,16 +121,26 @@ The process is named NAME and runs in BUFFER-NAME."
|
|||||||
(split-string (shell-command-to-string
|
(split-string (shell-command-to-string
|
||||||
(format "%s models" (executable-find llm-executable)))
|
(format "%s models" (executable-find llm-executable)))
|
||||||
"\n" t " "))
|
"\n" t " "))
|
||||||
(models (mapcar (lambda (s)
|
(models (mapcar
|
||||||
(cons s (cadr (s-match ".*?: \\(.*?\\) -" s))))
|
(lambda (s)
|
||||||
model-strings))
|
(cons s
|
||||||
|
(cadr
|
||||||
|
(s-match ".*?: \\(.*?\\)\\(?:[[:blank:]]\\|$\\)" s))))
|
||||||
|
model-strings))
|
||||||
(selected (completing-read "Model: " models)))
|
(selected (completing-read "Model: " models)))
|
||||||
(alist-get selected models nil nil #'equal))))
|
(alist-get selected models nil nil #'equal))))
|
||||||
(setq llm-model model))
|
(setq llm-model model))
|
||||||
|
|
||||||
|
(defvar llm-model-extra-args-alist
|
||||||
|
`(("Meta-Llama-3-8B-Instruct" . ("-o" "max_tokens" ,(number-to-string llm-max-tokens))))
|
||||||
|
"Alist mapping model names to extra arguments to pass to llm.")
|
||||||
|
|
||||||
(defun llm--prompt-args (query &rest extra-args)
|
(defun llm--prompt-args (query &rest extra-args)
|
||||||
"Return the arguments to prompt LLM with QUERY, appending EXTRA-ARGS."
|
"Return the arguments to prompt LLM with QUERY, appending EXTRA-ARGS."
|
||||||
(let* ((args (list "-o" "max_tokens" (number-to-string llm-max-tokens)))
|
(let* ((args nil)
|
||||||
|
(args (if-let ((extra-args (alist-get llm-model llm-model-extra-args-alist nil nil #'equal)))
|
||||||
|
(append extra-args args)
|
||||||
|
args))
|
||||||
(args (if llm-model
|
(args (if llm-model
|
||||||
(append (list "--model" llm-model) args)
|
(append (list "--model" llm-model) args)
|
||||||
args))
|
args))
|
||||||
|
Loading…
Reference in New Issue
Block a user