delayedkarma/langchain-issues huggingface dataset:
KeyError: 'content' using `AzureCognitiveSearchRetreiver`

### System Info

langchain=0.0.199
Python=3.9.13

### Who Can Help

@eyurtsev
@hwchase17

### 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
- [x] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```
import os

from langchain.retrievers import AzureCognitiveSearchRetriever

cognitive_search_name = os.environ["AZURE_COGNITIVE_SEARCH_SERVICE_NAME"]
vector_store_address: str = f"https://{cognitive_search_name}.search.windows.net/"
index_name: str = os.environ["AZURE_COGNITIVE_SEARCH_INDEX_NAME"]
vector_store_password: str = os.environ["AZURE_COGNITIVE_SEARCH_API_KEY"]

retriever = AzureCognitiveSearchRetriever(content_key="content")
retriever.get_relevant_documents("what is langchain")
```

### Expected behavior

I am attempting to use `AzureCognitiveSearchRetriever` to no avail. There is little guidance or documentation that I could find to make this functionality work. I don't know what value I'm supposed to set the parameter `content_key` to in order to make this work.

My overall goal is to retrieve data from Azure Cognitive Search and use it to determine the output served by the chatbot based on user query.

Thanks!
Fixed PermissionError on windows

Fixed PermissionError that occurred when downloading PDF files via http in BasePDFLoader on windows.

