From 5aaf96e68a5847d7a87154abd22cab4d1e22fd74 Mon Sep 17 00:00:00 2001 From: Sergey Kostyaev Date: Tue, 24 Oct 2023 02:39:24 +0700 Subject: [PATCH] ollama context fix --- llm-ollama.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llm-ollama.el b/llm-ollama.el index d1a7c4b..a6d7dc3 100644 --- a/llm-ollama.el +++ b/llm-ollama.el @@ -113,8 +113,13 @@ STREAMING if non-nil, turn on response streaming." (car (last (llm-chat-prompt-interactions prompt))))))) ;; If the first item isn't an interaction, then it's a conversation which ;; we'll set as the chat context. - (when (not (type-of (car (llm-chat-prompt-interactions prompt)))) - (push `("context" . ,(car (llm-chat-prompt-interactions prompt))) request-alist)) + (when (not (eq (type-of (car (llm-chat-prompt-interactions prompt))) + 'llm-chat-prompt-interaction)) + (push `("context" . ,(cl-remove-if + (lambda (el) + (eq (type-of el) 'llm-chat-prompt-interaction)) + (llm-chat-prompt-interactions prompt))) + request-alist)) (push `("prompt" . ,(string-trim text-prompt)) request-alist) (push `("model" . ,(llm-ollama-chat-model provider)) request-alist) (when (llm-chat-prompt-temperature prompt)