From 69fc2694bbe00bd8242d025904c3ab7bfd6ad795 Mon Sep 17 00:00:00 2001 From: James4Ever0 Date: Fri, 8 Dec 2023 02:58:28 +0800 Subject: [PATCH] Update factory.py Fixing issue when calling from write-the -> langchain -> litellm served ollama --- litellm/llms/prompt_templates/factory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 37c96d77331..4274ef0e1e7 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -74,7 +74,7 @@ def ollama_pt(model, messages): # https://github.com/jmorganca/ollama/blob/af4cf messages=messages ) else: - prompt = "".join(m["content"] for m in messages) + prompt = "".join(m["content"] if isinstance(m['content'], str) is str else "".join(m['content']) for m in messages) return prompt def mistral_instruct_pt(messages): @@ -397,4 +397,4 @@ def prompt_factory(model: str, messages: list, custom_llm_provider: Optional[str return hf_chat_template(original_model_name, messages) except: return default_pt(messages=messages) # default that covers Bloom, T-5, any non-chat tuned model (e.g. base Llama2) - \ No newline at end of file +