delayedkarma/langchain-issues huggingface dataset:
Kendra retriever api

## Description
Replaces [Kendra Retriever](https://github.com/hwchase17/langchain/blob/master/langchain/retrievers/aws_kendra_index_retriever.py) with an updated version that uses the new [retriever API](https://docs.aws.amazon.com/kendra/latest/dg/searching-retrieve.html) which is better suited for retrieval augmented generation (RAG) systems.

**Note**: This change requires the latest version (1.26.159) of boto3 to work. `pip install -U boto3` to upgrade the boto3 version.

cc @hupe1980
cc @dev2049



<!-- 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: @dev2049
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @dev2049
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @vowelparrot
  - 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
 -->
Add enum fields to parameters when constructing openai function requests
Labels: name: auto:improvement

**Description:** Added `add_enum_properties` into `format_tool_to_openai_function` which adds enum details from `tools.arg_schema.schema()` into OpenAI Functions API requests, to make the response more relevant; similar to how enum is used in [this tutorial](https://platform.openai.com/docs/guides/gpt/function-calling) for the `["celsius", "fahrenheit"]`. 

There are several cases where an enum in the parameters where pydantic handles differently not as a simple `"enum"` key in the schema, most were covered in the unit test here `tests/unit_tests/tools/test_convert_to_openai.py`.

**Issue:** None
**Dependencies:** N/A
**Tag maintainers:** @vowelparrot
**Twitter handle:** ZhiHaoLow

It's my first time here, if there are any things that need amendment please let me know. 

OpenAI Functions seems promising and fun and hope I can contribute more! 😄
GuardrailsOutputParser, added pydantic support.

**Description**: Added `from_rail_pydantic` to `GuardrailsOutputParser` which maps to the `guardrails.Guard.from_pydantic` method recently added and offers the option to use pydantic BaseModel classes instead of RAIL spec to define the guardrails Guard.
**Issue**: None
**Dependencies**: N/A
**Tag maintainers**:   @dev2049 @hwchase17 

This is my first time contributing to this repo, lmk if anything else needs adding.
ChatVertexAI Error: _ChatSessionBase.send_message() got an unexpected keyword argument 'context'

### System Info

langchain version: 0.0.209

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] 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

https://python.langchain.com/docs/modules/model_io/models/chat/integrations/google_vertex_ai_palm

### Expected behavior

I get an error saying "TypeError: _ChatSessionBase.send_message() got an unexpected keyword argument 'context'" when I run `chat(messages)` command mentioned in https://python.langchain.com/docs/modules/model_io/models/chat/integrations/google_vertex_ai_palm. 

This is probably because ChatSession.send_message does not have the argument 'context' and ChatVertexAI._generate automatically adds the context argument to params since chat-bison being a non-code model.
feat: add MultiStrategy output parser
Labels: name: enhancement

**tldr**: fancy name for brute forcing multiple parsing functions before giving up with an exception.


#### Description:

- This PR introduces a new type of output parser interface and implementation that can try multiple strategies
- A strategy is a tuple-like class of `(parser, predicate, name=None)` *see strategies.py*
- Strategies are tried if predicate is True
- Strategies are tried in order, allows for fallbacks
- New strategies can be added to handle new output errors and coverd by unit tests.
- Base interface allows existing parsers to implement it

```python
# strategies can be defined like this
    parse_strategies = (
        ParseStrategy(parse_raw_json, is_json),
        ParseStrategy(code_block, lambda text: text.find('```') != -1), name="md_code_block"),
        ...,
        ParseStrategy(fallback, lambda _:True)
    )
    
    # then passed to the implementer:
    my_parser = MyMultiParser(parse_strategies)
