delayedkarma/langchain-issues huggingface dataset:
Add user_context to AmazonKendraRetriever
Labels: name: lgtm, name: auto:improvement

### Description 

Now, we can pass information like a JWT token using user_context:  

```python
self.retriever = AmazonKendraRetriever(index_id=kendraIndexId, user_context={"Token": jwt_token})
```

- [x] `make lint`
- [x] `make format`
- [x] `make test`

Also tested by pip installing in my own project, and it allows access through the token. 

### Maintainers 

 @rlancemartin, @eyurtsev

### My twitter handle 

[girlknowstech](https://twitter.com/girlknowstech)

### Tests passed 

```
-------------------------------------------------------------------------------------------------------- snapshot report summary --------------------------------------------------------------------------------------------------------
22 snapshots passed.
========================================================================================================== slowest 5 durations ==========================================================================================================
4.01s call     tests/unit_tests/llms/test_openai.py::test_openai_async_retries
4.01s call     tests/unit_tests/llms/test_openai.py::test_openai_retries
0.76s call     tests/unit_tests/memory/chat_message_histories/test_sql.py::test_multiple_sessions[SQLite]
0.67s call     tests/unit_tests/document_loaders/parsers/test_pdf_parsers.py::test_pdfminer_parser
0.65s call     tests/unit_tests/memory/chat_message_histories/test_sql.py::test_clear_messages[SQLite]
============================================================================================ 1022 passed, 83 skipped, 47 warnings in 21.99s =============================================================================================
```
<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: 
  - 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Issue: Supabase python client pydantic dependency mismatch
Labels: name: auto:bug

### Issue you'd like to raise.

When using supabase client I get dependency errors, which I believe originate from the pydantic library 

Supabase uses requires pydantic<3.0,>=2.1.0 
Langchain requires (I guess) 1.10.12 

With langchain compatible pydantic versions, supabase errors out. 

``` python
from supabase.client import Client, create_client
supabase_url = os.environ.get("SUPABASE_URL")
supabase_key = os.environ.get("SUPABASE_SERVICE_KEY")
supabase: Client = create_client(supabase_url, supabase_key)
```

    ImportError: cannot import name 'field_validator' from 'pydantic' 


But if I upgrade pydantic, langchain starts erroring out. 

``` python
from langchain.vectorstores.pgvector import PGVector
```

    PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.


Is there any quick fix for this?

Thanks
Issue: How can we combine ConversationalRetrievalChain with openai ChatCompletion
Labels: name: area: agent, name: auto:question, name: auto:improvement

### Issue you'd like to raise.

I'm trying to chat with a PDF using ConversationalRetrievalChain.

```
embeddings = OpenAIEmbeddings()
vectordb = Chroma(embedding_function=embeddings, persist_directory=directory)
qa_chain = ConversationalRetrievalChain.from_llm(ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0.3), vectordb.as_retriever(), memory=memory)
answer = (qa_chain({"question": query}))
```
    
    
    
 It works perfectly as it gives the answer from the documents. But it can't alter the tone or even convert the answer into another language when prompted. 
How can we change the tone like we do in openai ChatCompletion:

```
    response = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[
            {"role": "system", "content": "You are a helpful and friendly chatbot who converts text to a very friendly tone."},
            {"role": "user", "content": f"{final_answer}"}
        ]
    )

```

such that it answers from the doc but also converts it according to some given prompt. Right now I have to pass the received output from ConversationalRetrievalChain in above code in order to modify the tone. Is this kind of functionality missing in ConversationalRetrievalChain?

### Suggestion:

_No response_
Add flush=True to stream examples
Labels: name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
fix evaluation parse test
Labels: name: auto:bug

# What
- fix evaluation parse test

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Fix evaluation parse test
  - Issue: None
  - Dependencies: None
  - Tag maintainer: @baskaryan
  - Twitter handle: @MLOpsJ

Please make sure you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Bug with os.environ['FAISS_NO_AVX2'] = '1' 
Labels: name: area: embeddings, name: area: vector store, name: auto:bug

### System Info

I was trying to create FAISS embeddings that would work on different platforms so I tried to use:
`os.environ['FAISS_NO_AVX2'] = '1' `
as recommended in https://github.com/langchain-ai/langchain/blob/6cdd4b5edca511b0015f1b39102225fe638d8359/langchain/vectorstores/faiss.py

It works for windows, but I am getting `TypeError: IndexFlatCodes.add() missing 1 required positional argument: 'x'` when I try to create embeddings in Docker image



Full error:
```
TypeError: IndexFlatCodes.add() missing 1 required positional argument: 'x'
Traceback:
File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
File "/app/src/pages/1_💬__AI-Chat.py", line 127, in <module>
    chatbot = utils.setup_chatbot(
              ^^^^^^^^^^^^^^^^^^^^
File "/app/./src/modules/utils.py", line 121, in setup_chatbot
    vectors = embeds.getDocEmbeds(file, uploaded_file.name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/./src/modules/embedder.py", line 104, in getDocEmbeds
    self.storeDocEmbeds(file, original_filename)
File "/app/./src/modules/embedder.py", line 86, in storeDocEmbeds
    vectors = FAISS.from_documents(data, embeddings)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/base.py", line 336, in from_documents
    return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/faiss.py", line 550, in from_texts
    return cls.__from(
           ^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/faiss.py", line 505, in __from
    index.add(vector)
```

langchain==0.0.226

### Who can help?

@hwchase17

### 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

from langchain.document_loaders.csv_loader import CSVLoader
from langchain.vectorstores import FAISS
from langchain.embeddings.openai import OpenAIEmbeddings

 loader = CSVLoader(file_path=tmp_file_path, encoding="utf-8",csv_args={
                'delimiter': ',',})
            data = loader.load()
 embeddings = OpenAIEmbeddings(...)
 vectors = FAISS.from_documents(data, embeddings)

### Expected behavior

embeddings should generated
Fix/abstract add message
Labels: name: area: memory, name: auto:nit

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Fix/abstract add message
  - Issue: None
  - Dependencies: None
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - Twitter handle: @MLOpsJ

Please make sure you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Separate LLMs for Tool Selection and Chatting in Agent Initialization
Labels: name: area: agent, name: auto:enhancement

### Feature request

Currently when we initialize an agent we can only pass one llm which is responsible for both tool selection and chatting. There should be a feature that would allows us to define seperate llms for tool selection and chatting respectively. 

### Motivation

It has been observed that text llms are better at decision making which is helpful when we have multiple tools but their chat responses are not that impressive. On the other hand chat models are better at chatting and but not as good at decision making which causes problems when we have multiple tools. Therefore, I want to harness the good of both in single agent. 

### Your contribution

Yes I can submit a PR if certain guidance is provided.
Issue: Having trouble passing question with LangSmith
Labels: name: auto:question

### Issue you'd like to raise.

Hello! I am trying to use LangSmith to test my LLM. I've created a dataset, but I'm confused, as this dataset doesn't seem to work even though I am using `StuffDocumentsChain` in testing (I think) the same way I'm using it in production. Here's how I call it in production:

```
docs_chain = StuffDocumentsChain(
    llm_chain=LLMChain(
        llm=ChatOpenAI(
            temperature=0,
        ),
        prompt=prompt,
        verbose=True,
    ),
    document_variable_name="context",
    verbose=True,
    document_prompt=document_prompt,
)
...
answer = await docs_chain.arun(
    input_documents=llm_context["docs"], **llm_context["inputs"]
)
...
```
So, this accept 4 inputs (I believe coming from `input_documents` and `llm_context["inputs"]`: `'question', 'chat_history', 'input_documents', 'organization_uuid'`

However, when I want to test this with LangSmith I'm trying to do:
```
def create_chain():
    messages = [SystemMessagePromptTemplate.from_template(system_prompt)]

    messages.append(HumanMessagePromptTemplate.from_template('{question}'))

    retrieval_prompt = ChatPromptTemplate.from_messages(messages)

    combine_docs_chain = StuffDocumentsChain(
        llm_chain=LLMChain(
            llm=ChatOpenAI(
                temperature=0,
            ),
            prompt=retrieval_prompt,
            verbose=True,
        ),
        document_variable_name="context",
        verbose=True,
        document_prompt=document_prompt,
    )
    return combine_docs_chain

...

await arun_on_dataset(
        client=client,
        dataset_name=dataset_name,
        llm_or_chain_factory=create_chain,
        evaluation=eval_config,
        verbose=True,
    )
```

but I'm getting:
```
langchain.smith.evaluation.runner_utils.InputFormatError: Example inputs do not match chain input keys. Please provide an input_mapper to convert the example.inputs to a compatible format for the chain you wish to evaluate.Expected: ['input_documents']. Got: dict_keys(['question', 'chat_history', 'input_documents', 'organization_uuid'])
```

I don't understand this, as I'm calling this in the same way... shouldn't those input map in the same way?

As the error states, I can also pass an `input_mapper` to just convert my example inputs into the required format, but then I would be throwing away the `question`, etc., and I want that `question` to be part of the test.

I'm probably thinking about this wrong. Let me know what you would do here, thank you!

### Suggestion:

_No response_
Issue: AssertionError: Unknown arguments: ['fetch_k', 'maximal_marginal_relevance'] when specifyig search_kwargs ini from_llm() function call
Labels: name: area: vector store, name: auto:bug

### Issue you'd like to raise.

Hi there, I am recently using Langchain to build my toy chatbot. I used both **Qdrant** cloud storage and local storage for test. However, when I am using local storage for **vector_store** and **search_kwargs**, everything is good. But, when I switch to the Qdrant cloud storage, the retriever of vectorDB is reporting no machtching **search_kwargs**. My partial codes shown below.
<img width="947" alt="image" src="https://github.com/langchain-ai/langchain/assets/59675745/50d0e930-38a8-4d69-b294-656435a5fdc3">

 The error:
<img width="1012" alt="image" src="https://github.com/langchain-ai/langchain/assets/59675745/f800c82c-ac75-4158-8dc2-ae32a271b7c0">


### Suggestion:

_No response_
Visualize the Networkx Entity Graph created via the GraphIndexCreator class using pyvis/matplotlib
Labels: name: auto:question, name: auto:enhancement

### Feature request

```
from langchain.indexes import GraphIndexCreator
from langchain.graphs.networkx_graph import KnowledgeTriple
index_creator = GraphIndexCreator(llm=llm)
graph = index_creator.from_text('text to RDF')

graph.add_triple(KnowledgeTriple('aaa', '10', 'bbb'))
graph.add_triple(KnowledgeTriple('ccc', '30', 'ddd'))
graph.add_triple(KnowledgeTriple('eee', '10', 'aaa'))
graph.add_triple(KnowledgeTriple('ffff', '5', 'ddd'))
```
Using above code I have created a sample Networkx graph. Now I want to visualize this graph using  pyvis/matplotlib. How can I?

### Motivation

Graph visualization support

### Your contribution

Graph visualization support
Issue: Support for Custom VertexAI models
Labels: name: auto:question, name: auto:enhancement

### Issue you'd like to raise.

This is more like a question than feature request.

Google Vertex AI has support for some task specific models which are specially trained for certain action. 
I know Langchain has support for LLM based models in general but do you ever plan to integrate these task specific models in your library? This (by Google's definition) is a Language Service Model but might not be powered by Gen AI technology

<img width="932" alt="image" src="https://github.com/langchain-ai/langchain/assets/97156231/867a3101-e429-4716-a3ae-62c3c4c90813">


### Suggestion:

_No response_
Add BGE embeddings support
Labels: name: lgtm, name: area: embeddings, name: auto:enhancement

- Description:  [BGE-large](https://huggingface.co/BAAI/bge-large-en) embeddings from BAAI are at the top of [MTEB leaderboard](https://huggingface.co/spaces/mteb/leaderboard). Hence adding support for it.
- Tag maintainer: @baskaryan
- Twitter handle: @ManabChetia3
Issue: ChromaDB document and token openAI limitations
Labels: name: area: embeddings, name: area: vector store, name: auto:question

### Issue you'd like to raise.

currently, 
im using openAI GPT3.5 for models and chroma DB to save vector.
i have some pdf documents which is have 2000 total pages. the pages will increase about 100 pages every day. 
and at the end, the total target page that must be inputed is around 20.000 pages.

i have 2 question: 
1. i worry about token limitations from GPT3.5 . any idea / suggestion to improve token limitations for many source documents?
2. for chromaDB, are chromaDB has limitations for saving vector?

i already using text splitter

`textSplitter = RecursiveCharacterTextSplitter(chunk_size=1536, chunk_overlap=200,separators=["#####","\n\n","\n","====="])`


i accept all idea and suggestion for this, thanks for advice
please take a note: i cant make summary from every documents.


i accept all idea and suggestion for this, thanks for advice
please take a note: i cant make summary from every documents.

### Suggestion:

_No response_
eugene/automaton variant 1
Labels: name: auto:enhancement

- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x

<!-- Thank you for contributing to LangChain!

Replace this 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
added filter kwarg to VectorStoreIndexWrapper query and query_with_so…
Labels: name: lgtm, name: area: vector store, name: auto:improvement

- Description: added filter to query methods in VectorStoreIndexWrapper for filtering by metadata (i.e. search_kwargs)
- Tag maintainer: @rlancemartin, @eyurtsev

Updated the doc snippet on this topic as well.  It took me a long while to figure out how to filter the vectorstore by filename, so this might help someone else out.
TypeError Due to Duplicate 'auth' Argument in aiohttp Request when provide header  to APIChain
Labels: name: area: agent, name: auto:bug

### System Info

Langchain version: 0.0.253
Python:3.11

### Who can help?

@agola11 @hwchase17 @eyurtsev

### 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
- [X] Chains
- [ ] Callbacks/Tracing
- [X] Async

### Reproduction

1. Environment Setup:

Ensure you're using Python 3.11.
Install the necessary libraries and dependencies:

```bash
pip install fastapi uvicorn aiohttp langchai
```

2. APIChain Initialization:

Set up the APIChain utility using the provided API documentation and the chosen language model:

```python
from langchain import APIChain

chain = APIChain.from_llm_and_api_docs(api_docs=openapi.MY_API_DOCS, llm=choosen_llm, verbose=True, headers=headers)
```
3. Run the FastAPI application:

Use a tool like Uvicorn to start your FastAPI app:
```lua
uvicorn your_app_name:app --reload
```
4. Trigger the API Endpoint:

Make a request to the FastAPI endpoint that uses the APIChain utility. This could be through tools like curl, Postman, or directly from a browser, depending on how your API is set up.
Execute the Callback:

Inside the relevant endpoint, ensure you have the following snippet:
```python

with get_openai_callback() as cb:
    response = await chain.arun(user_query)
```
5. Observe the Error:

You should encounter a TypeError indicating a conflict with the auth argument in the aiohttp.client.ClientSession.request() method. Because of providing header to APIChain and running it with ```arun``` method.


### Expected behavior

Request Execution:

The chain.arun(user_query) method should interact with the intended external service or API without any issues.
The auth parameter, when used in the underlying request to the external service (in aiohttp), should be correctly applied without conflicts or multiple definitions.