Relative Content

Tag Archive for pythonlangchainpy-langchain

Chaining langchain responses using LCEL

I’ve started working with Langchain to get a feel of it and a lot of the videos seem outdated. After some research I learned about LCEL being used as the other methods seem to be deprecated. In my code I’m trying to use the output of one chain as the input for another but it doesn’t seem to work.

How to fix “AttributeError: ‘str’ object has no attribute ‘query'” in langchain?

retriver = PineconeVectorStore( pinecone_api_key=pc_key, index=”index-1″, embedding=OpenAIEmbeddings() ).as_retriever() qa_chain = ( { “context”: retriver, “question”: RunnablePassthrough(), } | review_template | model | StrOutputParser() ) res =qa_chain.invoke(“Question”) print(res) Output of the code snipet : “AttributeError: ‘str’ object has no attribute ‘query” Expecting Output: retrive data from pinecone vectordb and create good answer for users. python langchain py-langchain

Langchain message history with message length limiting

My goal is to limit the last N messages in a message history so I don’t overload the LLM. My plan is to use use RunnableWithMessageHistory in conjunction with a filter function. Unfortunately I seem to have two problems: 1) getting the limiting function to work; and 2) passing the actual user message into the model.