delayedkarma/langchain-issues huggingface dataset:
Errors about ErnieBotChat
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

my test code
```
import unittest
from langchain.chat_models import ErnieBotChat
from langchain.schema import (
    HumanMessage
)


class TestErnieBotCase(unittest.TestCase):
    def test_ernie_bot(self):
        chat_llm = ErnieBotChat(
            ernie_client_id="xxx",
            ernie_client_secret="xxx"
        )
        result = chat_llm.generate(messages=[HumanMessage(content="请列出清朝的所有皇帝的姓名和年号")])
        print(result)


if __name__ == '__main__':
    unittest.main()
```
it's return error：
```
Error
Traceback (most recent call last):
  File "/Users/keigo/Workspace/study/langchain/tests/test_erniebot.py", line 14, in test_ernie_bot
    result = chat_llm.generate(messages=[HumanMessage(content="请列出清朝的所有皇帝的姓名和年号")])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/base.py", line 309, in generate
    raise e
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/base.py", line 299, in generate
    self._generate_with_cache(
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/base.py", line 446, in _generate_with_cache
    return self._generate(
           ^^^^^^^^^^^^^^^
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/ernie.py", line 157, in _generate
    "messages": [_convert_message_to_dict(m) for m in messages],
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/ernie.py", line 157, in <listcomp>
    "messages": [_convert_message_to_dict(m) for m in messages],
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/keigo/Workspace/study/langchain/venv/lib/python3.11/site-packages/langchain/chat_models/ernie.py", line 31, in _convert_message_to_dict
    raise ValueError(f"Got unknown type {message}")
ValueError: Got unknown type ('content', '请列出清朝的所有皇帝的姓名和年号')
```

in ernie.py file function _convert_message_to_dict,the variable message is of type tuple。

### Suggestion:

_No response_
Issue: create_pandas_dataframe_agent is hard to work with llama models 
Labels: name: area: agent, name: auto:bug, name: auto:question, name: area: models

### Issue you'd like to raise.

Langchain pandas agents (create_pandas_dataframe_agent ) is hard to work with llama models. (the same scripts work well with gpt3.5.)
I am trying to use local model Vicuna 13b v1.5 (LLaMa2 based) to create a local Question&Answer system. 
it works well dealing with doc QAs. 
but it doesn't work well dealing with pandas data (by calling create_pandas_dataframe_agent ). Any suggestions for me ?



my calling code:
```
df=pd.read_excel(CSV_NAME)
pd_agent = create_pandas_dataframe_agent(
    ChatOpenAI(temperature=0,model_name=set_model),
    df,
    verbose=True, 
    agent_type=AgentType.OPENAI_FUNCTIONS,
    agent_executor_kwargs={"handle_parsing_errors":True}
)
pd_agent.run(query)


```
example: when I asking   How many events occurred after May 20, 2023?
the final answer would be :

````From the data provided, we can find the GUID of the event, and then filter out the data after May 20, 2023 based on the date. The following is the Python code implementation:
```python
import pandas as pd

#Read data
data = pd.read_csv('your_data_file.csv')

# Filter the data in the date range
filtered_data = data[data['date'] >= '2023-05-20']

# Extract the GUID of the event
guids = filtered_data[filtered_data['element'] == 'events']['id'].unique()

# Output the GUID of the event
print(guids)
```
Please replace `your_data_file.csv` with your data file name. This code will output the GUID of the event after May 20, 2023.
````

it seems the chain did not proceed to the last step. any suggestions for me ? 
1. other than create_pandas_dataframe_agent , is there other chain or agent can I try?
2. if i need to overwrite some methods, which method should I edit? 
the only similar example I found is written by kvnsng https://github.com/langchain-ai/langchain/issues/7709#issuecomment-1653833036

### Suggestion:

_No response_
Supabase vector self querying retriever
Labels: name: area: vector store, name: auto:enhancement, name: integration: supabase

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
## Description
Adds Supabase Vector as a self-querying retriever.

