delayedkarma/langchain-issues huggingface dataset:
Chroma, Deeplake, Faiss indexing error ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10379,) + inhomogeneous part.
Labels: name: auto:bug

### System Info

langchain Version: 0.0.220
python 3.9.16 
Windows 11/ ubuntu 22.04
anaconda


### Who can help?

@agola11 When ingesting the attched file (I'm attaching a zip as .pkl cannot be updated) in a normal document splitting loop
```python
embeddings = OpenAIEmbeddings()
chunk_sizes = [512, 1024, 1536]
overlap= 100
docs_n_code = "both"
split_documents = []
base_dir ="..."

for chunk_size in chunk_sizes:
    
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=overlap)
    docs = text_splitter.split_documents(documents)
    faiss_dir = "..."
    faiss_vectorstore = FAISS.from_documents(docs, embeddings)
    faiss_vectorstore.save_local(faiss_dir)
```
I get the following error:
```
setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10379,) + inhomogeneous part.
```
similar errors occur with chroma and deeplake, locally. With chroma i can get the error more frequently even when ingesting other documents.
[api_docs.zip](https://github.com/hwchase17/langchain/files/11930126/api_docs.zip)


### Information

- [X] 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
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python

from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import FAISS
from langchain.document_loaders import TextLoader

from langchain.document_loaders import TextLoader

with open('api_docs.pkl', 'rb') as file:
    documents = pickle.load(file)


text_splitter = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=100)
docs = text_splitter.split_documents(documents)

embeddings = OpenAIEmbeddings()

db = FAISS.from_documents(docs, embeddings)
```

### Expected behavior

Create the index
Fix for KeyError in MlflowCallbackHandler 
Labels: name: lgtm, name: auto:improvement

  - Description: `MlflowCallbackHandler` fails with `KeyError: "['name'] not in index"`. See https://github.com/hwchase17/langchain/issues/5770 for more details. Root cause is that LangChain does not pass "name" as a part of `serialized` argument to `on_llm_start()` callback method. The commit where this change was made is probably this: https://github.com/hwchase17/langchain/commit/18af149e91e62b3ac7728ddea420688d41043734. My bug fix derives "name" from "id" field.
  - Issue: https://github.com/hwchase17/langchain/issues/5770
  - Dependencies: None
  - Tag maintainer: @agola11
Fix error when save chain to file and reload(#6889)
Labels: name: auto:bug

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Fix error when save chain to file and reload, 
  - Issue: SQLDatabaseChain cannot be loaded(#6889),
  - Dependencies: none,
  - Tag maintainer: @dev2049 ,
  - 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
 -->
Fixed Office365 tool __init__.py files, tests, and get_tools() function
Labels: name: auto:improvement

## Description
Added Office365 tool modules to `__init__.py` files
## Issue
As described in Issue https://github.com/hwchase17/langchain/issues/6936, the Office365 toolkit can't be loaded easily because it is not included in the `__init__.py` files.
## Reviewer
@dev2049
Chain support missing variable
Labels: name: auto:improvement

### Feature request

The LLM chain strictly validates all input variables against placeholders in the template. It will throw an error if they don't match. I wish it could handle missing variables, thus making the prompt template more flexible.

```python
  def _validate_inputs(self, inputs: Dict[str, Any]) -> None:
        """Check that all inputs are present."""
        missing_keys = set(self.input_keys).difference(inputs)
        if missing_keys:
            raise ValueError(f"Missing some input keys: {missing_keys}")
```

### Motivation

I'm using jinja2 to build a generic prompt template, but the chain's enforcement on variable validation forces me to take some extra steps, such as pre-rendering the prompt before running it through the chain. 

I hope the official could support the handling of missing variables.

### Your contribution

I think I could add a variable to determine whether to check the consistency between input variables and template variables, and then submit a PR. 

if you have better ideas, such as complex and complete solutions like custom detection rule callback functions.

I look forward to the official update. Please, I really need this, and I believe others do too. 

This will make the design of the Prompt more flexible.
Map_reduce not adapted to the 16k model 😲😥
Labels: name: auto:improvement

### System Info

LangChain==0.0.177
Python==3.10

### Who can help?

_No response_

### Information

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

### Reproduction

When using the **map_reduce** technique with a **GPT 16k** model, you receive an error message: '**A single document was longer than the context length, we cannot handle this.'** I believe this is due to the token_max limit mentioned in the following context. Is it possible to address this issue? It no longer makes sense to use a 16k model if we cannot send documents exceeding the hardcoded limit of 3000 tokens. _Could you please modify this hardcoded value from the 4098 token models to accommodate the 16k models?_ Thank you.

<img width="1260" alt="Capture d’écran 2023-07-02 à 13 26 21" src="https://github.com/hwchase17/langchain/assets/20300624/5f09b7e6-0a7a-49ec-9585-a20524332682">


### Expected behavior

I would like be able to give a Document object that would be more than 3000 tokens.
ClientSession._request() got an unexpected keyword argument 'verify'
Labels: name: auto:bug

### System Info

PYTHON: 3.11.4
LANGCHAIN: 0.0.220
FLATFORM: WINDOWS

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

**My code:**
```
import nest_asyncio
import gc

nest_asyncio.apply()
from langchain.document_loaders import WebBaseLoader

urls=['','']
loader = WebBaseLoader(urls)
loader.requests_per_second = 1

scrape_data = loader.aload()
```

**ERROR i got:**
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 13
     10 loader = WebBaseLoader(urls)
     11 loader.requests_per_second = 1
---> 13 scrape_data = loader.aload()

File [c:\Program](file:///C:/Program) Files\Python311\Lib\site-packages\langchain\document_loaders\web_base.py:227, in WebBaseLoader.aload(self)
    224 def aload(self) -> List[Document]:
    225     """Load text from the urls in web_path async into Documents."""
--> 227     results = self.scrape_all(self.web_paths)
    228     docs = []
    229     for i in range(len(results)):

File [c:\Program](file:///C:/Program) Files\Python311\Lib\site-packages\langchain\document_loaders\web_base.py:173, in WebBaseLoader.scrape_all(self, urls, parser)
    170 """Fetch all urls, then return soups for all results."""
    171 from bs4 import BeautifulSoup
--> 173 results = asyncio.run(self.fetch_all(urls))
    174 final_results = []
    175 for i, result in enumerate(results):

File [c:\Program](file:///C:/Program) Files\Python311\Lib\site-packages\nest_asyncio.py:35, in _patch_asyncio..run(main, debug)
     33 task = asyncio.ensure_future(main)
     34 try:
---> 35     return loop.run_until_complete(task)
...
    921     return _RequestContextManager(
--> 922         self._request(hdrs.METH_GET, url, allow_redirects=allow_redirects, **kwargs)
    923     )

TypeError: ClientSession._request() got an unexpected keyword argument 'verify'
```

### Expected behavior

_**i want to get web content like basic guide you provide.
I remember I was initially using version 0.0.20, and it worked fine. 
But today, after updating to the latest version: 0.0.220, it got this error**_
Issue: Doubt on STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION
Labels: name: auto:bug, name: auto:question

### Issue you'd like to raise.

Can we reuse intermediate steps for an agent defined using STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION?

This is my definition:
```
agent_executor = initialize_agent(
    tools,
    llm,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
    return_intermediate_steps=True,
    agent_kwargs={
        "prefix": PREFIX,
        "suffix": SUFFIX,
        "input_variables": [
            "input",
            "agent_scratchpad",
            "intermediate_steps",
            "tools",
            "tool_names",
        ],
        "stop": ["\nObservation:"],
    },
)
```

But I'm getting this error:
```
Got mismatched input_variables. Expected: {'tools', 'agent_scratchpad', 'input', 'tool_names'}. Got: ['input', 'agent_scratchpad', 'intermediate_steps', 'tools', 'tool_names'] (type=value_error)
```

### Suggestion:

_No response_
Agent for MongoDB
Labels: name: auto:enhancement

### Feature request

I was skimming through the repository for the MongoDB Agent and I discovered that it does not exist. Is it feasible to develop a MongoDB agent that establishes a connection with MongoDB, generates MongoDB queries based on given questions, and retrieves the corresponding data?

### Motivation

Within my organization, a significant portion of our data is stored in MongoDB. I intend to utilize this agent to establish connections with our databases and develop a practical application around it.

### Your contribution

If it is indeed possible, I am willing to work on implementing this feature. However, I would greatly appreciate some initial guidance or assistance from someone knowledgeable in this area.
SelfQueryRetriever not working in async call
Labels: name: auto:bug

### Issue you'd like to raise.

I want to chain the ```SelfQueryRetriever``` with ```ConversationalRetrievalChain``` and stream the output. I tested it in synchronous function it's working. However, when I convert it to async function, it pauses there and the execution never ended, no output as well. I went through the source code and found that ```aget_relevant_documents()``` for ```SelfQueryRetriever``` is not implemented.

```python
async def aget_relevant_documents(self, query: str) -> List[Document]:
        raise NotImplementedError
```

Not sure whether the issue came from this, because I am using ```acall()``` for ```ConversationalRetrievalChain```. But I do not receive any error message from the execution. Any temporary workaround for me to use ```SelfQueryRetriever``` in async function or I should wait for the release?

### Suggestion:

_No response_
Loading online PDFs gives temporary file path as source in metadata
Labels: name: auto:improvement

Hi, 

first up, thank you for making langchain! I was playing around a little and found a minor issue with loading online PDFs, and would like to start contributing to langchain maybe by fixing this.

### System Info

langchain 0.0.220, google collab, python 3.10

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction


```python
from langchain.document_loaders import PyMuPDFLoader

loader = PyMuPDFLoader('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf')
pages = loader.load()

pages[0].metadata
```

<img width="977" alt="image" src="https://github.com/hwchase17/langchain/assets/21276922/4ededc60-bb03-4502-a8c8-3c221ab109c4">


### Expected behavior

Instead of giving the temporary file path, which is not useful and deleted shortly after, it could be more helpful if the source is set to be the URL passed to it. This would require some fixes in the `langchain/document_loaders/pdf.py` file.
Self hosted llm api
Labels: name: auto:enhancement

Description: An additional LLM subclass called SelfHostedApi. This subclass was designed to be used by developers using self-hosted LLMs in a VPS environment, but who have exposed the model's functionality to an API endpoint. The goal is to allow more flexibility and performance for those using a single llm for varying inference tasks.

Unit tests added (all tests use mocked services)
In-code documentation added
Linting in progress (would love some help from someone more familiar with it. I've never done it before)
No demo in docs/modules (didn't see that explicit path in the repo). Point me to the correct directory and I'll do it.

Issue: N/A
Dependencies: Requests
Maintainer: @hwchase17 

Thank y'all for making this package!
Fix docs
Labels: name: auto:nit

<!-- 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
 -->
Probabilistic Language of Thought (PLoT) Agent Implementation
Labels: name: auto:enhancement

### Feature request

## Summary
Implement a new type of Langchain agent that reasons using a PLoT architecture as described in this paper:

https://arxiv.org/abs/2306.12672

## Notes
* Such an agent would need to use a probabilistic programming language (the paper above used Church) to generate code that describes its world model. This means that it would only work for LLMs that can generate code, and it would also need access to a Church interpreter (if that is the language that is chosen)

### Motivation

An agent which uses probabilistic language of thought to construct a coherent world model would be better at reasoning tasks involving uncertainty and ambiguity. Basically, it would think more like a human, using an understanding of the world that is external to the weights & biases on which it was trained. 


### Your contribution

I've already started work on this and I intend to submit a PR when I have time to finish it! I'm pretty busy so any help would be appreciated! Feel free to reach out on discord @jasondotparse or twitter https://twitter.com/jasondotparse if you are down to help!
Fixes incorrect docstore creation in faiss.py
Labels: name: auto:bug

  - **Description**: Current implementation assumes that the length of `texts` and `ids` should be same but if the passed `ids` length is not equal to the passed length of `texts`, current code `dict(zip(index_to_id.values(), documents))` is not failing or giving any warning and silently creating docstores only for the passed `ids` i.e. if `ids = ['A']` and `texts=["I love Open Source","I love langchain"]` then only one `docstore` will be created. But either two docstores should be created assuming same id value for all the elements of `texts` or an error should be raised.
  
  - **Issue**: My change fixes this by using dictionary comprehension instead of `zip`. This was if lengths of `ids` and `texts` mismatches an explicit `IndexError` will be raised.
  
@rlancemartin, @eyurtsev
OutputParserException: Could not parse LLM output: `df = [] for i in range(len(df)):`
Labels: name: auto:bug

### System Info

OutputParserException: Could not parse LLM output: `df = [] for i in range(len(df)):`

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

I used open source LLM, HuggingFaceHub(repo_id = "google/flan-t5-xxl"), but not OpenAI LLM, to create agent below: 

agent = create_csv_agent using HuggingFaceHub(repo_id = "google/flan-t5-xxl"), r"D:\ML\titanic\titanic.csv", verbose=True)
the agent created successfully:

but when I used the agent below, I got error above:

agent.run("Plot a bar chart comparing Survived vs Dead for Embarked")
agent.run("Find the count of missing values in each column")
agent.run("Fix the issues with missing values for column Embarked with mode")
agent.run("Drop cabin column")




### Expected behavior

I should get plot or other .
Rename Databerry to Chaindesk
Labels: name: lgtm, name: auto:refactor, name: auto:documentation

<!-- 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
 -->
fix(pipeline prompt): support  PipelinePrompt format missing varable
Labels: name: auto:bug

Replace this comment with:
  - Description: fixed the bug where PipelinePromptTemplate throws an error when input variable is missing, 
  - Issue: the issue #7016 it fixes (if applicable),
  - Dependencies: none
  - Tag maintainer: @dev2049
  - Twitter handle: 
<!-- 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
 -->