```

In this first pass I implemented a ConvoOutputParser that implements multi strategy. I also implemented some example parsing strategies that can handle most exceptions on nested code blocks in json. *see the tests and test outputs*

 Looking for feedback if this is something worth pursuing and whether the code organization is right.



 @hwchase17, @dev2049
Just corrected a small inconsistency on a doc page
Labels: name: lgtm

### Just corrected a small inconsistency on a doc page (not exactly a typo, per se)
  - Description: There was inconsistency due to the use of single quotes at one place on the [Squential Chains](https://python.langchain.com/docs/modules/chains/foundational/sequential_chains) page of the docs, 
  - Issue: NA,
  - Dependencies: NA,
  - Tag maintainer: @dev2049,
  - Twitter handle: kambleakash0
Fix typo in myscale_self_query.ipynb

lenth -> length

<!-- 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: @dev2049
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @dev2049
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @vowelparrot
  - 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
 -->
response does not call the plugin

### System Info

Hello, 

When using AIPluginTool with ChatOpenAI

sometimes the chain call the plugin and sometimes the response is like "the user can call the url ... to get the response" . Why is it?


My code:




import os

import openai
from dotenv import load_dotenv, find_dotenv
from langchain.chat_models import ChatOpenAI

from langchain.tools import AIPluginTool
from langchain.agents import load_tools, ConversationalChatAgent, ZeroShotAgent
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
from langchain.agents.agent import AgentExecutor




tool = AIPluginTool.from_plugin_url("http://localhost:5003/.well-known/ai-plugin.json")
tools2 = load_tools(["requests_get"] )

tools = [tool,tools2[0]]


_ = load_dotenv(find_dotenv()) #read local .env file
openai.api_key = os.getenv('OPENAI_API_KEY')

llm=ChatOpenAI(
    openai_api_key=os.getenv('OPENAI_API_KEY'),
    temperature=0,
    model_name='gpt-3.5-turbo'
)


prefix = """Have a conversation with a human, answering the following questions as best you can. You have access to the following tools:"""


memory = ConversationBufferWindowMemory(
    memory_key="chat_history",  
    k=5,
    return_messages=True
)


custom_agent = ConversationalChatAgent.from_llm_and_tools(llm=llm, tools=tools, system_message=prefix)


agent_executor = AgentExecutor.from_agent_and_tools(agent=custom_agent, tools=tools, memory=memory)
agent_executor.verbose = True


print(
    agent_executor.agent.llm_chain.prompt
)

resp = agent_executor.run(input="What are my store orders  for userId Leo ?")

print(
    resp
)


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] 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
- [X] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

execute the code , two or three times. you will get a different response

### Expected behavior

call the plugin and get the response from http://localhost:5003/order/Leo
Issue: why SQLAlchemy 2.0 is forced?

### Issue you'd like to raise.

I need to upgrade our Langchain version due to a security issue flagged in version 0.0.27 (see https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAIN-5411357).

However, I can't do this because Langchain depends on SQLAlchemy 2.0, while we use 1.4.

1. Why is SQLALchemy 2.0 needed? It might be useful for a tiny feature out of all the Langchain functionality...
2. SQLAlchemy 1.4 is still more widely used than 2.0

### Suggestion:

Not forcing 2.0, but >1.4 - should support the same syntax -> https://docs.sqlalchemy.org/en/14/
ImportError: cannot import name 'RetrievalQAWithSourcesChain' from 'langchain.chains'

### System Info

Langchain 0.27
Python 3.7
Amazon Linux

### Who can help?

@ag

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

### Reproduction

At launch, after recreating python venv and reinstalling latest version of langchain the error message is:
ImportError: cannot import name 'RetrievalQAWithSourcesChain' from 'langchain.chains'

### Expected behavior

This import should not cause an error.
feat: Add `UnstructuredRSTLoader`

### Summary

Adds an `UnstructuredRSTLoader` for loading [reStructuredText](https://en.wikipedia.org/wiki/ReStructuredText) file.

### Testing

```python
from langchain.document_loaders import UnstructuredRSTLoader

loader = UnstructuredRSTLoader(
    file_path="example_data/README.rst", mode="elements"
)
docs = loader.load()
print(docs[0])
```

### Reviewers

- @hwchase17 
- @rlancemartin 
- @eyurtsev
Issue: Summarization using Vertex AI - returns 400 Error on certain cases 

### Issue you'd like to raise.

We are trying to summarize contents of some URLs using Vertex AI. Below is the code snippet
```
from langchain.llms import VertexAI
from langchain.chains.summarize import load_summarize_chain

llm = VertexAI(temperature=0.5, max_output_tokens=1024)
chain = load_summarize_chain(llm, chain_type="map_reduce")

def digest(url, driver):
    
    # Get page source HTML
    html = driver.page_source

    # Parse HTML with BeautifulSoup
    soup = BeautifulSoup(html, 'html.parser')

    get_html_and_add(soup, url)

def get_html_and_add(soup: BeautifulSoup, url: str):
    text = soup.get_text()

    if soup.title:
        title = str(soup.title.string)
    else:
        title = ""

    vector_store.add_documents(summary_text(text, url, title))
    vector_store.persist()


def summary_text(docs: str, url: str, title: str):
    
    metadata: Dict[str, Union[str, None]] = {
        "source": url,
        "title": title,
    }
    docs = [Document(page_content=docs, metadata=metadata)]
    val = chain.run(docs)
    print(f'summary for url {url} is \n {val}')
    return [Document(page_content=val, metadata=metadata)]
