delayedkarma/langchain-issues huggingface dataset:
Added deeplake use case examples of the new features

<!--
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
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
 
 1. Added use cases of the new features
 2. Done some code refactoring
Wrong implementation of score_threshold in Faiss vectorstore

### System Info

Langchain Version: 0.0.207

### Who can help?

@hwchase17 

Hi, I am now having a deep dive into the vectorstores and found a wrong implementation in faiss.

The relevant file is as below:
https://github.com/hwchase17/langchain/blob/master/langchain/vectorstores/faiss.py#L210

In the similarity_search, the score returned from index is either L2 or inner production, basically the smaller the score is, the more similar. But when the score_threshold is passed to the method, it filters the search result by **similarity >= score_threshold**. 

I think the correct implementation is to change the code to
**similarity <= score_threshold** 
or 
**self.relevance_score_fn(score) >= score_threshold**



### Information

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

### Related Components

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

### Reproduction

None

### Expected behavior

None
sitemap loader : got an unexpected keyword argument 'verify'

### System Info

langchain-0.0.207, osx, python 3.11

Hi @eyurtsev

I am using this example from the docs
and get the error below .
Any idea ? im kind of stuck.

Seems to work with version 202 - everything above seems broken

`TypeError: ClientSession._request() got an unexpected keyword argument 'verify'
`


```
from langchain.document_loaders.sitemap import SitemapLoader
sitemap_loader = SitemapLoader(web_path="https://langchain.readthedocs.io/sitemap.xml")

docs = sitemap_loader.load()

sitemap_loader.requests_per_second = 2
# Optional: avoid `[SSL: CERTIFICATE_VERIFY_FAILED]` issue
sitemap_loader.requests_kwargs = {"verify": True}
```

### 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
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

run code mentioned above

### Expected behavior

the sitemap loader should return a list of documents
Wrong number of closing curly brackets in Pydantic Format Instructions

https://github.com/hwchase17/langchain/blob/0fce8ef178eed2a5f898f65c17179c0a01275745/langchain/output_parsers/format_instructions.py#L13

There are too many closing curly braces here: `"required": ["foo"]}}}}`.

It should only be the following: `"required": ["foo"]}}`

Happy to open a PR if agreed to fix.
docs: update `youtube` videos and tutorials

added tutorials.mdx; updated youtube.mdx

