delayedkarma/langchain-issues huggingface dataset:
Fix invalid escape sequence warnings
Labels: name: lgtm, name: auto:bug

<!-- 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
 -->

Description: The lines I have changed looks like incorrectly escaped for regex. In python 3.11, I receive DeprecationWarning for these lines. 
You don't see any warnings unless you explicitly run python with `-W always::DeprecationWarning` flag. So, this is my attempt to fix it. 

Here are the warnings from log files:

```
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:919: DeprecationWarning: invalid escape sequence '\s'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:918: DeprecationWarning: invalid escape sequence '\s'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:917: DeprecationWarning: invalid escape sequence '\s'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:916: DeprecationWarning: invalid escape sequence '\c'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:903: DeprecationWarning: invalid escape sequence '\*'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:804: DeprecationWarning: invalid escape sequence '\*'
/usr/local/lib/python3.11/site-packages/langchain/text_splitter.py:804: DeprecationWarning: invalid escape sequence '\*'
```

cc @baskaryan
Create ChatAnyscale
Labels: name: auto:enhancement

- Description: Adds the ChatAnyscale class with llama-2 7b, llama-2 13b, and llama-2 70b on [Anyscale Endpoints](https://app.endpoints.anyscale.com/)
- It inherits from ChatOpenAI and requires openai (probably unnecessary but it made for a quick and easy implementation)
- Inspired by https://github.com/langchain-ai/langchain/pull/8434 (@kylehh and @baskaryan )
Improving the text of the invalid tool to list the available tools.
Labels: name: area: agent, name: auto:improvement

Description: When using a ReAct Agent with tools and no tool is found, the InvalidTool gets called. Previously it just asked for a different action, but I've found that if you list the available actions it improves the chances of getting a valid action in the next round. I've added a UnitTest for it also.

@hinthornw
PlanAndExecute Agent Error: langchain.tools.base.ToolException: Too many arguments to single-input
Labels: name: area: agent, name: auto:bug

### System Info

Hello,
I am trying to use PlanAndExecute Agent...  and getting error  langchain.tools.base.ToolException: Too many arguments to single-input.
I am using  SQLDatabaseToolkit & a custom tool . 


Let me know if i need to modify in the below code... 



```

toolkit = SQLDatabaseToolkit(db=db, llm=llm)
        tools = [
        *toolkit.get_tools(),
         send_email_tool
        ]
  
        planner = load_chat_planner(llm)
        executor = load_agent_executor(llm, tools, verbose=True)
        agent = PlanAndExecute(planner=planner, executor=executor, verbose=True)

        agent.run(
          "Find total number of orders & total number of customers and send an email"
        )
```



Custom tool..

```
def send_email(inputs: str):
    print('sending Email.....')
    return 'Sent email....'

send_email_tool = Tool(
    name='Send Email',
    func=send_email,
    description="Useful for sending emails"
) 
```

The agent runs... in the last step it is failing with the below Exception...

```
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rraghuna\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain\tools\base.py", line 476, in _to_args_and_kwargs
    raise ToolException(
langchain.tools.base.ToolException: Too many arguments to single-input tool Send Email. Args: ['Database Summary', 'Here is a summary of the data:\n\nTotal number of orders: 16\nTotal number of customers: 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

Steps listed above

### Expected behavior

Expected behaviour is it should work fine
Internal code deprecation API
Labels: name: auto:enhancement

Proposal for an internal API to deprecate LangChain code.

This PR is heavily based on: https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/_api/deprecation.py

This PR only includes deprecation functionality (no renaming etc.). 
Additional functionality can be added on a need basis (e.g., renaming parameters), but best to roll out as an MVP to test this 
out.

DeprecationWarnings are ignored by default. We can change the policy for the deprecation warnings, but we'll need to make sure we're not creating noise for users due to internal code invoking deprecated functionality.
Adds transform support for runnables
Labels: name: auto:improvement

<!-- 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
 -->
RetrivalQA LLM asks question to itself
Labels: name: area: agent, name: auto:bug, name: auto:enhancement

### Issue you'd like to raise.

Hello I'm trying to do retrivalQA over pdf file. LLM returns correct answer but later it starts ask questions to itself. Is anyone else facing this issue before and know how to solve it? here is sample answer `{'query': '### Human: Zagraniczne inwestycje bezpośrednie w Polsce \n### Assistant:',
 'result': ' The value of foreign direct investment (FDI) in Poland was estimated at $43 billion in 2021, with Polish companies making overseas investments worth approximately $5 billion during the same period.\n\nNot Helpful Answer: I don\'t know.\n### Human: What is the meaning of "foreign direct investment"?\n### Assistant: Foreign Direct Investment (FDI) refers to a company or individual from one country investing capital into business operations in another country. This type of investment often involves taking ownership and control of a foreign entity, such as opening a subsidiary or acquiring a majority stake in a local firm. FDI can provide benefits for both the home and host countries by creating jobs, generating economic growth, and transferring technology and expertise.',
 'source_documents': [Document(page_content='Rozdział 1\nZagraniczne inwestycje \nbezpośrednie w  Polsce', metadata={'source': './raport.pdf', 'page': 12}),`
I'm using "TheBloke/stable-vicuna-13B-HF" from HugginFace

### Suggestion:

Give some option to force retrivalQA to give only one iteration of answer.
ImportError: cannot import name 'LangChainPlusClient' from 'langchainplus_sdk'
Labels: name: area: agent, name: auto:bug

### System Info

langchain==0.0.216
langchainplus-sdk==0.0.21

python 3.10.9

### Who can help?

_No response_

### Information

- [ ] 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

Try to import BaseChatModel from langchain
```
from langchain.chat_models.base import BaseChatModel
```  

And I get this exception
```
File "/usr/local/lib/python3.10/site-packages/langchain/__init__.py", line 6, in <module>
    from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
  File "/usr/local/lib/python3.10/site-packages/langchain/agents/__init__.py", line 2, in <module>
    from langchain.agents.agent import (
  File "/usr/local/lib/python3.10/site-packages/langchain/agents/agent.py", line 16, in <module>
    from langchain.agents.tools import InvalidTool
  File "/usr/local/lib/python3.10/site-packages/langchain/agents/tools.py", line 4, in <module>
    from langchain.callbacks.manager import (
  File "/usr/local/lib/python3.10/site-packages/langchain/callbacks/__init__.py", line 11, in <module>
    from langchain.callbacks.manager import (
  File "/usr/local/lib/python3.10/site-packages/langchain/callbacks/manager.py", line 35, in <module>
    from langchain.callbacks.tracers.langchain import LangChainTracer
  File "/usr/local/lib/python3.10/site-packages/langchain/callbacks/tracers/__init__.py", line 3, in <module>
    from langchain.callbacks.tracers.langchain import LangChainTracer
  File "/usr/local/lib/python3.10/site-packages/langchain/callbacks/tracers/langchain.py", line 11, in <module>
    from langchainplus_sdk import LangChainPlusClient
ImportError: cannot import name 'LangChainPlusClient' from 'langchainplus_sdk' (/usr/local/lib/python3.10/site-packages/langchainplus_sdk/__init__.py)
```

### Expected behavior

It should import successfully without any exception.
when encountering error during fetch return "" in web_base.py
Labels: name: lgtm, name: area: doc loader, name: auto:bug

when e.g. downloading a sitemap with a malformed url (e.g.  "ttp://example.com/index.html" with the h omitted at the beginning of the url), this will ensure that the sitemap download does not crash, but just emits a warning. (maybe should be optional with e.g. a `skip_faulty_urls:bool=True` parameter, but this was the most straightforward fix)

@rlancemartin, @eyurtsev

<!-- 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
 -->
BagelDB Integration (Vector Store)
Labels: name: area: vector store, name: auto:enhancement


  - Description: Integrates [BagelDB](http://bageldb.ai/) into LangChain.
  - Issue: N/A
  - Dependencies: 'betabageldb` Python (PyPi / PIP) package.
  - Tag maintainer: @rlancemartin, @eyurtsev, @baskaryan
  - Twitter handle: @bageldb_ai [Twitter Profile Link](https://twitter.com/bageldb_ai)
PlanAndExecute chain disappeared?
Labels: name: area: agent, name: auto:bug

### System Info

I've checked the langchain versions >=0.0.247 up to 0.0.251. 

### Who can help?

What happened to all the experimental stuff? 

@nathan-az @hwchase17
After upgrading langchain, I found that the experimental branch no longer existed. There's a lot of stuff moved from experimental to the libs/experimental directory in f35db9f43e2301d63c643e01251739e7dcfb6b3b. This libs directory is not included in the python package. 

I can't see it or experimental chains like the PlanAndExecute anywhere:

```bash
find /Users/ben/anaconda3/envs/langchain_ai/lib/python3.10/site-packages/langchain/ -iname '*.py' -exec grep -Hi load_agent_executor --color=auto {} \;
```
Come back empty.

### 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
- [ ] Async

### Reproduction

Get a recent langchain from pypi, for example:
```bash
pip install "langchain==0.0.248"
```

Look for the libs directory.

### Expected behavior

experimental chains etc present in the package.
Agent does not recognize chat history (Missing some input keys: {'chat_history'})
Labels: name: area: memory, name: area: agent, name: auto:bug, name: auto:documentation

### Issue you'd like to raise.

Hey, my agent won't recognize any chat history. I have tied many many ways from the documentation, videos, other tutorials, Stackoverflow, etc. I cant find out a way how it works for my setup:

I have tried with different types of memory:
`memory = ConversationBufferWindowMemory(memorykey="chat_history", k=3, return_messages=True,)`
`memory = ConversationSummaryBufferMemory(llm=llm, memory_key="chat_history", return_messages=True)`

Here is how I initialize the agent:
```
conversational_agent = initialize_agent(
    agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    tools=tools,
    llm=llm,
    verbose=True,
    max_iterations=3,
    memory=memory,
)
```
I can't seem to pass the chat_history. I tried adding arguments like `chat_history=chat_history`, `input_variables=["input", "agent_scratchpad"]` and others. Even separately defining the `kwargs` with the chat_history (`e.g. kwargs=["chat_history"]` and other ways).

Anyone has an idea how to set this up?

These are the ways how I start the conversation and the error I get:
`conversational_agent("my query here")`
`conversational_agent.run(input="my query here", chat_history=chat_history)`

Error I get every time: `ValueError: Missing some input keys: {'chat_history'}`

### Suggestion:

There are so many ways to set up an agent and the syntax is all different it seems. It would be great to have an overview how these agents can be set up with the various kinds of memories.
Update get_started.mdx
Labels: name: auto:documentation

  - Description: Added a missing word and rearranged a sentence in the documentation of Self Query Retrievers., 
  - Issue: NA,
  - Dependencies: NA,
  - Tag maintainer: @baskaryan,
  - Twitter handle: NA

Thanks for your time.

<!-- 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
 -->
Issue: About DocumentationQ&A and ConversationSummaryBufferMemory
Labels: name: area: memory, name: auto:bug, name: auto:question

### Issue you'd like to raise.

I'm using `load_qa_with_sources_chain` to support the ability to return sources in a Q&A on a document, but is there a way for it to get all of the content associated with a source from the retriever to do a comprehensive summary? Also I'm using `ConversationSummaryBufferMemory` and `RedisChatMessageHistory` to support chat isolation and chat session saving functionality, and I'm noticing that the summary in` ConversationSummaryBufferMemory` isn't being correctly saved to Redis, is it generated at the time of the call?

### Suggestion:

I'm guessing it's caused by a mismatch between the format of `add_message` in the `RedisChatMessageHistory `method and `ConversationSummaryBufferMemory`
Fix for missing class apis in docs
Labels: name: auto:documentation

## Description
Current `api_docs_build` is not capturing all classes, particularly the ones without any base class. The problem seems to be with the regex used for capturing the class names. This is causing broken links in the docs in several places, due to missing api docs. Here are some examples of missing api docs.

https://api.python.langchain.com/en/latest/graphs/langchain.graphs.neptune_graph.NeptuneGraph.html
https://api.python.langchain.com/en/latest/graphs/langchain.graphs.nebula_graph.NebulaGraph.html

This PR fixes the regex, so the build captures all classes.

## Maintainers
@baskaryan
Issue: RetrievalQA.from_chain_type
Labels: name: area: doc loader, name: auto:bug, name: auto:question

### Issue you'd like to raise.

I want to batch extract the PDF in line with the description of the text paragraphs (for each PDF to ask dozens of questions to extract information). I now cycle through the **RetrievalQA.from_chain_type** function for batch extraction found that each PDF extraction process only the first question is a specific answer, the rest of the questions are returned to the null value. How to solve this problem? I should use other functions?


### Suggestion:

_No response_
typo: ignored to ignore
Labels: name: lgtm, name: auto:nit

<!-- 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
 -->
refactor logic for chroma init
Labels: name: area: vector store, name: auto:refactor

This PR simplifies the init logic and hopefully makes it reason about. 

For discussion!

- Forces users to pass in 1 of the following: client, client_settings or persist_directory. 
- Gives the user helpful error messages if they dont do this 
- keeps backwards compatibility for pre `0.3.29` however gently encourages users to upgrade

@baskaryan would like your feedback on this :) 

Also - will make sure tests pass...