```
The code works fine for most of the URLs, however, for few URLs, we are receiving the attached error, when ```chain.run(docs)``` is invoked in the method ```summary_text```

[Error.txt](https://github.com/hwchase17/langchain/files/11835133/Error.txt)

Not able to identify the root cause, any help is appreciated. 

Thank you!
PS: Unable to share the URL as it is an internal URL. The langchain version that we use is the latest as of today i.e., 0.0.208.



### Suggestion:

_No response_
beautifulsoup get_text kwargs in WebBaseLoader

# beautifulsoup get_text kwargs in WebBaseLoader

  - Description: this PR introduces an optional `bs_get_text_kwargs` parameter to `WebBaseLoader` constructor. It can be used to pass kwargs to the downstream BeautifulSoup.get_text call. The most common usage might be to pass a custom text separator, as seen also in `BSHTMLLoader`. 
  - Tag maintainer: @rlancemartin, @eyurtsev
  - Twitter handle: jtolgyesi
DOC: RecursiveTextSplitter function doesn't exist

### Issue with current documentation:

https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/recursive_text_splitter

this function isn't to be found in the text_splitter.py file :

from langchain.text_splitter import RecursiveCharacterTextSplitter

this returns an error.




### Idea or request for content:

_No response_
Not able to clear Conversationbuffermemory.

### Feature request

The current implementation of ConversationBufferMemory lacks the capability to clear the memory history. When using the load_qa_chain function with ConversationBufferMemory and uploading the abc.pdf file for the first time, subsequent questions based on that document yield expected answers. However, if I then change the file to 123.pdf and ask the same questions as before, the system provides the same answers as those given for the previous pdf.

Unfortunately, I have not found a clear_history function within the ConversationBufferMemory, which would enable me to reset or remove the previous memory records.

### Motivation

add that clear_history under ConversationBufferMemory to clear all previous saved messages.

### Your contribution

no
Typo

### System Info

latest version

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

Typo on :
https://github.com/hwchase17/langchain/blob/d50de2728f95df0ffc59c538bd67e116a8e75a53/langchain/vectorstores/weaviate.py#L49

Instal - > install

### Expected behavior

typo corrected
Improve PubMedAPIWrapper to get the PubMed ID and/or DOI and/or journal information returned.

### Feature request

Improve PubMedAPIWrapper to get the PubMed ID and/or DOI and/or journal information returned.

Please rename
langchain/utilities/pu**p**med.py
to
langchain/utilities/pu**b**med.py

### Motivation

A user of a chat model can ask the model to provide a link to the original literature to verify if the answer of the model makes sense.

### Your contribution

None.
Dev2049/azure endpoint

### Description

We have added a new LLM integration `azureml_endpoint` that allows users
to leverage models from the AzureML platform. Microsoft recently
announced the release of [Azure Foundation
Models](https://learn.microsoft.com/en-us/azure/machine-learning/concept-foundation-models?view=azureml-api-2)
which users can find in the AzureML Model Catalog. The Model Catalog
contains a variety of open source and Hugging Face models that users can
deploy on AzureML. The `azureml_endpoint` allows LangChain users to use
the deployed Azure Foundation Models.

### Dependencies

No added dependencies were required for the change.

### Tests

Integration tests were added in
`tests/integration_tests/llms/test_azureml_endpoint.py`.

### Notebook

A Jupyter notebook demonstrating how to use `azureml_endpoint` was added
to `docs/modules/llms/integrations/azureml_endpoint_example.ipynb`.

### Twitters

[Prakhar Gupta](https://twitter.com/prakhar_in)
[Matthew DeGuzman](https://twitter.com/matthew_d13)
unable to use matching engine

### System Info

langchain 0.0.207
platform ubuntu
python 3.9


### Who can help?

@hwaking @eyurtsev @tomaspiaggio 

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

python script
```
from langchain.embeddings import VertexAIEmbeddings
embeddings = VertexAIEmbeddings()
llm = VertexAI(model_name='text-bison')

from langchain.vectorstores import MatchingEngine

texts = ['The cat sat on', 'the mat.', 'I like to', 'eat pizza for', 'dinner.', 'The sun sets', 'in the west.']

vector_store = MatchingEngine.from_components(
    project_id=project,
    region=location,
    gcs_bucket_name='bucket_name',
    index_id="index_id",
    endpoint_id="endpoint_id",
    embedding=embeddings
)
```

error message
[error.txt](https://github.com/hwchase17/langchain/files/11830103/error.txt)




### Expected behavior

expected behavior is pushing the vectors to vectorstore
Use modern OpenAI endpoints for embeddings

  - Description: 

LangChain passes [engine](https://github.com/hwchase17/langchain/blob/master/langchain/embeddings/openai.py#L256) and not `model` as a field when making OpenAI requests. Within the `openai` Python library, for OpenAI requests, this [makes a call](https://github.com/openai/openai-python/blob/main/openai/api_resources/abstract/engine_api_resource.py#L58) to an endpoint of the form `https://api.openai.com/v1/engines/{engine_id}/embeddings`. 

