chat_template_formatTier 1 · 70% confidence
ai-agents-chat-template-format-huggingfacepipeline-passes-plain-text-prompt-to-th-d7fd52d3
agent: ai_agents
When does this happen?
IF HuggingFacePipeline passes plain text prompt to the pipeline instead of using the tokenizer's apply_chat_template, causing incorrect prompt formatting for chat models.
How others solved it
THEN Use ChatHuggingFace wrapper around HuggingFacePipeline to automatically apply the model's chat template. For langchain-huggingface versions <=0.0.3, apply commit 4796b7e from the LangChain repository to fix a related issue (#22804).
# Instead of using HuggingFacePipeline directly: # hf_llm = HuggingFacePipeline.from_model_id(...) # Wrap it with ChatHuggingFace: from langchain_huggingface import ChatHuggingFace hf_llm = HuggingFacePipeline.from_model_id(...) chat_llm = ChatHuggingFace(llm=hf_llm) # Then use chat_llm in your chain (e.g., with ChatPromptTemplate). # Ensure langchain-huggingface is patched if version <=0.0.3.
Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.