From 9024593468346e322c1f36ae50182703e6b665e5 Mon Sep 17 00:00:00 2001 From: "Govind.S.B" Date: Mon, 13 Nov 2023 22:15:11 +0530 Subject: [PATCH] added system prompt and template fields to ollama (#13022) **Description** the ollama api now supports passing system prompt and template directly instead of modifying the model file , but the ollama integration in langchain did not have this change updated . The update just adds these two parameters to it ( there are 2 more parameters that are pending to be updated, I was not sure about their utility wrt to langchain ) Refer : https://github.com/jmorganca/ollama/commit/8713ac23a86e1eaf8b94f93bb0d51d13b0225d87 **Issue** : None Applicable **Dependencies** : None Changed **Twitter handle** : https://twitter.com/violetto96 --------- Co-authored-by: Eugene Yurtsev --- libs/langchain/langchain/llms/ollama.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/langchain/langchain/llms/ollama.py b/libs/langchain/langchain/llms/ollama.py index f0652981756..8f5e3035100 100644 --- a/libs/langchain/langchain/llms/ollama.py +++ b/libs/langchain/langchain/llms/ollama.py @@ -89,6 +89,12 @@ class _OllamaCommon(BaseLanguageModel): to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text. (Default: 0.9)""" + system: Optional[str] = None + """system prompt (overrides what is defined in the Modelfile)""" + + template: Optional[str] = None + """full prompt or prompt template (overrides what is defined in the Modelfile)""" + @property def _default_params(self) -> Dict[str, Any]: """Get the default parameters for calling Ollama.""" @@ -109,6 +115,8 @@ class _OllamaCommon(BaseLanguageModel): "top_k": self.top_k, "top_p": self.top_p, }, + "system": self.system, + "template": self.template, } @property