delayedkarma/langchain-issues huggingface dataset:
Add back in 
Labels: 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
 -->
redirect vecstores
Labels: 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
 -->
Inconsistent naming of document loaders
Labels: name: auto:question

### Issue you'd like to raise.

Genuinely wanted to know the reasonings behind the inclusion of "Mu" in the "PyMuPDFLoader". Coming from an Indian background my friend and I held 1-2 hours of discussion over what this represents and the conclusions were not so appropriate. 

We landed on this discussion after we noticed the inconsistency in the naming of the single pdf loader (i.e. "PyMuPDFLoader") and the multiple pdf loader (i.e. "PyPDFDirectoryLoader").

(Being a pioneer in LLM Orchestration we admire the open-course revolution. LangChain has opened a wider scope for opensource collaborations and we thank @hwchase17 for it.)

### Suggestion:

_No response_
FewShotPromptTemplate with Chat models
Labels: name: auto:improvement, name: auto:documentation

### Issue with current documentation:

From the [documentation](https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples), it is not clear whether ‘FewShotPromptTemplate’ can be used with Chat models: in particular, it does not appear to be compatible with OpenAI’s suggested best practices (mentioned on the same page) of having alternating “name: example_user” and “name: example_$role” JSON passed to the OpenAI API for each few-shot example message passed in the call. 

### Idea or request for content:

Is it planned to have a separate “ChatFewShotPromptTemplate” class? If so, perhaps a placeholder could be added to the documentation to make this clear. If not, perhaps the documentation could be updated to make the mismatch explicit so that the reader understands the limitations of the current FewShotPromptTemplate in the context of Chat models.
Use an Enum for search type
Labels: name: auto:improvement

<!-- 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
 -->

## Description
Description: Presently, vectorstores and `VectorStoreRetrievers` use strings to identify the search type that should be used. This approach has a few shortcomings:

1. Strings can be easily mistyped, and IDEs are unlikely to let you know.
2. Code completion may be unreliable.
3. IDEs likely won't allow you to easily refactor usage of string literals throughout the code.
4. Users and maintainers must read through various classes to understand what types of searches are supported by the system as a whole
5. If maintainers would like enable new search types within the framework, it may not be obvious how such system-wide changes can be made.
6. Without a clear list of supported search types, "synonyms" may be introduced, making the system inconsistent and increasing the cognitive load on the maintainers and users. For an example, see `RedisVectorStoreRetriever`, which defines a search type of "similarity_limit", which I believe is synonymous with "similarity_score_threshold".

Replacing the use of string literals with an `Enum` solves these problems. It provides stronger typing and (hopefully) a reduced risk of introducing defects into new or existing code. Users and maintainers alike can easily see what the system supports in a single location, and the system is more likely to be self-consistent.

## Tag Maintainer
 @rlancemartin @eyurtsev @hwchase17

## Note
These changes should be fully backwards compatible since the `Enum` also inherits `str`.
Added support for Amazon SageMaker Asynchronous Endpoints
Labels: name: auto:enhancement

## Description
Added support for Amazon SageMaker Asynchronous Endpoints.

## Issue
#6928 

## Dependencies
boto3, uuid

## Maintainer
@hwchase17 

## Twitter handle
DGallitelli95

## Code to test this

```python
from typing import Dict
from langchain import PromptTemplate
from langchain.llms.sagemaker_endpoint import LLMContentHandler, SagemakerAsyncEndpoint
from langchain.chains import LLMChain

# This ContentHandler has been tested with Falcon40B Instruct from SageMaker JumpStart
class ContentHandler(LLMContentHandler):
    content_type:str = "application/json"
    accepts:str = "application/json"
    len_prompt:int = 0

    def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
        self.len_prompt = len(prompt)
        input_str = json.dumps({"inputs": prompt, "parameters": {"max_new_tokens": 100, "do_sample": False, "repetition_penalty": 1.1}})
        return input_str.encode('utf-8')

    def transform_output(self, output: bytes) -> str:
        response_json = output.read()
        res = json.loads(response_json)
        ans = res[0]['generated_text']
        return ans

chain = LLMChain(
    llm=SagemakerAsyncEndpoint(
        input_bucket=bucket,
        input_prefix=prefix,
        endpoint_name=my_model.endpoint_name,
        region_name=sagemaker.Session().boto_region_name,
        content_handler=ContentHandler(),
    ),
    prompt=PromptTemplate(
        input_variables=["query"],
        template="{query}",
    ),
)

print(chain.run("What is the purpose of life?"))
```
Chroma (duckdb+parquet) DB isn't saving the parquet files for persisted DB until application is killed
Labels: name: bug

### System Info

Chroma v0.2.36, python 3.9

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

