delayedkarma/langchain-issues huggingface dataset:
added trafilatura to webbaseloader
Labels: name: area: doc loader, name: auto:improvement

  - **Description:** The WebBaseLoader has some problems when it came to handling page content properly. These issues ranged from unwanted or missing spaces, to unwanted characters like dots, multiple newlines, and even the addition of header, footer, ads, and other unwanted data in the page content. It was a roadblock that needed a solution. I made changes to extract the page_content using another python package named as trafilatura, which handles all the issues I described earlier. The BeautifulSoup package is still used for metadata extraction, just the text part is extracted using trafilatura.,
  - **Dependencies:** trafilatura,
  - **Tag maintainer:** @baskaryan , @eyurtsev , @hwchase17 ,
  - **Twitter handle:** abrehmaaan
Add async streaming for Bedrock
Labels: name: auto:improvement, name: area: models

### Feature request

Currently, the Bedrock `chat_model` does not support async streaming, which is odd, as the previous [PR](https://github.com/langchain-ai/langchain/pull/10393/files#diff-9874347f7fa335df661ff4089b0922b3214e08a92e9879610424522f806358f7R62) included it; seems that the async method was not added properly.

### Motivation

Without async streaming you cannot pretty much build chatbot infra.

### Your contribution

Not sure, possibly just copying-pasting what was [here](https://github.com/langchain-ai/langchain/pull/10393/files#diff-9874347f7fa335df661ff4089b0922b3214e08a92e9879610424522f806358f7R62) already?
Fix typo in baidu_qianfan_endpoint.ipynb
Labels: name: lgtm, name: auto:documentation

enviroment -> environment

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
ConversationalRetrievalChain Vectorstore cannot apply filter to a key with given multiple values
Labels: name: area: vector store, name: auto:bug, name: auto:improvement

### System Info

on Ubuntu with Python 3.11.5, Langchain 0.0.307


### Who can help?

@hwchase17 

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

What my code basically does is returns an answer to a given question using conversational retrieval chain with a qdrant vectorstore that stores publications. I want the chain to use only the documents published in specified years. 

1. Create vectorstore
qdrant_client = QdrantClient(QDRANT_HOST, port=int(QDRANT_PORT))
retriever = Qdrant(client=qdrant_client, collection_name=QDRANT_COLLECTION, embeddings=get_encoder(ENCODER))

2. Create chain:
rag_chain = ConversationalRetrievalChain.from_llm(llm=llm, 
                                                    retriever = retriever.as_retriever(search_kwargs={"filter": {"year": ["2009","2010"]}), 
                                                    return_source_documents=return_source_documents, 
                                                    verbose=verbose)

3. When I run the chain it retrieves no documents even though it should. 



### Expected behavior

The chain should return documents related to a given question. When I checked the implementation of qdrant.py under langchain vectorstores I saw that _qdrant_filter_from_dict function makes a "must" match; however in my case I need a "should" match since no document can have more than one publication date.
Add patch_config(configurable=) arg, make with_config(configurable=) merge it with existing
Labels: name: auto:improvement



<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
db = FAISS.from_documents(docs, embeddings)  ;how to get docs's index or content from db?
Labels: name: area: vector store, name: auto:question

### System Info

0.0.3

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.faiss.FAISS.html

### Expected behavior

get concrete docs's index or content
Chat model answering incorrectly and weirdly
Labels: name: area: embeddings, name: area: doc loader, name: auto:bug, name: auto:question, name: area: models

![image](https://github.com/langchain-ai/langchain/assets/99576727/2197b06d-c3ff-41a5-b974-6a05a4cbaf8d)
![image](https://github.com/langchain-ai/langchain/assets/99576727/ef268717-044c-475b-8e0d-75cff72e18c5)
![image](https://github.com/langchain-ai/langchain/assets/99576727/ad84e4a7-775e-4793-8f3a-3d7eee863e2e)


I am using the ConversationalRetrievalChain along with DirectoryLoader from LangChain to load PDF files only and answer questions based on the different files in the directory along with returning the source of the answer from the document it got it from. As shown in the 2 pictures, in the first picture I asked it to answer in 1 single sentence but it kept answering and answering then repeated the answer. In the second picture, it rewrote the question again and then answered along with repeating the answers. In the 3rd picture, it answered a question thats not in any of the files in the Directory and it then shows the error of exceeding the rate limit.

I'd like help on how can I make it "listen" to me and how do I fix the rate limit error? I am using OpenAI embeddings for my Q&A chatbot. Does anyone recommend other embeddings that are not OpenAI which I could use for this use case? I plan on later moving my embeddings to the cloud and deploy it.

Thanks in advance
Issue: Inability to serialize langchain modules such as conversational retrieval chain, SQL database 
Labels: name: area: memory, name: auto:bug

### Issue you'd like to raise.

In creating an app, ideally, you would like to let's say 
db = SQLDatabase.from_uri(DATABASE_URI)
in one endpoint, and use the db in other endpoints,
The second endpoint could be what users get access to, so in getting responses, it should be quick, hence only accessing the already loaded db
but I cannot serialize db from the first endpoint, hence i have to include 
db = SQLDatabase.from_uri(DATABASE_URI) 
in the user endpoint, meaning anytime they hit the endpoint, db is run which delays significantly, and doesn't make for a good user experience, how do I solve this issue

### Suggestion:

_No response_
Hallucinations, ignoring data in vector store and returning all documents as sources
Labels: name: area: memory, name: area: vector store, name: auto:bug, name: area: models, name: integration: pinecone

### System Info

IDE==PyCharm
Python==3.11.4
langchain==0.0.306
pinecone-client==2.2.2


### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

The following function in my code with **ConversationalRetrievalChain** runs perfectly. It responds to the question "Hello" appropriately. It answers the questions related to the data in the vector_store:

```python
def get_conversation_chain(vector_store):
    llm = ChatOpenAI()
    memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
    conversation_chain = ConversationalRetrievalChain.from_llm(
        llm=llm,
        retriever=vector_store.as_retriever(),
        memory=memory
    )
    return conversation_chain
```

When the chain is changed to **RetrievalQAWithSourcesChain** with new arguments then the bot responds to the user prompt "hello" with statements about Michael Jackson. It also does not answer questions to data that is contained within the vector store:

```python
def get_conversation_chain(vector_store):
    llm = ChatOpenAI()
    memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True, output_key="answer") 
    conversation_chain = RetrievalQAWithSourcesChain.from_chain_type(
        llm=llm,
        chain_type="stuff",
        retriever=vector_store.as_retriever(),
        # return_source_documents=True,
        memory=memory
    )
    return conversation_chain
```

Everything else in my code remains the same when switching between the 2 functions. The issue only arises when I use the  RetrievalQAWithSourcesChain function above. Also when the return_source_documents=True argument is active, it returns all documents within vector_store instead of only the documents being referenced in the answer.

### Expected behavior

I would expect that the answers from the RetrievalQAWithSourcesChain are the same as with ConversationalRetrievalChain:
- responds appropriately to the user prompt "hello"
- provides an answer referencing data that is contained within the vector_store
- plus returning relevant document sources related to answer.
Update models.py
Labels: name: auto:documentation, name: area: models

Updated comments for better understanding of the search mechanism.

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
ConversationalRetrievalChain + Memory ( New issue for me)
Labels: name: area: memory, name: auto:question, name: auto:improvement, name: area: models

### Issue you'd like to raise.


I've tried building a Bot and now I see the following issue.

Architecture: 

1. Cloud Run service 1 ; Streamlit app which accepts the user_input (question) on the topic and sends it to Flask API part of service 2.
2. Cloud Run service 2: Flask code which calls the LLM code and returns the response to streamlit.

I'm using qa as below.

        qa = ConversationalRetrievalChain.from_llm(
                llm,
                retriever,
                condense_question_prompt=CONDENSE_QUESTION_PROMPT,
                verbose=False,
                memory=memory,
                condense_question_llm =llm,
                return_generated_question= True,
                combine_docs_chain_kwargs={"prompt": promptHist},
                return_source_documents=True,
                )


Issue: If different Users are asking questions through various streamlit sessions, it is using the same chat_history buffer and mixing responses. 

Question: Is there a way to separate the "qa" sessions specific to User and avoid common memory/chat buffer being used ? Is there a utility in Langchain for this?


### Suggestion:

_No response_
GPT4All Model Serializable.__init__ Error
Labels: name: auto:bug, name: area: models

### System Info

Langchain version : 0.0.312
python version: 3.11.4
conda env platform: osx-arm64 / x86
system : macos M1  13.2.1 (22D68)

### Who can help?

@hwchase17 @agola11 

### Information

- [x] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate(template=template, input_variables=["question"])

local_path = ("/Users/langchain-usecase/04-gpt4all/llama-2-7b-chat.ggmlv3.q4_0.bin")


# Callbacks support token-wise streaming
callbacks = [StreamingStdOutCallbackHandler()]

# Verbose is required to pass to the callback manager
llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True)

llm_chain = LLMChain(prompt=prompt, llm=llm)

question = "What NFL team won the Super Bowl in the year Justin Bieber was born?"

llm_chain.run(question)

```

bash output


``` bash
Traceback (most recent call last):
  File "/Users/mac/EasyGithub/test/gpt4all.py", line 45, in <module>
    llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mac/miniforge3/envs/langchain/lib/python3.11/site-packages/langchain/load/serializable.py", line 97, in __init__
    super().__init__(**kwargs)
  File "/Users/mac/miniforge3/envs/langchain/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for GPT4All
__root__ -> __root__
  Serializable.__init__() takes 1 positional argument but 2 were given (type=type_error)


```

### Expected behavior

The same code runs on my other M2 MacMini and generates a reply. I don't know what caused the error. 
![image](https://github.com/langchain-ai/langchain/assets/50387804/a4ea3302-765d-4172-89d2-aabe8fcb713b)


M2 MacMini env info:
python==3.11.4
langchain==0.0.312
conda env platform: osx-arm64
macos==13.4.1
ValueError: "Minimax" object has no field "_client"
Labels: name: auto:bug, name: area: models

### System Info
langchain=0.0.312

### code:
from langchain.llms import Minimax

minimax = Minimax(minimax_api_key=minimax_api_key, minimax_group_id=minimax_group_id)

print(minimax("What is the difference between panda and bear?"))

### or:
from langchain.chat_models import MiniMaxChat
from langchain.schema import HumanMessage
chat = MiniMaxChat()
res = chat(
    [
        HumanMessage(
            content="Translate this sentence from English to French. I love programming."
        )
    ]
)
print(res)

### error log:
  File "E:\AI\Projects\AIProject\AIApiTest\langchain_minimax.py", line 43, in <module>
    llm = Minimax()
  File "D:\anaconda3\envs\ai\lib\site-packages\langchain\llms\minimax.py", line 113, in __init__
    self._client = _MinimaxEndpointClient(
  File "pydantic\main.py", line 357, in pydantic.main.BaseModel.__setattr__
ValueError: "Minimax" object has no field "_client"

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

### code:
from langchain.llms import Minimax

minimax = Minimax(minimax_api_key=minimax_api_key, minimax_group_id=minimax_group_id)

print(minimax("What is the difference between panda and bear?"))

### or:
from langchain.chat_models import MiniMaxChat
from langchain.schema import HumanMessage
chat = MiniMaxChat()
res = chat(
    [
        HumanMessage(
            content="Translate this sentence from English to French. I love programming."
        )
    ]
)
print(res)

### Expected behavior

Fix this bug
FAISS similarity search with score
Labels: name: area: embeddings, name: area: vector store, name: auto:bug

### System Info

langchain==0.0.311
python==3.9

I am trying to find out the similarity search score. but I got the score is abnormal. I hope the score is between 0 and 1.
![image](https://github.com/langchain-ai/langchain/assets/42560553/cbbf8328-29b5-423f-84e4-7d40f4baf280)


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
from torch import cuda
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
from langchain.vectorstores import (FAISS, Chroma)
from langchain.document_loaders import CSVLoader

embed_model_id = 'E:/modelscope/model/hggingface/text2vec-large-chinese'
device = f'cuda:{cuda.current_device()}' if cuda.is_available() else 'cpu'
embedding = HuggingFaceEmbeddings(
    model_name=embed_model_id,
    model_kwargs={'device': device},
    encode_kwargs={'device': device, 'batch_size': 8}
)


def save_faiss_index(file_path: str = './label_remark_openai.csv', encoding: str = 'utf-8',
                     index_name: str = 'label_remark_openai_index',
                     save_path: str = "E:/pythonProject/information_demo/faiss_data"):
    document = CSVLoader(file_path=file_path, encoding=encoding).load()
    FAISS.normalize_L2 = True
    db = FAISS.from_documents(documents=document, embedding=embedding, normalize_L2=True)
    db.save_local(index_name=index_name, folder_path=save_path)


def get_faiss_index(index_name: str = 'label_remark_openai_index',
                    folder_path: str = "E:/pythonProject/information_demo/faiss_data"):
    local_db = FAISS.load_local(index_name=index_name, embeddings=embedding, folder_path=folder_path, normalize_L2=True)

    return local_db

if __name__ == '__main__':
    index = get_faiss_index()
    docs_and_scores = index.similarity_search_with_score("query text", k=10)
    for doc, score in docs_and_scores:
        print(f"Content: {doc.page_content}, Metadata: {doc.metadata}, Score: {score}")
```


### Expected behavior

I hope the score is between 0 and 1.
ArxivLoader always returns 1 document 
Labels: name: area: doc loader, name: auto:bug

### System Info

Python version - Python 3
Langchain version - I am not completely sure, but I think 0.0.196


### Who can help?

@eyurtsev - can you help with the above issue as I see you look after DataLoader Abstractions?

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Code I wrote:

!pip install arxiv
!pip install pymupdf
from langchain.document_loaders import ArxivLoader
docs = ArxivLoader(query="2303.10130", load_max_docs=5, load_all_available_meta='FALSE').load()

### Expected behavior

Problem:
The problem is that I expected 'docs' variable to have at least 5 pages (as the article has 20+ pages) given i have passed the parameter load_max_docs = 5, but it only has 1. I tried with different numbers as well, but to no avail.
create_csv_agent cannot read files hosted on Vercel blob
Labels: name: area: agent, name: area: doc loader, name: auto:bug

### System Info

Flask==3.0.0
Flask-Cors==4.0.0
langchain==0.0.312
openai==0.28.1
pandas==2.1.1
tabulate==0.9.0
numpy==1.26.0

### Who can help?

@eyurtsev 

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
agent = create_csv_agent(
    ChatOpenAI(temperature=0, model="gpt-4", openai_api_key=api_key, verbose=True),
    ["https://loyp2qzippf1q4hd.public.blob.vercel-storage.com/Mock%20Data%20_%20Dumping%20Costs%20-%20Dumping%20Cost-SIU4feVnqtCwoYg2g5Rgy9K5ejfKx0.csv"],
    verbose=True,
    agent_type=AgentType.OPENAI_FUNCTIONS,
    return_intermediate_steps=True,
    agent_executor_kwargs={"handle_parsing_errors": True},
)
```

### Expected behavior

The CSV file should be loaded accordingly