delayedkarma/langchain-issues huggingface dataset:
Modify Anyscale integration to work with Anyscale Endpoint
Labels: name: lgtm, name: auto:improvement, name: area: models

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

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

**Description**:

- Added Momento Vector Index (MVI) as a vector store provider. This includes an implementation with docstrings, integration tests, a notebook, and documentation on the docs pages.
- Updated the Momento dependency in pyproject.toml and the lock file to enable access to MVI.
- Refactored the Momento cache and chat history session store to prefer using "MOMENTO_API_KEY" over "MOMENTO_AUTH_TOKEN" for consistency with MVI. This change is backwards compatible with the previous "auth_token" variable usage. Updated the code and tests accordingly.

**Dependencies**:

- Updated Momento dependency in pyproject.toml.

**Testing**:

- Run the integration tests with a Momento API key. Get one at the [Momento Console](https://console.gomomento.com) for free. MVI is available in AWS us-west-2 with a superuser key.
- `MOMENTO_API_KEY=<your key> poetry run pytest tests/integration_tests/vectorstores/test_momento_vector_index.py`

**Tag maintainer:**

@eyurtsev

**Twitter handle**:

Please mention @momentohq for this addition to langchain. With the integration of Momento Vector Index, Momento caching, and session store, Momento provides serverless support for the core langchain data needs.

Also mention @mlonml for the integration.
DOC: Remove the Link Icon in the footer due to the docusaurus default settings
Labels: name: auto:documentation

### Issue with current documentation:

The current Docusaurus default settings display a link icon in the footer of the website. This icon is a small hyperlink symbol that appears next to external links in the footer. While this may be a helpful feature for some websites, it may not align with the design or functional requirements of our documentation site.


### Idea or request for content:

The goal of this issue is to remove the link icon from the footer of our Docusaurus-powered website. This will result in a cleaner and more minimalistic footer design.

Expected Behavior:
The link icon should be removed from the footer, ensuring that external links are presented without the additional icon.

Attachments:

Current Footer:

![Screenshot 2023-10-09 at 11 27 21 PM](https://github.com/langchain-ai/langchain/assets/41548480/4bde2e20-89be-478f-8f2c-e81b580c5eba)
Add callback function to RunnablePassthrough
Labels: name: auto:improvement

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

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

### System Info

LangChain v0.0.304

### Who can help?

@hwchase17 @ag

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

Use a combine documents chain with Bedrock/anthropic.claude-v2 LLM:

```python
from langchain.chains.question_answering import load_qa_chain
from langchain.llms import Bedrock

llm = Bedrock(model_id="anthropic.claude-v2")
chain = load_qa_chain(llm, chain_type="map_reduce", verbose=verbose, **kwargs)
chain.run(...)
```

### Expected behavior

The chain runs correctly.

Instead, a series of warnings are raised about missing `transformers` library, about too long context passed to tokenizer, etc. etc., and at last the chain fails to run.

## Background

The default implementation of `get_token_ids` and `get_num_tokens` in `BaseLanguageModel` uses a GPT-2 based tokenizer. The `Bedrock` LLM implementation does not override these methods, so it tries to tokenize the text with the incorrect tokenizer. In the particular case when using `anthropic.claude-v2` model, this causes incorrect token counting, requires an otherwise unnecessary dynamic dependencies (the transformers library), and emits a series of warnings about too long input text passed for tokenizer.
Update Dockerfile.base
Labels: name: auto:nit

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

### Issue with current documentation:

On the class description page there is no list with links to class methods

The class:
langchain.chains.retrieval_qa.base.RetrievalQA
https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval_qa.base.RetrievalQA.html#langchain.chains.retrieval_qa.base.RetrievalQA

List as on this page:
https://api.python.langchain.com/en/latest/callbacks/langchain.callbacks.streaming_stdout.StreamingStdOutCallbackHandler.html#langchain.callbacks.streaming_stdout.StreamingStdOutCallbackHandler

### Idea or request for content:

_No response_
feature: add metadata information into the embedding file before uplo…
Labels: name: area: vector store, name: auto:improvement

Replace this entire comment with:
  - **Description:** In this modified version of the function, if the metadatas parameter is not None, the function includes the corresponding metadata in the JSON object for each text. This allows the metadata to be stored alongside the text's embedding in the vector store.
  - 
  - **Issue:** #10924
  - **Dependencies:** None
  - **Tag maintainer:** @hwchase17
@agola11
  - **Twitter handle:** @MelliJoaco
RFC: Implement stream/transform in RunnableRetry
Labels: name: auto:improvement

Yield a "stream reset" marker before starting the next attempt

Open question: How to deal with this best in RunnableSequence/RunnableMap? The next steps in the sequence are probably not designed to handle the reset marker, should RunnableSequence retry all steps after "current" once it sees a retry marker?

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
doc: Fix documentation about n-gram overlap
Labels: name: auto:documentation

This commit fixes the documentation about n-gram overlap that unrelated variables are declared.

Replace this entire comment with:
  - **Description:** Fix the documentation in https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap. It's currently declaring unrelated variables, for example, `examples` local variable is declared twice and the first one is overwritten immediately.
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** @dosuken123

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
Issue: <Getting error while setting up a RetrievalQA  Conversation  with Faiss_cpu  prefix>
Labels: name: area: embeddings, name: auto:bug, name: area: models

### Issue you'd like to raise.

I am getting this error while setting a RetrievalQA using FAISS, the code is as follows:

Using the following version on a MAC :   python 3.10,  Faiss_cpu 1.7.4, langchain  0.0.310


        embeddings_model_name = os.environ.get('EMBEDDINGS_MODEL_NAME')
        faiss_index = os.environ.get('FAISS_INDEX')
        embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name)
        self.db = FAISS.load_local(faiss_index, embeddings)

            retriever = self.db.as_retriever(
                search_type="mmr",
                search_kwargs={'k': 5, 'fetch_k': 10}
            )


            prompt = [
                ("human", "Hello"),
                ("assistant", "Hi there!"),
            ]

            qa = RetrievalQA.from_chain_type(
                llm=self.llm,
                chain_type="refine",
                retriever=retriever,
                return_source_documents=True,
                chain_type_kwargs={"prompt": prompt}
            )

            res = qa({
                "query": query,
                "prompt": prompt,
                "context": "You are helpful"
            })

The error is as follows:

([ErrorWrapper(exc=ExtraError(), loc=('prompt',))], <class 'langchain.chains.combine_documents.refine.RefineDocumentsChain'>)

The console show the following:

rompt : [('human', 'Hello'), ('assistant', 'Hi there!')]
self.llm : LlamaCpp
Params: {'model_path': 'models/llama-2-7b-chat.Q8_0.gguf', 'suffix': None, 'max_tokens': 256, 'temperature': 0.8, 'top_p': 0.9, 'logprobs': None, 'echo': False, 'stop_sequences': [], 'repeat_penalty': 1.1, 'top_k': 40}
Failed while retrieve documents: ([ErrorWrapper(exc=ExtraError(), loc=('prompt',))], <class 'langchain.chains.combine_documents.refine.RefineDocumentsChain'>)
Query response None 




### Suggestion:

_No response_
Support max_marginal_relevance_search for ElasticSearchStore
Labels: name: area: vector store, name: auto:bug

### System Info

max_marginal_relevance_search is mentioned in the ElasticSearchStore python documentation, but when calling the referenced API with langchain 0.0.310 and Python 3.9 I receive a NotImplementedError.

https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elasticsearch.ElasticsearchStore.html#langchain.vectorstores.elasticsearch.ElasticsearchStore.max_marginal_relevance_search

### Who can help?

_No response_

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

### Reproduction

```
vector_store = ElasticsearchStore(
    embedding=OpenAIEmbeddings(),
    index_name="{INDEX_NAME}",
    es_cloud_id="{CLOUD_ID}",
    es_user="{USER}",
    es_password="{PASSWORD}"
)

pages = vector_store.max_marginal_relevance_search("test query")
```



### Expected behavior

max_marginal_relevance_search functions as per the documentation.
Issue: Inference Client in Lang chain
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

Hi, I am trying to use Hugging Face model for langchain. However, I got this error :

"FutureWarning: '__init__' (from 'huggingface_hub.inference_api') is deprecated and will be removed from version '0.19.0'. `InferenceApi` client is deprecated in favor of the more feature-complete `InferenceClient`. Check out this guide to learn how to convert your script to use it: https://huggingface.co/docs/huggingface_hub/guides/inference#legacy-inferenceapi-client."

This is my code :

`

  os.environ["HUGGINGFACEHUB_API_TOKEN"] = huggingFace_api_key
  
  llm_repo_id = "google/flan-t5-xxl"
  
  def generate_pet_name(animal_type,pet_color):
      llm = HuggingFaceHub(
      repo_id=llm_repo_id, model_kwargs={"temperature": 0.5})

      prompt_template = PromptTemplate(
          input_variables = ['animal_type','animal_color'],
          template = "I have an {animal_type} with {animal_color} in color. Suggest me five name which sound" 
                                                      + "appropriate with the color for my {animal_type}")
  
      name_chain = LLMChain(llm=llm,prompt=prompt_template,output_key="pet_name")
  
      response = name_chain({'animal_type':animal_type,'animal_color':pet_color})
      return response


`

How do I get rid of this warning.

### Suggestion:

_No response_
User-Agent needs to be set for RecursiveUrlLoader
Labels: name: area: doc loader, name: auto:improvement

### Feature request

Based on the discussion in : https://github.com/langchain-ai/langchain/issues/11540
The WebBaseLoader in LangChain has a default User-Agent set in the session headers, and this could be a good enhancement for the RecursiveUrlLoader as well.

Here's a potential solution:
class RecursiveUrlLoader(BaseLoader):
    """Load all child links from a URL page."""

    def __init__(
        self,
        url: str,
        max_depth: Optional[int] = 2,
        use_async: Optional[bool] = None,
        extractor: Optional[Callable[[str], str]] = None,
        metadata_extractor: Optional[Callable[[str, str], str]] = None,
        exclude_dirs: Optional[Sequence[str]] = (),
        timeout: Optional[int] = 10,
        prevent_outside: Optional[bool] = True,
        link_regex: Union[str, re.Pattern, None] = None,
        headers: Optional[dict] = None,
        check_response_status: bool = False,
    ) -> None:
        ...
        self.headers = headers if headers is not None else {"User-Agent": "Mozilla/5.0"}
        ...



### Motivation

The RecursiveUrlLoader need to have an implicit user-Agent defined with the session like in WebBaseLoader(https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/document_loaders/web_base.py) else some of the websites we are trying to scrape gives a forbidden error.

Troubleshooting the error took a lot of time and finally we realised that it was due to the lack of appropriate headers.
loader = RecursiveUrlLoader(url=web_page,max_depth=1,extractor=lambda x: Soup(x, "html.parser").text)
docs = loader.load()
docs[0]
Document(page_content='\n403 Forbidden\n\n403 Forbidden\nnginx\n\n\n', metadata={'source': '.....', 'title': '403 Forbidden', 'language': None})

from fake_useragent import UserAgent
header_template = {}
header_template["User-Agent"] = UserAgent().random
loader = RecursiveUrlLoader(url=web_page,max_depth=1,headers=header_template,extractor=lambda x: Soup(x, "html.parser").text)
docs = loader.load()
docs[0]
Document(page_content="Hello and Welcome to....)

### Your contribution

yes
Recursive URL doesn't work on some websites until User-Agent is added
Labels: name: area: doc loader, name: auto:bug

### System Info

Python: 3.10

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

>>> loader = RecursiveUrlLoader(url=web_page,max_depth=1,extractor=lambda x: Soup(x, "html.parser").text)
>>> docs = loader.load()
>>> docs[0]
Document(page_content='\n403 Forbidden\n\n403 Forbidden\nnginx\n\n\n', metadata={'source': '.....', 'title': '403 Forbidden', 'language': None})

>>> from fake_useragent import UserAgent
>>> header_template = {}
>>> header_template["User-Agent"] = UserAgent().random
>>> loader = RecursiveUrlLoader(url=web_page,max_depth=1,headers=header_template,extractor=lambda x: Soup(x, "html.parser").text)
>>> docs = loader.load()
>>> docs[0]
Document(page_content="Hello and Welcome to....)

### Expected behavior

The RecursiveUrlLoader need to have an implicit user-Agent defined with the session like in WebBaseLoader(https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/document_loaders/web_base.py) else some of the websites we are trying to scrape gives a forbidden error. 

Troubleshooting the error took a lot of time and finally we realised that it was due to the lack of appropriate headers.