These endpoints are [deprecated](https://help.openai.com/en/articles/6283125-what-happened-to-engines) in favor of endpoints of the format `https://api.openai.com/v1/embeddings`, where `model` is passed as a parameter in the request body.

While these deprecated endpoints continue to function for now, they may not be supported indefinitely and should be avoided in favor of the newer API format.

It appears that `engine` was passed in instead of `model` to make both Azure OpenAI and OpenAI calls work similarly. However, the inclusion of `engine` [causes](https://github.com/openai/openai-python/blob/main/openai/api_resources/abstract/engine_api_resource.py#L58) OpenAI to use the deprecated endpoint, requiring a diverging code path for Azure OpenAI calls where `engine` is passed in additionally (Azure OpenAI requires `engine` to specify a deployment, and can optionally take in `model`).

In the long-term, it may be worth considering spinning off Azure OpenAI embeddings into a separate class for ease of use and maintenance, similar to the [implementation for chat models](https://github.com/hwchase17/langchain/blob/master/langchain/chat_models/azure_openai.py).

  - Tag maintainer: @dev2049 @hwchase17
Refactor vector storage to correctly handle relevancy scores

Description: This pull request aims to support generating the correct generic relevancy scores for different vector stores by refactoring the relevance score functions and their selection in the base class and subclasses of VectorStore. This is especially relevant with VectorStores that require a distance metric upon initialization. Note many of the current implenetations of `_similarity_search_with_relevance_scores` are not technically correct, as they just return       `self.similarity_search_with_score(query, k, **kwargs)`  without applying the relevant score function

Also includes changes associated with: https://github.com/hwchase17/langchain/pull/6564 and https://github.com/hwchase17/langchain/pull/6494

See more indepth discussion in thread in #6494 

Issue: 
https://github.com/hwchase17/langchain/issues/6526
https://github.com/hwchase17/langchain/issues/6481
https://github.com/hwchase17/langchain/issues/6346

Dependencies: None

The changes include:
- Properly handling score thresholding in FAISS `similarity_search_with_score_by_vector` for the corresponding distance metric. 
- Refactoring the `_similarity_search_with_relevance_scores` method in the base class and removing it from the subclasses for incorrectly implemented subclasses.
- Adding a `_select_relevance_score_fn` method in the base class and implementing it in the subclasses to select the appropriate relevance score function based on the distance strategy.
- Updating the `__init__` methods of the subclasses to set the `relevance_score_fn` attribute.
- Removing the `_default_relevance_score_fn` function from the FAISS class and using the base class's `_euclidean_relevance_score_fn` instead.
- Adding the `DistanceStrategy` enum to the `utils.py` file and updating the imports in the vector store classes.
- Updating the tests to import the `DistanceStrategy` enum from the `utils.py` file.
Remove duplicate databricks entries in ecosystem integrations

Currently, there are two Databricks entries in https://python.langchain.com/docs/ecosystem/integrations/
<img width="277" alt="image" src="https://github.com/hwchase17/langchain/assets/1097932/86ab4ad2-6bce-4459-9d56-1ab2fbb69f6d">

The reason is that there are duplicated notebooks for Databricks integration:
* https://github.com/hwchase17/langchain/blob/master/docs/extras/ecosystem/integrations/databricks.ipynb
* https://github.com/hwchase17/langchain/blob/master/docs/extras/ecosystem/integrations/databricks/databricks.ipynb

This PR is to remove the second one for simplicity.
[VectorStores][FAISS] Score threshold implementation fix

# Description: 
Support different metric types for FAISS (and adds generic enum for different vector stores) and fixes bug for score threshold filtering

Currently FAISS implementation will filter out scores that are less than the score threshold (for L2, but it should keep these scores, see issue below). If the index is constructed using inner product or jaccard e.g. it should use ge. 

# Issue
https://github.com/hwchase17/langchain/issues/6526

# Tag maintainer:
DataLoaders / VectorStores / Retrievers:
@rlancemartin, @eyurtsev
feat: interfaces for async embeddings, implement async openai

Since it seems like #6111 will be blocked for a bit, I've forked @tyree731's fork and implemented the requested changes.

This change adds support to the base Embeddings class for two methods, aembed_query and aembed_documents, those two methods supporting async equivalents of embed_query and
embed_documents respectively. This ever so slightly rounds out async support within langchain, with an initial implementation of this functionality being implemented for openai.

Implements https://github.com/hwchase17/langchain/issues/6109