Skip to content

The agent engineering platform.

ollama[patch]: Support seed param for OllamaLLM (#30553)

Wenqi Li64f97e707ee1
diff --git a/libs/partners/ollama/langchain_ollama/llms.py b/libs/partners/ollama/langchain_ollama/llms.py
index 16b307041b..24708e88b6 100644
--- a/libs/partners/ollama/langchain_ollama/llms.py
+++ b/libs/partners/ollama/langchain_ollama/llms.py
@@ -84,6 +84,11 @@ class OllamaLLM(BaseLLM):
"""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."""
@@ -150,6 +155,7 @@ class OllamaLLM(BaseLLM):
"repeat_last_n": self.repeat_last_n,
"repeat_penalty": self.repeat_penalty,
"temperature": self.temperature,
+ "seed": self.seed,
"stop": self.stop if stop is None else stop,
"tfs_z": self.tfs_z,
"top_k": self.top_k,