Rationale: the Tutorials section in the documentation is top-priority. (for example, https://pytorch.org/docs/stable/index.html) Not every project has resources to make tutorials. We have such a privilege. Community experts created several tutorials on YouTube. But the tutorial links are now hidden on the YouTube page and not easily discovered by first-time visitors.

- Added new videos and tutorials that were created since the last update.
- Made some reprioritization between videos on the base of the view numbers.

#### Who can review?

  - @hwchase17
    - @dev2049
Why there is no daily plan in Generative Agent? This is an important part in the party.

### Feature request

Add: 
Daily plan in Generative Agent.
Plan details in Generative Agent.
Update plan when interaction with others.

### Motivation

The planing is a very important part in Generative Agent.
Without plan the agent is not normal 'human'.

### Your contribution

I'm still read the code. 
Maybe I'll be helpful in later.
Issue: How to return a stream in api

### Issue you'd like to raise.

So, I've tried to create a custom callback and try to return a stream but got no luck:


```python
class MyCallbackHandler(BaseCallbackHandler):
    def on_llm_new_token(self, token, **kwargs) -> None:
        # print every token on a new line
        yield token

llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-0301", openai_api_key="openai_api_key", streaming=True, callbacks=[MyCallbackHandler()])

@app.route('/api/chatbot', methods=['GET', 'POST'])
@token_required
def chatbot(**kwargs) -> str:
    # rest of code
    tools = toolkit.get_tools()
    agent_chain = initialize_agent(tools=tools, llm=llm, agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION, 
                                   memory=memory, verbose=True)
    response = agent_chain.run(input=input_text)

    return app.response_class(response)
```

### Suggestion:

I am thinking of return the on_llm_new_token as a stream from the custom callback, but I get no idea of doing that. How to return a stream, pls give me a solution!
Vectara upd2
Labels: name: area: vector store

Update to Vectara integration 
- By user request added "add_files" to take advantage of Vectara capabilities to process files on the backend, without the need for separate loading of documents and chunking in the chain.
- Updated vectara.ipynb example notebook to be broader and added testing of add_file()
 
  @hwchase17 - project lead
A simpler wrapper of Open AI Functions else than in an Agent

### Feature request

The Open AI Functions feature is uesful not only in an Agent. 
I wonder if LangChain can provide a simpler wrapper for Functions feature, for example, in the ChatOpenAI Class.

### Motivation

Creating and defining an Agent is redundant if I only want to use Open AI Functions for a single call, or sequential calls in a Chain.

### Your contribution

I can work on this if this is really demanded.
Issue: langchain implementation where asynchronous tools don't break the chain

I implemented langchain as a Python API, created via FASTAPI and uvicorn. 

The Python API is composed of one main service and various microservices the main service call when required. These microservices are tools. I use 3 tools: web search, image generation, image description. All are long running tasks. 

The microservices need to be called as a chain. I.e. the output of one microservice can be used as the input to another microservice (who's output is then returned, or used as an input to another tool, as required).

Now I have made each microservice asynchronous. As in, they do the heavy lifting in a background thread, managed via Celery+Redis.  

This set up breaks the chain. Why? Because the first async microservice immediately returns a `task_id` (to track the background work) when it is run via Celery. This output (the `task_id`) is passed as input to the next microservice. But this input is essentially meaningless to the second microservice. It's like giving a chef a shopping receipt and expecting them to cook a meal with it.

The next microservice required the actual output from the first one to do its job, but it's got the `task_id` instead, which doesn't hold any meaningful information for it to work with. 

This makes the chain return garbage output ultimately. So in that sense, the chain "breaks".

How else could I have implemented my langchain execution to ensure concurrency and parallelism? Please provide an illustrative example. 

### Suggestion:

_No response_
Add PandocRSTLoader
Labels: name: enhancement, name: lgtm, name: area: doc loader

Note: I accidentally deleted the branch so the original request was automatically closed. Won't make that mistake again haha.

A loader that loads a .rst (reStructuredText) file, converts it into a markdown format and wraps it into a Document instance using the lazy-loading method.

It requires pypandoc

@eyurtsev @hwchase17
Documentation Fix: Correct the example code output in the prompt templates doc
Labels: name: lgtm

Documentation is showing the wrong example output for the prompt templates code snippet. This PR fixes that issue. 

<img width="933" alt="image" src="https://github.com/hwchase17/langchain/assets/3833303/0e31c965-5883-4ff9-9cf8-0c4e32ca2d00">
Feat: Add a prompt template parameter to qa with structure chains
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!
-->

## Description of Changes
This pull request introduces a new feature to the LangChain QA Retrieval Chains with Structures. The change involves adding a prompt template as an optional parameter for the RetrievalQA chains that utilize the recently implemented OpenAI Functions.

The main purpose of this enhancement is to provide users with the ability to input a more customizable prompt to the chain. By introducing a prompt template as an optional parameter, users can tailor the prompt to their specific needs and context, thereby improving the flexibility and effectiveness of the RetrievalQA chains.

## Changes Made
- Created a new optional parameter, "prompt", for the RetrievalQA with structure chains.
- Added an example to the RetrievalQA with sources notebook.

My twitter handle is @El_Rey_Zero
Scale cosine distance to 0-1
Labels: name: bug

Fix - "_similarity_search_with_relevance_scores" is called by VectorStore base class and should return relevance score between 0 and 1, not the distance.

<!--
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 #6481 

#### 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
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Added AzureML Endpoint Integration for Azure Foundation Models
Labels: name: enhancement, name: llms

<!--
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!
-->

### 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)

<!-- Remove if not applicable -->

#### Who can review?

Tag maintainers/contributors who might be interested:
  - @hwchase17
  - @agola11
DOC: Youtube tutorial link is not working at introduction section in documentation

### Issue with current documentation:

Hello there,

**Youtube Tutorial** link given [here](https://python.langchain.com/docs/get_started/introduction#additional-resources) is not working as per expectation.
[look here](https://python.langchain.com/docs/ecosystem/youtube.html)




### Idea or request for content:

It should be mapped with [this](https://python.langchain.com/docs/additional_resources/youtube)
Add example for chatting with multiple documents by referencing their IDs in a DB
Labels: name: area: agent, name: auto:documentation

An example of chatting with multiple docs with reference to their IDs in a DB. Here's an example:
```
How are @doc:bw456 and @doc:cg789 different in their main ideas on learning?
```

This example uses the [Self Querying Retriever](https://python.langchain.com/docs/modules/data_connection/retrievers/how_to/self_query/) with a `RetrieverQAWithSourcesChain` to create a tool that answers questions on a single doc.

The `STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION` agent uses this tool to create actions for each doc and then answers the user's query.

My Twitter handle 😬: [27upon2](https://twitter.com/27upon2)

#### Who can review?
 @hwchase17
feat (documents): add a source code loader based on AST manipulation
Labels: name: enhancement, name: area: doc loader

#### Summary

A new approach to loading source code is implemented:

Each top-level function and class in the code is loaded into separate documents. Then, an additional document is created with the top-level code, but without the already loaded functions and classes.

This could improve the accuracy of QA chains over source code.

For instance, having this script:

```
class MyClass:
    def __init__(self, name):
        self.name = name

    def greet(self):
        print(f"Hello, {self.name}!")

def main():
    name = input("Enter your name: ")
    obj = MyClass(name)
    obj.greet()

if __name__ == '__main__':
    main()
```

The loader will create three documents with this content:

First document:
```
class MyClass:
    def __init__(self, name):
        self.name = name

    def greet(self):
        print(f"Hello, {self.name}!")
```

Second document:
```
def main():
    name = input("Enter your name: ")
    obj = MyClass(name)
    obj.greet()
```

Third document:
```
# Code for: class MyClass:

# Code for: def main():

if __name__ == '__main__':
    main()
```

A threshold parameter is added to control whether small scripts are split in this way or not.

At this moment, only Python and JavaScript are supported. The appropriate parser is determined by examining the file extension.

#### Tests

This PR adds:

- Unit tests
- Integration tests

#### Dependencies

Only one dependency was added as optional (needed for the JavaScript parser).

#### Documentation

A notebook is added showing how the loader can be used.

#### Who can review?

@eyurtsev @hwchase17
Pinecone add_texts function does not populate vector store as expected, repeats first text in iterable

### System Info

I am running this code on my Mac and on a linux server

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

```python
embeddings = OpenAIEmbeddings()
pinecone.init(
        api_key=PINECONE_API_KEY,
        environment=PINECONE_ENV
)
pineconedb = Pinecone.from_existing_index(index_name, embeddings)
pineconedb.add_texts(
            texts=['Hello', 'my name is Steve', 'I am 20 years old']
)
```

### Expected behavior

Three new entries in the Pinecone vector store: ['Hello', 'my name is Steve', 'I am 20 years old']

Instead, I get three new entires: ['Hello', 'Hello', 'Hello']
DOC: Documentation links for the ClickHouse integration is broken

### Issue with current documentation:

https://t.co/QcsorxSzSG

https://twitter.com/LangChainAI/status/1666093323780767746

The sections in docs where the ClickHouse integration is covered (as a vector db) no longer load properly. The links (above) are broken, and you can no longer navigate to the ClickHouse section from docs directly. 

### Idea or request for content:

_No response_
fix: remove callbacks arg from Tool and StructuredTool inferred schema

Fixes #5456 

This PR removes the `callbacks` argument from a tool's schema when creating a `Tool` or `StructuredTool` with the `from_function` method and `infer_schema` is set to `True`. The `callbacks` argument is now removed in the `create_schema_from_function` and `_get_filtered_args` methods. As suggested by @vowelparrot, this fix provides a straightforward solution that minimally affects the existing implementation.

A test was added to verify that this change enables the expected use of `Tool` and `StructuredTool` when using a `CallbackManager` and inferring the tool's schema.

  - @hwchase17
fix: remove callbacks arg from Tool and StructuredTool inferred schema

Fixes #5456 

This PR removes the `callbacks` argument from a tool's schema when creating a `Tool` or `StructuredTool` with the `from_function` method and `infer_schema` is set to `True`. The `callbacks` argument is now removed in the `create_schema_from_function` and `_get_filtered_args` methods. As suggested by @vowelparrot, this fix provides a straightforward solution that minimally affects the existing implementation.

A test was added to verify that this change enables the expected use of `Tool` and `StructuredTool` when using a `CallbackManager` and inferring the tool's schema.


  - @hwchase17
`get_relevant_documents` of Chroma retriever uses cosine distance instead of cosine similarity as similarity score

### System Info

LangChain version: 0.0.205
Platform: Ubuntu 20.04 LTS
Python version: 3.10.4



### 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
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

**Steps to reproduce**
- Reproduce section in Similarity Score Threshold Retrieval in tutorial [Vector store-backed retriever](https://python.langchain.com/docs/modules/data_connection/retrievers/how_to/vectorstore) with Chroma instead of FAISS as vector store, then we will get incorrect results and get only less relevant documents instead of the most ones.

**Possible reason**
- `db.get_relevant_documents()` [calls](https://github.com/hwchase17/langchain/blob/df40cd233f0690c1fc82d6fc0a1d25afdd7fdd42/langchain/vectorstores/base.py#L393-L398) `db.similarity_search_with_relevance_scores()` for `search_type="similarity_score_threshold"`.

- In `db.similarity_search_with_relevance_scores()` we can see the following [description](https://github.com/hwchase17/langchain/blob/df40cd233f0690c1fc82d6fc0a1d25afdd7fdd42/langchain/vectorstores/base.py#L127-L129):
> Return docs and relevance scores, normalized on a scale from 0 to 1.
> **0 is dissimilar, 1 is most similar.**

- `db.similarity_search_with_relevance_scores()` finally calls `db.similarity_search_with_score()`, which has the following [description](https://github.com/hwchase17/langchain/blob/df40cd233f0690c1fc82d6fc0a1d25afdd7fdd42/langchain/vectorstores/chroma.py#L201-L211C51):
> Run similarity search with Chroma with distance.
> ...
> **Lower score represents more similarity.**

- So when `score_threshold` is [used](https://github.com/hwchase17/langchain/blob/df40cd233f0690c1fc82d6fc0a1d25afdd7fdd42/langchain/vectorstores/base.py#LL155-L159) in `db.similarity_search_with_relevance_scores()`:
``` python
docs_and_similarities = [
    (doc, similarity)
    for doc, similarity in docs_and_similarities
    if similarity >= score_threshold
]
```
Then the filter will retain only the **less** relevant docs, not the most ones, because cosine distance is used as similarity score, which is not correct.

**Related issues**
- #4517
- #6046

### Expected behavior

Cosine similarity instead of cosine distance must be used as similarity score.