`
            settings = Settings(
                chroma_db_impl='duckdb+parquet',
                persist_directory="db",
                anonymized_telemetry=False
            )

            pages = self._load_single_document(file_path=file_path)
            docs = text_splitter.split_documents(pages)
            db = Chroma.from_documents(docs, embedding_function, client_settings=settings)
`

### Expected behavior

All files for the database should be created in the db directory. However, the parquet files are not being created when db.from_documents() is called.
However, this is not happening. All the files in the index directory are created at this time.

Later, when the application is killed (flask application, so in between requests the DB is torn down and thus should be persisited), then the parquet files show up.
Missing reference to o365_toolkit module in __init__.py of agent_toolkits
Labels: name: bug

### System Info

Langchain 0.0.218 

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

### Reproduction

![E4D3964C-8891-46EE-879F-D4F862351BC1](https://github.com/hwchase17/langchain/assets/24804373/399a5a2f-0328-4bf9-bc4a-e4f7a856611a)


### Expected behavior

The module should be found automatically.
SageMaker Endpoint - Validations
Labels: name: bug, name: enhancement

### System Info

The SageMaker Endpoint validation function currently throws a missing credential error if the region name is not provided in the input. However, it is crucial to perform input validation for the region name to provide the user with clear error information.

GitHub Issue Reference:
For the code reference related to this issue, please visit: [GitHub Link](https://github.com/hwchase17/langchain/blob/7dcc698ebf4ebf4eb7331d25cec279f402918629472b/langchain/llms/sagemaker_endpoint.py#L177)

### Who can help?

@3coins 

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

### Reproduction

This can be reproduced by creating a SageMaker Endpoing LangChain without specifying region name. Please ensure that you have valid AWS credentials configured.

### Expected behavior

The error message must state

```Region name is missing. Please enter valid region name. E.g: us-west-2.```
General OpenAI Function Mapping from Pydantic, Dicts directly to function, parameters, and properties
Labels: name: enhancement, name: needs documentation

### Feature request

A universal approach to add openai functions specifically for output format control to `LLMchain`. Create a class that takes in dict, json, pydantic, or even rail specs (from guardrails) to preprocess classes or dictionaries into openai functions (function, parameters, and properties) for the `llm_kwargs` in `LLMChain` class in conjunction with the openai function parsers.

### Motivation

It is hard to use the function calling feature right now if you are not working with agents (can access using `format_tool_to_openai_function`) or a specific use case, such as the Extractor or QA chains. The idea is to create a general class that takes in dict, json, pydantic, or even rail specs (from guardrails) to preprocess classes or dictionaries into openai functions for better control of the output format.

### Your contribution

I can help with this, should I put this in the `docs/modules` folder?
Issue: How to handle RouterChain when 1 or more destination chain(s) which is expecting a different input variable?
Labels: name: question

### Issue you'd like to raise.

Would like to ask how we should deal with multiple destination chains where the chains are expecting different input variables? 

For e.g. in the tutorial for MultiPromptChain, i would like math questions to be directed to the PalChain instead of the standard LLMChain.  With the initial LLMRouterChain, the router prompt uses `input` as the input_variables. however, when it has decided that the input `what is 2+2` is a math question and should be routed to PalChain, i am presented the error

```
[/usr/local/lib/python3.10/dist-packages/langchain/chains/base.py](https://localhost:8080/#) in _validate_inputs(self, inputs)
    101         missing_keys = set(self.input_keys).difference(inputs)
    102         if missing_keys:
--> 103             raise ValueError(f"Missing some input keys: {missing_keys}")
    104 
    105     def _validate_outputs(self, outputs: Dict[str, Any]) -> None:

ValueError: Missing some input keys: {'question'}
```

manually replacing the MATH_PROMPT that PalChain uses from {question} to {input} works but I would like to know how I can specify the input variable that the destination chain is expecting when setting up the destination_chains array here:

```
chain = MultiPromptChain(router_chain=router_chain, 
                         destination_chains=destination_chains, 
                         default_chain=default_chain, 
                         verbose=True
                        )
```

been at it for 2 nights so am seeking help. thanks!

### Suggestion:

_No response_
PR-s wait the review forever
Labels: name: needs work

### Issue you'd like to raise.

The PRs wait for review  (for any feedback) very long time.

- Some sort of triage would be helpful.
- Some sort of PR closure can be helpful. If something is wrong with PR this should be explained/discussed/addressed. Not providing **any feedback** is demoralizing for contributors.

Thanks!
PS Take a look at the PR list and check PRs that passed all checks and has no answer/feedback. Hundreds of such PRs?

### Suggestion:

_No response_
Implement AgentExecutorIterator
Labels: name: enhancement, name: area: agent, name: lgtm, name: needs documentation

  - Description: Implements a `.iter()` method for the `AgentExecutor` class. This allows hooking into and intercepting intermediate agent steps.
  - Issue: #6925 
  - Dependencies: None
  - Tag maintainer: @vowelparrot @agola11 
  - Twitter handle: @SlapDron3 @lacicocodes
Support for Amazon SageMaker Asynchronous Endpoints
Labels: name: enhancement, name: needs work, name: stale

### Feature request

Please add support to invoke [Amazon SageMaker Asynchronous Endpoints](https://docs.aws.amazon.com/sagemaker/latest/dg/async-inference.html). 

This would require some code changes to the _call method of the SageMaker Endpoint class. Therefore, there is a need to create a new class, called SagemakerAsyncEndpoint, or introduce a logic in the SagemakerEndpoint class to check whether the endpoint is async or not.

### Motivation

They are a great way to have models running on expensive GPU instances, while keeping cost control especially during POC phase.

### Your contribution

Submitting a PR.
integrate JinaChat
Labels: name: enhancement, name: llms, name: lgtm

Integration with https://chat.jina.ai/api. It is OpenAI compatible API.

- Twitter handle: [https://twitter.com/JinaAI_](https://twitter.com/JinaAI_)

cc @hwchase17, @baskaryan

<!-- 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
 -->
Iterator version of AgentExecutor
Labels: name: enhancement, name: needs work

### Feature request

A colleague and I would like to implement an iterator version of the AgentExecutor. That is, we'd like to expose each intermediate step of the plan/action/observation loop. This should look something like:

```python3
inputs = ... # complex question that requires tool usage, multi-step

for step in agent_executor.iter(inputs=inputs):
    do_stuff_with(step)
```

### Motivation

This would be useful for a few applications. By hooking into agent steps we could:

- Route different thoughts/actions/observations conditionally to:
    - different frontend components 
    - different postprocessing/analysis logic
    - other agents

We could also "pause" agent execution and intervene.

### Your contribution

Yes, we have a PR ~ready.
Support BingNewsApiWrapper on utilities
Labels: name: enhancement, name: needs work

### Feature request

Hello, I'd like to ask about supporting [BingNewsAPI](https://www.microsoft.com/en-us/bing/apis/bing-news-search-api), which the apis and response format is different from bing web search api, that I cannot utilize existing [BingSearchAPIWrapper](https://python.langchain.com/docs/modules/agents/tools/integrations/bing_search) result or run method.
I know that you provide separating host url in existing BingSearchWrapper, but as the response format is different, there is an parsing error on calling result method.

### Motivation

I cannot utilize existing [BingSearchAPIWrapper](https://python.langchain.com/docs/modules/agents/tools/integrations/bing_search) s result or run method on [BingNewsAPI](https://www.microsoft.com/en-us/bing/apis/bing-news-search-api)

### Your contribution

If you allow me, I'd like to create pr for BingNewsSearchAPIWrapper utilities.
Structured Agent Search Not Working
Labels: name: bug

### System Info

Trying to get an agent to describe the contents of a particular URL for me, however, **my agent does not execute past first step**. Attached image to show what my code looks like and where it freezes as it runs.

<img width="683" alt="freezing_agent" src="https://github.com/hwchase17/langchain/assets/97087128/b3888b6e-f016-479e-ac1a-3036b7f16d97">

Thanks <3 !

(also posted as discussion, was not sure where to add)

### Who can help?

@agola11 

### 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

from config import SERPAPI_API_KEY, OPENAI_API_KEY
from langchain.agents import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent
from langchain.agents.agent_toolkits import PlayWrightBrowserToolkit
from langchain.tools.playwright.utils import create_async_playwright_browser
import asyncio

async_browser = create_async_playwright_browser()
browser_toolkit = PlayWrightBrowserToolkit.from_browser(async_browser=async_browser)
tools = browser_toolkit.get_tools()

gpt_model = "gpt-4"

llm = ChatOpenAI(
    temperature=0,
    model_name=gpt_model,
    openai_api_key=OPENAI_API_KEY
)

agent_chain = initialize_agent(tools, llm, agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)

async def main():
    response = await agent_chain.arun(input="Browse to https://www.theverge.com/2023/3/14/23638033/openai-gpt-4-chatgpt-multimodal-deep-learning and describe it to me.")
    return response

result = asyncio.run(main())
print(result)


### Expected behavior

Enter chain, navigate to browser, read content in browser, return description.

Based on: https://python.langchain.com/docs/modules/agents/agent_types/structured_chat.html
FileCallbackHandler doesn't log entering new chain
Labels: name: bug, name: needs work

### System Info

Langchain 0.0.200
Python 3.11.4
Windows 10

### Who can help?

@agola11

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

1. Use with `load_qa_chain`

Error in console:
```
Error in on_chain_start callback: 'name'
```

Log file content is missing "Entering new chain"

### Expected behavior

1. No error in console
2. "Entering new chain" is present in log file

Fix: access dict with fallback like StdOutCallbackHandler does:
```python
class_name = serialized.get("name", "")
```