chain = "prompt | model" # String instead of LCEL runnable
chain.invoke({"input": "hi"})
Error:
AttributeError: 'str' object has no attribute 'invoke'

chain = "prompt | model" # String instead of LCEL runnable
chain.invoke({"input": "hi"})
Error:
AttributeError: 'str' object has no attribute 'invoke'
Fix:
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
prompt = ChatPromptTemplate.from_template("{input}")
model = ChatOpenAI()
chain = prompt | model # Combine actual objects with pipe operator
Tell us about your project and get help tailored to your problem.
Contact usEveryone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.