delayedkarma/langchain-issues huggingface dataset:
Question!! Multiple agent use? agent within agent? 
Labels: name: auto:question, name: auto:improvement

### Feature request

Hello Langchain community! 

I'm currently in the process of developing a company's chatbot, and I've chosen to use both a CSV file and Pinecone DB for the project.

Here's a basic outline of the structure I've adopted so far:
![캡처](https://github.com/hwchase17/langchain/assets/81153340/de1d5abf-d6d4-4f30-aad8-f1711fcf8716)

I've managed to set the two tools, and its example usage has been providing accurate answers
![캡처1](https://github.com/hwchase17/langchain/assets/81153340/75b8ee0d-01cd-4276-b926-5f288ad50053)
the first tool gets me the answers based on pandas’s result from the example usage, the answers are based on csv and it’s correct in all cases 
![캡처2](https://github.com/hwchase17/langchain/assets/81153340/0b55e176-8eb4-4db7-be81-227dabcf90eb)

Also set the second tool and its example usage is answered correctly. 
![캡처3](https://github.com/hwchase17/langchain/assets/81153340/d816eb6a-926c-4e45-b033-18f3680fccd4)

until here things are very promising and i expected everything to work as it is. 
so i have set the LLM and combined the two tools and used agent
![캡처4](https://github.com/hwchase17/langchain/assets/81153340/64d11ca9-f7a4-4839-ab94-95a5f1970f42)

However, when I combined both tools using an agent, the answers started to deviate from the expected output. I'm not entirely sure whether the method I'm using to utilize the agent is optimal.
![캡처5](https://github.com/hwchase17/langchain/assets/81153340/3dc8b7ef-990a-446b-8838-021b1037a501)

To address this issue, I've experimented with the MultiretrievalQA chain using vector embedding. But the results are not consistently reliable, and moreover, I'd rather not generate new embeddings every time I modify the CSV.

Is there anyone in the community who can shed light on these issues I'm encountering? Any feedback on my current approach, suggestions on how to optimize it, or alternative strategies would be greatly appreciated!

Thank you.





### Motivation

I'm making a company's gpt and i hope to link my csv with the chatbot so that whenever i change the csv the chatbot is automatically linked with it 

### Your contribution

um solving the problem would help others?
Removed kwargs from add_texts
Labels: name: auto:nit

Removing **kwargs argument from add_texts method in DeepLake vectorstore as it confuses users and doesn't fail when user is typing incorrect parameters.

Also added small test to ensure the change is applies correctly.

Guys could pls take a look: @rlancemartin, @eyurtsev, this is a small PR. 

Thx so much!

<!-- 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!

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
 -->
Error while trying to run SQL Database Agent example
Labels: name: auto:bug

### System Info

Langchain version: 0.0.230
python version: Python 3.9.12

### Who can help?

@hwchase17
@agola11


### Information

- [X] 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
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Im trying run the to code mentioned at: https://python.langchain.com/docs/modules/agents/toolkits/sql_database

But I'm getting the error as: 
ModuleNotFoundError: No module named 'MySQLdb'

Then trying 'pip install MySQL-python' gives the following error:
ModuleNotFoundError: No module named 'ConfigParser'

Then trying 'pip install configparser' even doesn't solve the issue.

Please help me figure out this issue. Thanks!

### Expected behavior

The code should have just executed the prompt, And installation of the required libraries should be easier.
fix(typo): Clarify the point of `llm_chain`
Labels: name: lgtm, name: auto:documentation

Fixes a typo introduced in https://github.com/hwchase17/langchain/pull/7080 by @hwchase17.

In the example (visible on [the online documentation](https://api.python.langchain.com/en/latest/chains/langchain.chains.conversational_retrieval.base.ConversationalRetrievalChain.html#langchain-chains-conversational-retrieval-base-conversationalretrievalchain)), the `llm_chain` variable is unused as opposed to being used for the question generator. This change makes it clearer.
Update bedrock.py - support of other endpoint url (esp. for users of …
Labels: name: lgtm, name: auto:improvement

Added an _endpoint_url_ attribute to Bedrock(LLM) class - I have access to Bedrock only via us-west-2 endpoint and needed to change the endpoint url, this could be useful to other users 

<!-- 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!

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
 -->
Improve the usage of relevance score threshold and allow the return of the scores
Labels: name: auto:improvement

### Feature request

In `VectorStore`/`VectorStoreRetriever` class, `_similarity_search_with_relevance_scores`function,
1) Allow different choices of threshold kind: allow users to choose whether >= threshold or <= threshold
2) Allow users to choose to return the relevance score along with the docs

### Motivation

I am working with returning relevant docs that satisfy a certain threshold, and I encountered some problems. 
One problem is that for different embedding algorithms and similarity calculations, it is not always the case that higher relevance scores are better. Actually, when I use `HuggingFaceEmbedding` with `Chroma` database, the smaller the relevance score, the better. So I believe it would be necessary to allow users choose between different options here.
The second problem is that I want to see the relevance score, however, in https://github.com/hwchase17/langchain/blob/master/langchain/vectorstores/base.py, line 474 to 492, it is fixed that only the docs are finally returned. 
```
def _get_relevant_documents(
        self, query: str, *, run_manager: CallbackManagerForRetrieverRun
    ) -> List[Document]:
        if self.search_type == "similarity":
            docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
        elif self.search_type == "similarity_score_threshold":
            docs_and_similarities = (
                self.vectorstore.similarity_search_with_relevance_scores(
                    query, **self.search_kwargs
                )
            )
            docs = [doc for doc, _ in docs_and_similarities]
        elif self.search_type == "mmr":
            docs = self.vectorstore.max_marginal_relevance_search(
                query, **self.search_kwargs
            )
        else:
            raise ValueError(f"search_type of {self.search_type} not allowed.")
        return docs
```
I wish there is an option that the relevance scores could also be returned.

### Your contribution

I would love to open a PR if applicable ;) @hwchase17
namespace parameter is gone in pinecone from_existing_index method
Labels: name: auto:bug, name: auto:question

### System Info

I am using langchain v0.0.228. But namespace parameter is gone in existing_index() of v0.0.230.
Why the namespace is gone?

@hwchase17 @eyurtsev @agola11 

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

No need.

### Expected behavior

should be used from_existing_index method with namespace parameter
Question：ConversationalRetrievalChain with retriever
Labels: name: auto:bug, name: auto:improvement

### Issue you'd like to raise.

if use ElasticVectorSearch as as_retriever and set the params:
```python
elastic_vector_search.as_retriever(search_type="similarity_score_threshold",
                                                                                                      search_kwargs={"score_threshold": 1.8})
```
If no relevant docs were retrieved using the relevance score threshold 1.8.
then return an error!
![image](https://github.com/hwchase17/langchain/assets/5388898/70bd9610-0f9f-4da4-8da4-2428d807a130)


### Suggestion:

it should not throw err, when there is no relevant docs.
it should response like "i don't know " or an openai default response.
Error when creating a custom ConversationalChatAgent
Labels: name: auto:bug

### System Info

MacOS
Python 3.10.6
langchain 0.0.230
langchainplus-sdk 0.0.20

### Who can help?

@hwchase17  @agola11 

### Information

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

### Related Components

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

### Reproduction

For now, there are only the default `ConversationalChatAgent` and `ConversationalAgent`, and we cannot create custom prompt templates in them. At least, I don't see how to do that in both the docs and source code.

I think there should be a straight-forward way to do so, just like how you can have a [custom LLM agent](https://python.langchain.com/docs/modules/agents/how_to/custom_llm_chat_agent):
```py
agent = LLMSingleActionAgent(
    llm_chain=llm_chain, 
    output_parser=output_parser,
    stop=["\nObservation:"], 
    allowed_tools=tool_names
)
```
However, when the same code is applied to `ConversationalChatAgent`, that is:
```py
agent = LLMSingleActionAgent(
    llm_chain=llm_chain, 
    output_parser=output_parser,
    stop=["\nObservation:"], 
    allowed_tools=tool_names
)
```
I get the following error:
```shell
pydantic.error_wrappers.ValidationError: 1 validation error for ConversationalChatAgent
__root__
  Got unexpected prompt type <class '__main__.CustomPromptTemplate'> (type=value_error)
```

I'm not sure if this belongs to **Bug Report** so if I'm doing anything wrong, please tell me about it. Thanks!

### Expected behavior

The agent should be created without errors.
DOC: Langchain works well with single database, but in a session if I have to work with multiple database, it does not seem working
Labels: name: auto:bug, name: auto:documentation

### Issue with current documentation:

Below code does not seem to work, 

```
    db = SQLDatabase.from_uri("mssql+pymssql://<some server>/<some db>",
                          include_tables=['Some table'], view_support=True)
                          
    db1 = SQLDatabase.from_uri("mssql+pymssql://<some other server>/<some other db>",
                          include_tables=['Some other table'], view_support=True)

    toolkit = SQLDatabaseToolkit(db=db, llm=llm, reduce_k_below_max_tokens=True)

    sql_agent_executor = create_sql_agent(
        llm=llm,
        toolkit=toolkit,
        verbose=True
    )
    
    toolkit1 = SQLDatabaseToolkit(db=db1, llm=llm, reduce_k_below_max_tokens=True)

    sql_agent_executor1 = create_sql_agent(
        llm=llm,
        toolkit=toolkit,
        verbose=True
    )

    tools = [
        Tool(
            name = "Object or Product to Classification Association",
            func=sql_agent_executor.run,
            description="""
            Useful for when you need to Query on database to find the object or product to classification association.
            
            <user>: Get me top 3 records with Object number and description for approved classification KKK
            <assistant>: I need to check Object or Product to Classification Association details.
            <assistant>: Action: SQL Object or Product to Classification Association
            <assistant>: Action Input: Check The Object or Product to Classification Association Table

            """
        ),
        Tool(
            name = "Authorization or Authority or License Database",
            func=sql_agent_executor1.run,
            description="""
            Useful for when you need to Query on some thing else .
            
            <user>: Get me top 2 Authority Records with LicenseNumber
            <assistant>: I need to check Authorization or Authority or License Database details.
            <assistant>: Action: SQL Authorization or Authority or License Database
            <assistant>: Action Input: Check The Authorization or Authority or License Database Table

            """
        )
    ]

```

Is there an example where we can configure multiple databases as different tools and query them. It seems possible, but in my case, what ever question I ask, it always goes to the first Tool. Not sure what is the problem.

### Idea or request for content:

_No response_
chain.run doesn't necessarily return a `str`
Labels: name: auto:bug, name: auto:documentation

https://github.com/hwchase17/langchain/blob/2667ddc6867421842fe027f1946644f452de8eb3/langchain/chains/base.py#L386-L393

when I have this:
```
chain = create_structured_output_chain(Categorization, llm, prompt, verbose=True)
response = chain.run(trx_description)
```
my `response` object is a dict not a str, but I got misled by the type assistance making me think it was a str.
PGVector.from_documents breaking from 0.0.229 to 0.0.230
Labels: name: auto:bug

### System Info

langchain==0.0.230

### Who can help?

@raymond-yuan 


### 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

Fill in appropriate values for parameters
```
db = PGVector.from_documents(
    embedding=embeddings,
    documents=docs,
    collection_name=COLLECTION_NAME,
    connection_string=CONNECTION_STRING,
    pre_delete_collection=True,
)
```

Produces:
```
Traceback (most recent call last):
  File "create_pgvector_index_hr.py", line 70, in <module>
    db = PGVector.from_documents(
  File "/home/coder/venv-openai-slackbot/lib/python3.8/site-packages/langchain/vectorstores/pgvector.py", line 578, in from_documents
    return cls.from_texts(
  File "/home/coder/venv-openai-slackbot/lib/python3.8/site-packages/langchain/vectorstores/pgvector.py", line 453, in from_texts
    return cls.__from(
  File "/home/coder/venv-openai-slackbot/lib/python3.8/site-packages/langchain/vectorstores/pgvector.py", line 213, in __from
    store = cls(
TypeError: ABCMeta object got multiple values for keyword argument 'connection_string'
```

and appears related to this change: https://github.com/hwchase17/langchain/blame/master/langchain/vectorstores/pgvector.py#L213-L220

### Expected behavior

Above code works with langchain==0.0.229

Code should not throw an exception as it did prior to 0.0.230
Reduce the number of LLM parsing error with conversational chats
Labels: name: auto:bug

A lot of times, when the LLM responses a Final Answer with markdown in the answer text (e.g. asking the LLM to write some code), the parser raises an OutputParserException("Could not parse LLM output: ..."), when the answer from the LLM is totally acceptable.

This change should reduce the number of such occurances.


  - Description: Reduce the number of LLM parsing error with conversational chats, 
  - Issue: the issue #1358 ,
  - Dependencies: None,
  - Tag maintainer: @hinthornw @baskaryan,
 
For example, this response from gpt-turbo-3.5 for "How to convert a list of dict to a JSON in Python" seems totally acceptable as the final answer, but will raise the OutputParserException, even with `handle_parsing_errors=True`. This PR fixes it.
![Screenshot 2023-07-12 101547](https://github.com/hwchase17/langchain/assets/40119257/f87555b2-7782-4274-a714-72c11082df98)
Fixed bug7445  where a duplicate restuld_id is added to the vectorstore.
Labels: name: auto:bug, name: auto:documentation


  - Description: updated BabyAGI examples to append the iteration to the result id to fix error storing data to vectorstore. 
  - Issue: 7445
  - Dependencies: no
  - Tag maintainer: @eyurtsev
  - 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!

This fix worked for me locally. Happy to take some feedback and iterate on a better solution. I was considering appending a uuid instead but didnt want to over complicate the example.
AmazonKendraRetriever "Could not load credentials" error in latest release
Labels: name: auto:bug

### System Info

LangChain version: 0.0.229
Platform: AWS Lambda execution
Python version: 3.9

I get the following error when creating the AmazonKendraRetriever using LangChain version 0.0.229. 
Code to create retriever:
    `retriever = AmazonKendraRetriever(index_id=kendra_index)`

Error:
```[ERROR] ValidationError: 1 validation error for AmazonKendraRetriever
__root__
  Could not load credentials to authenticate with AWS client. Please check that credentials in the specified profile name are valid. (type=value_error)
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 171, in lambda_handler
    retriever = AmazonKendraRetriever(index_id=kendra_index)
  File "/opt/python/langchain/load/serializable.py", line 74, in __init__
    super().__init__(**kwargs)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__```


When using LangChain version 0.0.219 this error does not occur.

Issue also raised on aws-samples git repo with potential solution: https://github.com/aws-samples/amazon-kendra-langchain-extensions/issues/24 

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

### Reproduction

1. Install latest version of Langchain
2. Follow instructions here: https://python.langchain.com/docs/modules/data_connection/retrievers/integrations/amazon_kendra_retriever

### Expected behavior

Error not thrown when creating AmazonKendraRetriever
Issue: Document loader for Notion DB doesn't supports some properties
Labels: name: auto:improvement

### Issue you'd like to raise.

Current version of document loader for Notion DB doesn't supports following properties for metadata

- `unique_id`
  - https://www.notion.so/help/unique-id
- `status`
  - https://www.notion.so/help/guides/status-property-gives-clarity-on-tasks
- `people`
  - useful property when you assign some task to assignees

### Suggestion:

I would like to make a PR to fix this issue if it's okay.
Accept Chain
Labels: name: auto:improvement

By default, the run_on_evaluate method requires chains to be passed in via a constructor. If you're not looking at function types, it's common to try to pass your chain in directly. This PR proposes to
- Accept a raw chain if it lacks memory. It may still be leaky if a child chain has memory (or for other sources of randomness), but that could also be the case if the constructor were incorrectly set up
- Throw a helpful error if not, explaining how to fix and why this is a requirement.

I don't update the public API types since we still want people to be in the habit of passing in the constructor, but this feels like a kinder UX

Delta from the general eval config refactor but not directly related
propagate callbacks through load_summarize_chain
Labels: name: auto:improvement

This lets you pass callbacks when you create the summarize chain:

```
summarize = load_summarize_chain(llm, chain_type="map_reduce", callbacks=[my_callbacks])
summary = summarize(documents)
```
See #5572 for a similar surgical fix.

tagging @hwchase17 for callbacks work

<!-- 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!

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
 -->