- Designed to be backwards compatible with existing `filter` logic on `SupabaseVectorStore`.
- Adds new filter `postgrest_filter` to `SupabaseVectorStore` `similarity_search()` methods
- Supports entire PostgREST [filter query language](https://postgrest.org/en/stable/references/api/tables_views.html#read) (used by self-querying retriever, but also works as an escape hatch for more query control)
- `SupabaseVectorTranslator` converts Langchain filter into the above PostgREST query
- Adds Jupyter Notebook for the self-querying retriever
- Adds tests

## Tag maintainer
@hwchase17

## Twitter handle
[@ggrdson](https://twitter.com/ggrdson)
Change StructuredTool's ainvoke to await
Labels: name: auto:nit

Fixes #10080. StructuredTool's `ainvoke` doesn't `await`.

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
add use case nb position
Labels: name: auto:documentation

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Strip text splits
Labels: name: lgtm, name: auto:improvement

#10085

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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
`langchain/document_loaders/s3_directory.py` S3DirectoryLoader has 3 bugs
Labels: name: area: doc loader, name: auto:bug

### System Info

langchain==0.0.281
boto3==1.28.41

```python
        s3 = boto3.resource(
            "s3",
            region_name=self.region_name,
            api_version=self.api_version,
            use_ssl=self.use_ssl,
            verify=self.verify,
            endpoint_url=self.endpoint_url,
            aws_access_key_id=self.aws_access_key_id,
            aws_secret_access_key=self.aws_secret_access_key,
            aws_session_token=self.aws_session_token,
            config=self.boto_config,
        )
```

line 117 should be `config=self.boto_config` not `boto_config=self.boto_config`.

```python
for obj in bucket.objects.filter(Prefix=self.prefix):
            if obj.get()["ContentLength"] == 0:
                continue
            loader = S3FileLoader(
                self.bucket,
                obj.key,
                region_name=self.region_name,
                api_version=self.api_version,
                use_ssl=self.use_ssl,
                verify=self.verify,
                endpoint_url=self.endpoint_url,
                aws_access_key_id=self.aws_access_key_id,
                aws_secret_access_key=self.aws_secret_access_key,
                aws_session_token=self.aws_session_token,
                config=self.boto_config,
            )
            docs.extend(loader.load())
```

before line 122 should add the condition if object is a directory, and line 135 `boto_config` again.

### 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
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

unnecessary

### Expected behavior

unnecessary
Added the Polars dataframe agent
Labels: name: area: agent, name: auto:enhancement

## Description
Added the Polars dataframe agent.
This is a dataframe agent and can be used in the same way as the Pandas dataframe agent.
(Polars is a DataFrame interface on top of an OLAP Query Engine implemented in Rust.)

## Issue
https://github.com/langchain-ai/langchain/issues/4620

## Dependencies
polars (https://pola-rs.github.io/polars-book/user-guide/)

## Tag maintainer
N/A

## Twitter handle
N/A
Update base.py
Labels: name: auto:improvement

Return both SQL Query and final answer

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Vaidehi2027 patch 1
Labels: name: auto:documentation

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
[create_csv_agent] Change dataframe as according to the prompt, and also save when required
Labels: name: area: agent, name: auto:enhancement

### Feature request

Currently there isn't any feature which we can use to actually manipulate/change and save the data frame.

**Examples:**
If I say rename columns to Column1, Column2, Column3. 
Make new column named as [Column4] having data concatenated from Column1 and Column2

It should actually perform the functionalities and make changes in dataframe. And once user is done with its prompt there should be a function or a specific prompt which user can use to actually save manipulated dataframe as CSV.

``` 
agent = create_pandas_dataframe_agent(
    ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
    df,
    return_intermediate_steps=True,
    verbose=True,
)
```
Using above code it returns good analytics and actual code which can be used to perform functionalities but can't actually manipulate exactly what is said to it. PLUS we cant save dataframe.

### Motivation

One can use this feature to actually manipulate data based on prompts, which can aid in Data Science industry.

### Your contribution

I looked into the source code but couldn't manage to locate the implementation of agent itself.
Added Hugging face inference api to embed documents without locally d…
Labels: name: lgtm, name: area: embeddings, name: auto:enhancement

…ownloading the model

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: Added Hugging Face Inference API support for embedding small documents without downloading the model locally , 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: There are no external dependencies as it depends on embedding model of langchain as requested by @hwchase17 ,
  

>
fix llm_inputs duplication problem in intermediate_steps in SQLDatabaseChain
Labels: name: auto:bug, name: area: models

Use `.copy()` to fix the bug that the first `llm_inputs` element is overwritten by the second `llm_inputs` element in  `intermediate_steps`.

***Problem description:***
In [line 127](
https://github.com/langchain-ai/langchain/blob/c732d8fffd39d2b02bdc393c37d2ccdd48f7626d/libs/experimental/langchain_experimental/sql/base.py#L127C17-L127C17), the `llm_inputs` of the sql generation step is appended as the first element of `intermediate_steps`:
```
            intermediate_steps.append(llm_inputs)  # input: sql generation
```

However, `llm_inputs` is a mutable dict, it is updated in [line 179](https://github.com/langchain-ai/langchain/blob/master/libs/experimental/langchain_experimental/sql/base.py#L179) for the final answer step: 
```
                llm_inputs["input"] = input_text
```
Then, the updated `llm_inputs` is appended as another element of  `intermediate_steps` in [line 180](https://github.com/langchain-ai/langchain/blob/c732d8fffd39d2b02bdc393c37d2ccdd48f7626d/libs/experimental/langchain_experimental/sql/base.py#L180):
```
                intermediate_steps.append(llm_inputs)  # input: final answer
```

As a result, the final `intermediate_steps` returned in [line 189](https://github.com/langchain-ai/langchain/blob/c732d8fffd39d2b02bdc393c37d2ccdd48f7626d/libs/experimental/langchain_experimental/sql/base.py#L189C43-L189C43) actually contains two same `llm_inputs` elements, i.e.,  the `llm_inputs` for the sql generation step overwritten by the one for final answer step by mistake. Users are not able to get the actual  `llm_inputs` for the sql generation step from `intermediate_steps`

Simply calling `.copy()` when appending `llm_inputs` to `intermediate_steps` can solve this problem.
query database using natural language
Labels: name: auto:question, name: auto:documentation, name: area: models

### Issue you'd like to raise.

Where given a question in a natural language it has to convert to sql query and then operate on the sql data base then has to return the answer.
Here I want to catch sql query generated and also the reponse to the question
Earlier I did by using SQLDatabaseChain
But now I couldn't find this in your document.
So what are all supported here for my use case?

### Suggestion:

_No response_
GPU usage 0 even with n_gpu_layers.
Labels: name: auto:bug, name: auto:question, name: area: models

GPU usage doesn't change and my Local Llama model only runs under CPU

``I'm running a local llama 2 7b model(hugging face bloke model), on my local machine, everything works fine, except that only cpu works and GPU usage remains 0 throughout. I've included n_gpu_layers and other such options, but gpu just doesn't work for some reason. 

device ram= 16gb
 Vram = 6gb. 

I can see 100% usage of my CPU, but nothing changes with respect to GPU usage. 

This is my code in python. 
`
from langchain.llms import LlamaCpp
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from transformers import AutoModelForCausalLM, AutoTokenizer


# MODEL_PATH = "D:\yarn-llama-2-7b-128k.Q2_K.gguf"
MODEL_PATH = "D:\llama-2-7b-chat.Q3_K_M.gguf"


def load_model():
    """Loads Llama model"""
    callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
    Llama_model = LlamaCpp(
        model_path=MODEL_PATH,
        temperature=0.5,
        max_tokens=2000,
        top_p=1,
        callback_manager=callback_manager,
        verbose=True,
        n_gpu_layers=100,
        n_batch=512

    )
    return Llama_model


llm = load_model()

model_prompt = """
a discussion between hitler and buddha
"""

response = llm(model_prompt)

print(response)


`

Does anybody have any idea how to include gpu ?

### Suggestion:

_No response_
Javelin
Labels: name: auto:enhancement, name: area: models

<!-- Thank you for contributing to LangChain!

We are introducing the py integration to Javelin AI Gateway www.getjavelin.io. Javelin is an enterprise-scale fast llm router & gateway. Could you please review and let us know if there is anything missing. 

Javelin AI Gateway wraps Embedding, Chat and Completion LLMs. Uses javelin_sdk under the covers (pip install javelin_sdk). 

Author: Sharath Rajasekar, Twitter: @sharathr, @javelinai

Thanks!!
 -->
langchain cannot be installed in a new project
Labels: name: auto:bug, name: integration: chroma

### System Info

npm --version
8.19.4

The langchain it's trying to install is 0.0.144

I think it's because chromadb recently released 1.5.7 and 1.5.8 which added a (conflicting) dep on cohere-ai. Pinning chromadb 1.5.6 works, but that's hardly satisfying.

### 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

mkdir testproject && cd testproject && npm init -y && npm add langchain

### Expected behavior

Expected to install properly. Instead get
```
npm add langchain
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: testproject@1.0.0
npm ERR! Found: cohere-ai@6.2.2
npm ERR! node_modules/cohere-ai
npm ERR!   peerOptional cohere-ai@"^6.0.0" from chromadb@1.5.8
npm ERR!   node_modules/chromadb
npm ERR!     chromadb@"^1.5.6" from the root project
npm ERR!     peerOptional chromadb@"^1.5.3" from langchain@0.0.144
npm ERR!     node_modules/langchain
npm ERR!       langchain@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional cohere-ai@"^5.0.2" from langchain@0.0.144
npm ERR! node_modules/langchain
npm ERR!   langchain@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
```