From 7da0597ecbb8a1a90df4eb095a8a231c172e9eee Mon Sep 17 00:00:00 2001 From: "Lennart J. Kurzweg" <50501527+noggynoggy@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:15:20 +0200 Subject: [PATCH] partners[ollama]: Support seed parameter for ChatOllama (#24782) ## Description Adds seed parameter to ChatOllama ## Resolves Issues - #24703 ## Dependency Changes None Co-authored-by: Lennart J. Kurzweg (Nx2) --- libs/partners/ollama/langchain_ollama/chat_models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/partners/ollama/langchain_ollama/chat_models.py b/libs/partners/ollama/langchain_ollama/chat_models.py index 0b353f74ace..2d3acc35e8d 100644 --- a/libs/partners/ollama/langchain_ollama/chat_models.py +++ b/libs/partners/ollama/langchain_ollama/chat_models.py @@ -291,6 +291,11 @@ class ChatOllama(BaseChatModel): """The temperature of the model. Increasing the temperature will make the model answer more creatively. (Default: 0.8)""" + seed: Optional[int] = None + """Sets the random number seed to use for generation. Setting this + to a specific number will make the model generate the same text for + the same prompt.""" + stop: Optional[List[str]] = None """Sets the stop tokens to use.""" @@ -335,6 +340,7 @@ class ChatOllama(BaseChatModel): "repeat_last_n": self.repeat_last_n, "repeat_penalty": self.repeat_penalty, "temperature": self.temperature, + "seed": self.seed, "stop": self.stop, "tfs_z": self.tfs_z, "top_k": self.top_k,