When downloading PDF files via http in BasePDFLoader, NamedTemporaryFile is used.
This function cannot open the file again on **Windows**.[Python Doc](https://docs.python.org/3.9/library/tempfile.html#tempfile.NamedTemporaryFile)

So, we created a **temporary directory** with TemporaryDirectory and placed the downloaded file there.
temporary directory is deleted in the deconstruct.

Fixes #2698

#### Who can review?

Tag maintainers/contributors who might be interested:

  - @eyurtsev
  - @hwchase17
TypeError: FAISS.similarity_search_with_score_by_vector() got an unexpected keyword argument 'score_threshold'

### System Info

LnagChain v0.0.200

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

1. Create `FAISS` vectorstore
2. Call `as_retriever(search_type='similarity_score_threshold', k=4, search_kwargs={'score_threshold': 0.6})`


### Expected behavior

To not raise error
NameError: Name pd not found with PythonRepl

### System Info

langchain version = 0.0.198

while using the lagchain create_pandas_dataframe_agent,
it was able to generate the correct intermediate command, 
but when it came to execute it, it says pd is not defined.
its not able to detect that pandas is to imported as pd

i am using AzureOpenAI service with gpt-3.5-turbo model

anyone who can help me on this

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

Same code run

### Expected behavior

in intermediate step, it will say pd is not defined.
feature: token based text splitter relative chunk overlap argument
Labels: name: auto:improvement

For SentenceTransformersTokenTextSplitter text splitter.

Adds a new parameter `relative_chunk_overlap` for the `SentenceTransformersTokenTextSplitter` constructor. The parameter sets the chunk overlap using a relative factor, e.g. for a model where the token limit is 100, a `relative_chunk_overlap=0.5` implies that `chunk_overlap=50`.

#### Who can review?

@hwchase17 @dev2049
Retrieval Question/Answering Example not working in 0.0.200

### System Info

**The problem seem to be in below code:**

exception: dict is not iterable 

Working version: langchain==0.0.164

usecase : https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html

Issue in below method:

```
def dict(self, **kwargs: Any) -> Dict:
    """Return a dictionary of the LLM."""
    starter_dict = dict(self._identifying_params)
    starter_dict["_type"] = self._llm_type
    return starter_dict

```

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

https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html

Try these steps

### Expected behavior

It should work as per the example.
Fix error in aim callback when tracking of chains.
Labels: name: auto:bug

The aim callback is trying to track the keys "input" and "output" (hard coded) when tracking a chain. This causes the exceptions 
```
Error in on_chain_start callback: 'input'
Error in on_chain_end callback: 'output'
```
to be thrown.

I fixed the error by tracking all key, value pairs from the inputs resp. outputs variables.

Furthermore, the following issue is also fixed:
Fixes # 5107


Tag maintainers/contributors who might be interested:

Tracing / Callbacks
  - @agola11
VectorStore Typesense refactored example code and modified k value
Labels: name: lgtm

Changes done.
1. Example code in Typesense Class provided input embedding as `embedding=embedding.embed_query` which throws an error as `AttributeError: 'function' object has no attribute 'embed_query'`.
2. modified k values in vector similarity as Typesense by default returns 10 results. So providing k =4 by default would make users think about why the results are returned 10 instead of 4.


#### Who can review?

@jasonbosco @hwchase17 
 @dev2049
OpenAICallbackHandler is not updating values when used in ConversationalRetrievalChain

### System Info

langchain : 0.0.197
docker python alpine image : 3.11.3

ConversationalRetrievalChain works perfectly and i get awesome output. at the same time i also need to track my usage on openai api call.

Im setting the qa object as below
```
qa = ConversationalRetrievalChain.from_llm(
        model,
        retriever=retriever,
        verbose=True,
        # callback in not updating the cost
        callbacks=[OpenAICallbackHandler()]
    )
```

I see the callback is printing the all openai info on console, which means callback is getting triggered.
But I always see all values to Zero.

### Who can help?

@ag

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [X] Callbacks/Tracing
- [ ] Async

### Reproduction

1. Create qa object as show in disciption with callback.
2. Pass the question chat history  to qa object 

### Expected behavior

Callback show update all the values for openai traceback
Impossible to connect PowerBI Dataset Agent to Azure services

### System Info

Hi, 
I'm trying to reproduce this example https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html

When i launch this part of the code : 
toolkit = PowerBIToolkit(
    powerbi=PowerBIDataset.update_forward_refs(dataset_id=dataset-id, table_names=['Tables'], credential=DefaultAzureCredential()), 
    llm=smart_llm
)

I have this error : NameError: name 'TokenCredential' is not defined

What am I doing wrong ? Do i have to specify things with Azure credentials first ? 
Thanks for your help

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

### Reproduction

example here : https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html

I just modified powerbi=PowerBIDataset() to powerbi=PowerBIDataset.update_forward_refs() because of an error i had. 

### Expected behavior

Connect the agent to powerbi rest API
Add docs for tags

<!--
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

 -->
Add Alibaba Cloud OpenSearch as a new vector store

Hello Folks,

Thanks for creating and maintaining this great project. I'm excited to submit this PR to add Alibaba Cloud OpenSearch as a new vector store.

OpenSearch is a one-stop platform to develop intelligent search services. OpenSearch was built based on the large-scale distributed search engine developed by Alibaba. OpenSearch serves more than 500 business cases in Alibaba Group and thousands of Alibaba Cloud customers. OpenSearch helps develop search services in different search scenarios, including e-commerce, O2O, multimedia, the content industry, communities and forums, and big data query in enterprises.

OpenSearch provides the vector search feature. In specific scenarios, especially test question search and image search scenarios, you can use the vector search feature together with the multimodal search feature to improve the accuracy of search results.


This PR includes:

A AlibabaCloudOpenSearch class that can connect to the Alibaba Cloud OpenSearch instance.
add embedings and metadata into a opensearch datasource.
querying by squared euclidean and metadata.
integration tests.
ipython notebook and docs.

I have read your contributing guidelines. And I have passed the tests below

- [x]  make format
- [x]  make lint
- [x]  make coverage
- [x]  make test
langchain rephrased the human input to a completely different meaning in the prompts

### System Info

Recently, we do a few test on the ConversationalRetrievalChain + Memory, and notice that, the customer's question is rephrased by Langchain to a totally different meaning. Anyone knows how to avoid this?

The conversation is to introduce the different package of a mobile plan to the customer. and Customer inputs: **Hi**. However, while it comes to Langchain, this sentence is rephrased to: **What is your estimated monthly usage for data, talktime, and SMS?**

**Code:** 

qa = ConversationalRetrievalChain.from_llm(
            llm=self.llm, retriever=retriever, combine_docs_chain_kwargs={'prompt': self.QA_PROMPT}, verbose=True)    
result = qa({'question': question, 'chat_history': message_history.messages})

**Debugging infö as below:** 

Prompt after formatting:
Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.

Chat History:

Human: I would like to have a data plan
Assistant: Sure, we have several data plans available. Can you please let me know your estimated monthly usage for data, talktime, and SMS? This will help me recommend the most suitable plan for you.
Follow Up Input: hi
Standalone question:

> Finished chain.

Human: I would like to have a data plan
Assistant: Sure, we have several data plans available. Can you please let me know your estimated monthly usage for data, talktime, and SMS? This will help me recommend the most suitable plan for you.
        
Human: What is your estimated monthly usage for data, talktime, and SMS?

### 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
- [ ] Vector Stores / Retrievers
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Create a context of the conversation, and send some subjective sentence. 

### Expected behavior

Langchain rephrase it to a question.
Tracking total cost for gpt-3.5-turbo-0613 yields $0.0

### System Info

Langchain version: 0.0.200

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

### Reproduction

Steps to reproduce:

1. Create a ConversationChain instance with parameters:
```
llm = ChatOpenAI(model_name="gpt-3.5-turbo-0613", temperature=0)
memory = ConversationBufferMemory()
```
2. Run the chain inside callback block:
```
    with get_openai_callback() as cb:
            response = conversation.run("Tell me a joke")
            print(cb)
```
3. Total Cost is always $0.0.
<img width="767" alt="Screenshot 2023-06-14 at 11 31 21" src="https://github.com/hwchase17/langchain/assets/18078190/e7992bcb-f288-462f-ab2c-94d0d894929f">


### Expected behavior

Total cost of the conversation chain usage is reflected in the Total Cost parameter of the callback and represents accurate usage costs.
Removed handling for non-existent error in chromadb library
Labels: name: lgtm

The current version of chromadb handle the case of `n_result` is greater than the total number of elements in the collection. [chromadb PR](https://github.com/chroma-core/chroma/issues/301). So removed `NotEnoughElementException` that doesn't exists now.

#### Who can review?

Tag maintainers/contributors who might be interested:

- @hwchase17
- @dev2049
create_csv_agent incomplete response

### System Info

when  > Finished chain.
output:  [article]  but not complete, it still has something to write. 

how can I make article completely?


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

### Reproduction

`from langchain.agents import create_csv_agent
from langchain.llms import OpenAI
import os
os.environ["OPENAI_API_KEY"] = 'mykey'
#llm = OpenAI(model_name="gpt-3.5-turbo-0613")

agent = create_csv_agent(OpenAI(temperature=0,batch_size=5), ['csv/a.csv', 'csv/b.csv'], verbose=True)
a = agent.run("Help me analyze customer consumption and generate an article")
print(a)`

### Expected behavior

i want output a complete article
ValueError for tutorial about JSONLoader

### System Info

LangChain version: 0.0.200
Platform: Ubuntu 20.04 LTS
Python version: 3.10.4


### 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

1. Reproduce section "Using JSONLoader" for [tutorial](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/json.html) about JSONLoader

2. After executing the following code:
```python
loader = JSONLoader(
    file_path='./example_data/facebook_chat.json',
    jq_schema='.messages[].content'
)

data = loader.load()
```
the following error is displayed:
```ValueError: Expected page_content is string, got <class 'NoneType'> instead.                     Set `text_content=False` if the desired input for                     `page_content` is not a string```

3. If we try to get not the list, but just string:
```python
loader = JSONLoader(
    file_path='./example_data/facebook_chat.json',
    jq_schema='.title'
)

data = loader.load()
```
there are no errors

4. If we set text_content to False in original code:
```python
loader = JSONLoader(
    file_path='./example_data/facebook_chat.json',
    jq_schema='.messages[].content',
    text_content=False
)

data = loader.load()
```
then there are also no errors.

### Expected behavior

- The code and documentation must match each other
- Argument `text_content` must have more clear description in which cases it has to be used
Expanded Self-Query Retriever 👀 and Self-querying with MyScale 🤩

# Expanded Self-Query Retriever 👀 and Self-querying with [MyScale](https://docs.myscale.com/en/) 🤩

LangChain is built with a great interface for self-query retrievers and many super nice contribution has been made during the last few weeks. 🌟 Self-query retrievers are really cool and we believe it will be the future of vector databases! 😎 So we decided to expand self-query retriever with more functions and data types enabled and bring MyScale to the big family of self-query enabled vector databases! 🤗

[MyScale](https://docs.myscale.com/en/) can make use of [various data types and functions for filters](https://blog.myscale.com/2023/06/06/why-integrated-database-solution-can-boost-your-llm-apps/#filter-on-anything-without-constraints). It will boost up your LLM app no matter if you are scaling up your data or expand your system to broader application. 🚀🚀🚀 And we believe it will be a common feature to every vector database in the future!

In the notebook we'll demo the `SelfQueryRetriever` wrapped around a MyScale vector store with some extra piece we contributed to LangChain. In short, it can be concluded into 4 points:

1. Add `contain` comparator 🪣 to match list of any if there is more than one element matched
2. Add `timestamp` data type 🕰️ for date time match (ISO-format, or YYYY-MM-DD)
3. Add `like` comparator 🔎 for string pattern search
4. Add arbitrary function 💣 capability. 

Let's boost LLM apps with vector databases! 🎉🎉🎉
<!--
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 -->

#### 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
-->

- [x] unit-test for `LIKE` and `CONTAIN` 
- [x] Notebook for MyScale Self-query Retriever

#### Who can review?

Tag maintainers/contributors who might be interested:

- @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
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->