delayedkarma/langchain-issues huggingface dataset:
Implement saving and loading of RetrievalQA chain
Labels: name: lgtm

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes #3983
Mimicing what we do for saving and loading VectorDBQA chain, I added the logic for RetrievalQA chain.
Also added a unit test. I did not find how we test other chains for their saving and loading functionality, so I just added a file with one test case. Let me know if there are recommended ways to test it.

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:
@dev2049
<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
how to clear VectorStoreRetrieverMemory?

### System Info


python: 3.9
langchain: 0.0.190
MacOS 13.2.1 (22D68)


### Who can help?

@hwchase17

### Information

I use **CombinedMemory** which contains **VectorStoreRetrieverMemory** and **ConversationBufferMemory** in my app. It seems that ConversationBufferMemory is easy to clear, but when I use this CombinedMemory in a chain, it will automatically store the context to the vector database, and I can't clear its chat_history unless I create a new database, but that's very time-consuming.
I initially tried various methods to clear the memory, including clearing the CombinedMemory and clearing them separately.
But I looked at the clear method in VectorStoreRetrieverMemory, and it didn't do anything.
![image](https://github.com/hwchase17/langchain/assets/134575521/da3cdad1-e888-45e3-ae43-ff40e0bb0290)
It is worth noting that I am using this vectordatabase in order to be able to retrieve a certain code repository. If there are other alternative methods that can successfully clear session history without affecting the vector database, then that would be even better!

- [ ] 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
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

1. insert 2 files to the vector database
2. ask a question related to them(get the right answer)
3. delete the file and update the database
4. ask the same question
5. Technically speaking, it cannot provide the correct answer, but now it can infer based on chat history.



### Expected behavior

I would like to add that the reason why I don't think the problem lies in updating the database is because when I skip the second step and only add files, delete files, update the database and then ask questions, it behaves as expected and does not give me the correct answer.
Issue: OpenAIEmbeddings class about Azure Openai usage example error

https://github.com/hwchase17/langchain/blob/b3ae6bcd3f42ec85ee65eb29c922ab22a17a0210/langchain/embeddings/openai.py#L100
I was profoundly misled by it when using it, the parameters used in the use case depicted in the example have been renamed to openai_api_base, which seems to be an exact bug, the correct example:
```
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"
os.environ["OPENAI_PROXY"] = "http://your-corporate-proxy:8080"

from langchain.embeddings.openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
    deployment="your-embeddings-deployment-name",
    model="your-embeddings-model-name",
    openai_api_base="https://your-endpoint.openai.azure.com/",
    openai_api_type="azure",
)
text = "This is a test query."
query_result = embeddings.embed_query(text)
```
FIX: backslash escaped

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

LatexTextSplitter needs to use "\n\\\chapter" when separators are escaped, such as "\n\\\chapter", otherwise it will report an error: (re.error: bad escape \c at position 1 (line 2, column 1))


Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use

re.error: bad escape \c at position 1 (line 2, column 1)

See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

@hwchase17  @dev2049 

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
docs: add Shale Protocol integration guide

This PR adds documentation for Shale Protocol's integration with LangChain.

[Shale Protocol](https://shaleprotocol.com) provides forever-free production-ready inference APIs to the open-source community. We have global data centers and plan to support all major open LLMs (estimated ~1,000 by 2025).

The team consists of software and ML engineers, AI researchers, designers, and operators across North America and Asia. Combined together, the team has 50+ years experience in machine learning, cloud infrastructure, software engineering and product development. Team members have worked at places like Google and Microsoft.

#### Who can review?

Tag maintainers/contributors who might be interested:

  - @hwchase17
  - @agola11
Add DeepInfra embeddings integration with tests and examples, better exception handling for Deep Infra LLM.

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:
@hwchase17
<!-- For a quicker response, figure out the right person to tag with @

   - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
fixed faiss integ tests

Fixes # 5807

Realigned tests with implementation.
Also reinforced folder unicity for the test_faiss_local_save_load test using date-time suffix

#### Before submitting

- Integration test updated
- formatting and linting ok (locally) 

#### Who can review?

Tag maintainers/contributors who might be interested:

  @hwchase17 - project lead
  VectorStores / Retrievers / Memory
  -@dev2049
Issue: Integration tests fail for faiss vector store

### Issue you'd like to raise.

Integration tests for faiss vector store fail when run. 
It appears that the tests are not in sync with the module implementation.

command: poetry run pytest tests/integration_tests/vectorstores/test_faiss.py 

Results summary:

======================================================= short test summary info =======================================================
FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_local_save_load - FileExistsError: [Errno 17] File exists: '/var/folders/nm/q080zph50yz4mcc7_vcvdcy00000gp/T/tmpt6hov952'
FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_similarity_search_with_relevance_scores - TypeError: __init__() got an unexpected keyword argument 'normalize_score_fn'
FAILED tests/integration_tests/vectorstores/test_faiss.py::test_faiss_invalid_normalize_fn - TypeError: __init__() got an unexpected keyword argument 'normalize_score_fn'
FAILED tests/integration_tests/vectorstores/test_faiss.py::test_missing_normalize_score_fn - Failed: DID NOT RAISE <class 'ValueError'>
=============================================== 4 failed, 6 passed, 2 warnings in 0.70s ===============================================

### Suggestion:

Correct tests/integration_tests/vectorstores/test_faiss.py to be in sync with langchain.vectorstores.faiss
Update adding_memory.ipynb
Labels: name: lgtm

just change "to" to "too" so it matches the above prompt

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
split up batch llm calls into separate runs

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Issue: JSON agent tool "json_spec_list_keys" does not error when access non existing list

### Issue you'd like to raise.

`json_spec_list_keys` works with not exists list index `[0]` and no error occurs. 
Here is a a simple example.

```python
# [test.json]
#
# {
#   "name": "Andrew Lee",
#   "assets": {"cash": 10000, "stock": 5000}
# }

json_spec = JsonSpec.from_file(pathlib.Path("test.json"))

print(json_spec.keys('data["assets"]'))  # => ['cash', 'stock']
print(json_spec.value('data["assets"]')) # => {'cash': 10000, 'stock': 5000}

print(json_spec.keys('data["assets"][0]')) # => ['cash', 'stock']
print(json_spec.value('data["assets"][0]')) # => KeyError(0)

print(json_spec.keys('data["assets"][1]')) # => KeyError(1)
print(json_spec.value('data["assets"][1]')) # => KeyError(1)
```

`json_spec_list_keys` does not error on non existing [0], but `json_spec_get_value` errors at [0].
This makes the LLM confuse like below and endless error happens.

```
Action: json_spec_list_keys
Action Input: data
Observation: ['name', 'assets']
Thought: I should look at the keys under each value to see if there is a total key
Action: json_spec_list_keys
Action Input: data["assets"][0]
Observation: ['cash', 'stock']
Thought: I should look at the values of the keys to see if they contain what I am looking for
Action: json_spec_get_value
Action Input: data["assets"][0]
Observation: KeyError(0)
Thought: I should look at the next value
Action: json_spec_list_keys
Action Input: data["assets"][1]
Observation: KeyError(1)
...
```

### Suggestion:

`json_spec_list_keys` should raise key-error exception when accessing a non-existent index [0] like `json_spec_get_value` does.

### Who can help?
@vowelparrot
Add UTF-8 json ouput support while langchain.debug is set to True.
Labels: name: lgtm

Before:
<img width="984" alt="image" src="https://github.com/hwchase17/langchain/assets/4317474/2b0807b4-a1d6-4df2-87cc-92b1c8e10534">

After:
<img width="992" alt="image" src="https://github.com/hwchase17/langchain/assets/4317474/128c2c7d-2ed5-4c95-954d-b0964c83526a">


Thanks in advance.

 @agola11
[Docs][Hotfix] Fix broken links

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Some links were broken from the previous merge. This PR fixes them. Tested locally. 

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Utilizing langchain library for SQL database querying with GIS functionality

### Feature request

Hi!

It's possible to integrate the langchain library with a SQL database, enabling the execution of SQL queries with spatial analysis capabilities? 

Specifically, I'd like to leverage GIS functions to perform spatial operations such as distance calculations, point-in-polygon queries, and other spatial analysis tasks.

If the langchain library supports such functionality, it would greatly enhance the capabilities of our project by enabling us to process and analyze spatial data directly within our SQL database.

I appreciate any guidance or information you can provide on this topic. 


### Motivation

By leveraging GIS functions within the langchain library, we can unlock the power of spatial analysis directly within our SQL database combined with LLM.
This integration creates a multitude of possibilities for executing intricate spatial operations, including proximity analysis, overlay analysis, and spatial clustering via user prompts.

### Your contribution

-  I can provide insights into the best practices, optimal approaches, and efficient query design for performing various spatial operations within the SQL database.

-  I can offer troubleshooting assistance and support to address any issues or challenges that may arise during the integration of the langchain library. I can provide guidance on resolving errors, improving performance, and ensuring the accuracy of spatial analysis results.
LOTR: Lord of the Retrievers. A retriever that merge several retrievers together applying document_formatters to them.

"One Retriever to merge them all, One Retriever to expose them, One Retriever to bring them all and in and process them with Document formatters."

Hi @dev2049! Here bothering people again!

I'm using this simple idea to deal with merging the output of several retrievers into one.
I'm aware of DocumentCompressorPipeline and ContextualCompressionRetriever but I don't think they allow us to do something like this. Also I was getting in trouble to get the pipeline working too. Please correct me if i'm wrong.

This allow to do some sort of "retrieval" preprocessing and then using the retrieval with the curated results anywhere you could use a retriever.
My use case is to generate diff indexes with diff embeddings and sources for a more colorful results then filtering them with one or many document formatters.

I saw some people looking for something like this, here:
https://github.com/hwchase17/langchain/issues/3991
and something similar here:
https://github.com/hwchase17/langchain/issues/5555

This is just a proposal I know I'm missing tests , etc. If you think this is a worth it idea I can work on tests and anything you want to change.
Let me know!
Revise DATABRICKS_API_TOKEN as DATABRICKS_TOKEN

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

In the [Databricks integration](https://python.langchain.com/en/latest/integrations/databricks.html) and [Databricks LLM](https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html), we suggestted users to set the ENV variable `DATABRICKS_API_TOKEN`. 
However, this is inconsistent with the other Databricks library. To make it consistent, this PR changes the variable from `DATABRICKS_API_TOKEN` to `DATABRICKS_TOKEN`

After changes, there is no more `DATABRICKS_API_TOKEN` in the doc
```
$ git grep DATABRICKS_API_TOKEN|wc -l
0

$ git grep DATABRICKS_TOKEN|wc -l
8
```
cc @hwchase17 @dev2049 @mengxr since you have reviewed the previous PRs.