Questions tagged [py-langchain]

LangChain is an open-source framework for developing applications powered by language models. Use this tag for the python-specific package.

LangChain is an open-source framework for developing applications powered by language models. Use this tag for the python-specific package.

Official Python LangChain documentation: https://python.langchain.com/en/latest/

153 questions
8
votes
4 answers

How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain?

How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain? For the past 2 weeks ive been trying to make a chatbot that can chat over documents (so not in just a semantic search/qa so with…
8
votes
4 answers

LangChain Chroma - load data from Vector Database

I have written LangChain code using Chroma DB to vector store the data from a website url. It currently works to get the data from the URL, store it into the project folder and then use that data to respond to a user prompt. I figured out how to…
max choate
  • 81
  • 1
  • 3
6
votes
0 answers

Refer to specific files using LangChain & Question-Answering about differences/comparisons

I have not found documentation regarding Question-Answering based on multiple text files, while referencing the text files individually. Example: I have file1.txt through file20.txt. file1.txt is from April 2023 and file5.txt is from March…
Jay Jung
  • 1,805
  • 3
  • 23
  • 46
5
votes
1 answer

Are Langchain toolkits able to be modified? Can we add tools to a pandas_dataframe_agent toolkit?

I'm new to langchain, so I'm guessing this is possible but demonstrates my lack of a full understanding of the components in langchain. I have successfully created and used the Pandas Dataframe Agent toolkit to analyze a small dataframe. I have…
5
votes
1 answer

define an output schema for a nested json in langchain

Whats the recommended way to define an output schema for a nested json, the method I use doesn't feel ideal. # adding to planner -> from langchain.experimental.plan_and_execute import load_chat_planner refinement_response_schemas = [ …
Zizi96
  • 459
  • 1
  • 6
  • 23
5
votes
2 answers

How to incorporate context/chat history in OpenAI ChatBot using ChatGPT and langchain in Python?

Please bear with me as this is literally the first major code I have ever written and its for OpenAI's ChatGPT API. What I intend to do with this code is load a pdf document or a group of pdf documents. Then split them up so as to not use up my…
Ali Q
  • 51
  • 4
4
votes
3 answers

Langchain: text splitter behavior

I don't understand the following behavior of Langchain recursive text splitter. Here is my code and output. from langchain.text_splitter import RecursiveCharacterTextSplitter r_splitter = RecursiveCharacterTextSplitter( chunk_size=10, …
GreenEye
  • 153
  • 2
  • 14
4
votes
2 answers

How to use the new gpt-3.5-16k model with langchain?

I have written an application in langchain that passes a number of chains to a Sequential Chain to run. The problem I'm having is that the prompts are so large that they are exceeding the 4K token limit size. I saw that OpenAI has released a new…
redmage123
  • 413
  • 8
  • 15
4
votes
3 answers

TypeError: issubclass() arg 1 must be a class when importing langchain in Flask

I am doing a microservice with a document loader, and the app can't launch at the import level, when trying to import langchain's UnstructuredMarkdownLoader $ flask --app main run --debug Traceback (most recent call last): File "venv/bin/flask",…
prout
  • 317
  • 5
  • 18
4
votes
2 answers

How to load a folder of Json files in Langchain?

I am trying to load a folder of JSON files in Langchain as: loader = DirectoryLoader(r'C:...') documents = loader.load() But I got such an error message: ValueError: Json schema does not match the Unstructured schema Can anyone tell me how to…
peiwb
  • 41
  • 1
  • 2
4
votes
1 answer

ValueError: `run` not supported when there is not exactly one output key. Got ['answer', 'sources', 'source_documents']. (langchain/Streamlit)

I got an error says ValueError: `run` not supported when there is not exactly one output key. Got ['answer', 'sources', 'source_documents']. Here's the traceback error File…
naranara
  • 151
  • 1
  • 10
4
votes
1 answer

Get all documents from ChromaDb using Python and langchain

I'm using langchain to process a whole bunch of documents which are in an Mongo database. I can load all documents fine into the chromadb vector storage using langchain. Nothing fancy being done here. This is my code: from…
user791793
  • 413
  • 1
  • 6
  • 19
4
votes
1 answer

langchain with context and memory

I'm attempting to modify an existing Colab example to combine langchain memory and also context document loading. In two separate tests, each instance works perfectly. Now I'd like to combine the two (training context loading and conversation…
Chris Vorster
  • 41
  • 1
  • 2
3
votes
1 answer

Why is RecursiveCharacterTextSplitter not giving any chunk overlap?

I am trying to create chunks (max) 350 characters long with 100 chunk overlap. I understand that chunk_size is an upper limit, so I may get chunks shorter than that. But why am I not getting any chunk_overlap? Is it because the overlap also has to…
codeananda
  • 939
  • 1
  • 10
  • 16
3
votes
0 answers

Dynamically add more embedding of new document in chroma DB - Langchain

I have created a retrieval QA Chain which uses chromadb as vector DB for storing embeddings of "abc.txt" file. What if I want to dynamically add more document embeddings of let's say another file "def.txt"? How to do that? I don't want to reload the…
Jason
  • 676
  • 1
  • 12
  • 34
1
2 3
10 11