delayedkarma/langchain-issues huggingface dataset:
Fix `llms.Mlflow` example
Labels: name: lgtm, name: auto:bug, name: area: models, name: size:XS

<!-- Thank you for contributing to LangChain!

Replace this entire 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!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->

The example code for `llms.Mlflow` is outdated.
Remove unused `Params`
Labels: name: auto:nit, name: area: models, name: size:S

<!-- Thank you for contributing to LangChain!

Replace this entire 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!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->

Removes unused `Params` in `libs/langchain/langchain/llms/mlflow.py`.
Update minimax.py
Labels: name: auto:bug, name: area: models, name: size:XS

MiniMaxChat class _generate method shoud return a ChatResult object not str

<!-- Thank you for contributing to LangChain!

Replace this entire 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!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
index with redis as vector store cannot delete documents
Labels: name: area: doc loader, name: area: vector store, name: auto:bug, name: integration: redis

### System Info

langchain==0.0.346
python==3.11.6

### Who can help?

@eyurtsev

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

### Reproduction

Hi there!

I'm currently exploring the index feature in Langchain to load documents into the vector store upon my app startup.

However, I've encountered an issue where the index doesn't delete old documents when utilizing Redis as the vector store. After some investigation, I discovered that the `delete` function in `langchain.vectorstores.redis.base.Redis` is a static method, which poses a limitation—it cannot access instance variables, including the essential `key_prefix`. Without the `key_prefix`, Redis is unable to delete documents correctly.

This leads me to question why the `delete` method of the Redis vector store is static. I've noticed that other vector stores, such as Pinecone, do not have a static `delete` function and seem to handle this differently.


### Expected behavior

index with Redis as vector store should delete documents correctly.
Allow ChatAnthropic to receive Raw prompt or don't deprecate llms.Anthropic
Labels: name: auto:improvement, name: area: models

### Feature request

GitLab is currently trying to adopt LangChain in https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/merge_requests/475 for Anthropic usage. It's just simply passing a raw prompt to the Anthropic client, however, LangChain seems not supporting it because:

- `langchain.chat_models.ChatAnthropic` class can't take a raw prompt. It expects [`List[BaseMessage]`](https://github.com/dosuken123/langchain/blob/master/libs/langchain/langchain/chat_models/anthropic.py#L45C5-L45C41) and constructs the new messages.
- `langchain.llms.Anthropic` class was deprecated by @hwchase17 in https://github.com/langchain-ai/langchain/commit/52d95ec47dbb06a1bcc3f0ff30cadc50135351db. We don't want to use a deprecated class.

It sounds like we should add an option to `ChatAnthropic` to allow raw prompt, or recover `langchain.llms.Anthropic` from deprecated state.

### Motivation

Increasing the adoption of LangChain in GitLab

### Your contribution

I can contribute to this issue as LangChain contributor.
create_sql_agent Suffix error
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

Langchain version = 0.0.344
Python version = 3.11.5

@agola11 @hwchase17

### Who can help?

@hwchase17 @agola11

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

### Reproduction

Here is my code and it is giving me below error for create_sql_agent whe i use suffix variable.

A single string input was passed in, but this chain expects multiple inputs (set()). When a chain expects multiple inputs, please call it by passing in a dictionary, eg `chain({'foo': 1, 'bar': 2})

agent_inputs = {
    'prefix': MSSQL_AGENT_PREFIX,
    'format_instructions': MSSQL_AGENT_FORMAT_INSTRUCTIONS,
    'suffix': MSSQL_AGENT_SUFFIX,
    'llm': llm,
    'toolkit': toolkit,
    'top_k': 30,
    'early_stopping_method': 'generate',
    'handle_parsing_errors': True,
    'input_variables': ['question']
   
}

agent_executor_sql = create_sql_agent(**agent_inputs)

i also used suffix': [MSSQL_AGENT_SUFFIX],    and   suffix': str(MSSQL_AGENT_SUFFIX). Yet the error persist. Kindly help.



### Expected behavior

It should take suffix and work.
OpenAIEmbeddings bug
Labels: name: area: embeddings, name: auto:bug

### System Info

langchain==0.0.344
langchain-experimental>=0.0.42
python==3.10.12
 ```
embeddings = OpenAIEmbeddings(model_name=model,
                                                  openai_api_key=get_model_path(model),
                                                  chunk_size=CHUNK_SIZE)
```
error
```
WARNING! model_name is not default parameter.
                    model_name was transferred to model_kwargs.
                    Please confirm that model_name is what you intended.
  warnings.warn(
2023-12-07 12:36:12,645 - embeddings_api.py[line:39] - ERROR: Embeddings.create() got an unexpected keyword argument 'model_name'
AttributeError: 'NoneType' object has no attribute 'conjugate'
```

### Who can help?

@hwchase17

### Information

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

### Related Components

- [ ] LLMs/Chat Models
- [X] 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

```
                    from langchain.embeddings.openai import OpenAIEmbeddings
                    embeddings = OpenAIEmbeddings(model_name="text-embedding-ada-002",
                                                  openai_api_key='xxxx',
                                                  chunk_size=512)
                    data = embeddings.embed_documents(texts)

```

### Expected behavior

Normal loading
Triyam/bedrock Exception bug resolved
Labels: name: auto:bug, name: area: models, name: size:XS

Issue #14347

  - **Description:**  There a minor bug in error catching in `bedrockbase` class `langchain/llms/bedrock.py` file, 
  - **Issue:** exception was providing a broad error
  - **Changes:** 
>pytest = "^7.4.3", 
>content-hash = "fea3d6ece1f52d59a144dd626f61be20bda6306dfe4f786b815d7a2f1e82d486"
> This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
  - **Twitter handle:** https://twitter.com/Triyambaka58284?t=X5gMJFL7PcijWDzP5zgp6g
  
  ```diff

Removed:

 -except Exception as e:
 -         raise ValueError(f"Error raised by bedrock service: {e}")
 
 Added:
 
+except Exception as e:
+            if "ThrottlingException" in str(e):
+                raise ValueError(
+                    f"ThrottlingException raised by bedrock service: {e}"
+                ) from e
+           else:
+                raise ValueError(f"Error raised by bedrock service: {e}") from e

```
[Feature] RecursiveURLLoader: Custom PreventOutside

For websites where you start at a .html file, you aren't able to load sibling paths. If we allow prevent_outside to be another url, you can do things like:
start at `https://api.python.langchain.com/en/latest/core_api_reference.html` and prevent_outside to be `https://api.python.langchain.com/en/latest/`
Add support for private endpoint(Private Service Connect) for Vertex AI LLM
Labels: name: auto:enhancement, name: area: models

### Feature request

Add support for Private Service Connect endpoints in Vertex AI LLM.

### Motivation

Currently api_endpoint for VertexAIModelGarden LLM is hard coded to ```aiplatform.googleapis.com```

https://github.com/langchain-ai/langchain/blob/db6bf8b022c17353b46f97ab3b9f44ff9e88a488/libs/langchain/langchain/llms/vertexai.py#L380-L382

Google supports Private Service Connect or private endpoints to google services.
https://cloud.google.com/vpc/docs/configure-private-service-connect-apis#using-endpoints
Users can use private domains i.e. ```us-central1-aiplatform-xxxx.p.googleapis.com``` to call models in vertex ai.

### Your contribution

I can create a PR to add api_endpoint_base to let users specify google api endpoint for VertexAIModelGarden.

Currently pretrained models in ```vertexai.language_models```doesn't support specifying googleapi endpoint.
I'll also create an issue on vertex ai python sdk. 
Changes to pretrained model can be made if necessary changes are made to vertex ai python sdk.
Issue: How can we specify multiple types when initialize an agent
Labels: name: area: agent, name: auto:question, name: auto:improvement

### Issue you'd like to raise.

Can the 'AgentType parameter of ‘initialize_agent’ function only be of one type? How can I specify multiple types? I want to set agent type to 'STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION' and 'ZERO_SHOT_REACT_DESCRIPTION' at the same time ?

### Suggestion:

Set agent type to 'STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION' and 'ZERO_SHOT_REACT_DESCRIPTION' at the same time when create a agent?
Issue: No module named 'langchain'
Labels: name: auto:bug

### Issue you'd like to raise.

Issue:
```
PS E:\CODE\research-agents> python app.py
Traceback (most recent call last):
  File "E:\CODE\research-agents\app.py", line 3, in <module>
    from langchain.text_splitter import RecursiveCharacterTextSplitter
ModuleNotFoundError: No module named 'langchain'
```

What I've tried:
- Upgrading to langchain newest version
- Downgrading to langchain version==0.0.340
- Adding python path to environment variables
- Fresh environment with Python 3.10.x
- Fresh environment with Python 3.11.5


System:
Python ver: 3.11.5 (Anaconda)
Langchain ver: 0.0.340
OS: Windows 10

Thoughts, suggestions and tips are great appreciated. Thanks in advance!

### Suggestion:

_No response_
docs: notebook linting
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:L

Many jupyter notebooks didn't pass linting. List of these files are presented in the [tool.ruff.lint.per-file-ignores] section of the pyproject.toml . Addressed these bugs:
- fixed bugs; added missed imports; updated pyproject.toml
@efriis Only the `document_loaders/tensorflow_datasets.ipyn`, `cookbook/gymnasium_agent_simulation.ipynb` are not completely fixed. I'm not sure about imports.
Issue: agent output parser
Labels: name: area: agent, name: auto:question, name: auto:improvement

### Issue you'd like to raise.

Hi, I'm trying to make a Chinese agent using customized tools and prompt in Chinese. However the pre-defined output parser and streaming didn't work well. For example, the thought process was printed out even if I'm using the FinalStreamingStdOutCallbackHandler. I was wondering if you can help me 1, to understand how the prompt, output parser and streaming works in agent; 2 provide me some suggestions of making my own prompt, output parser and streaming class for Chinese processing.

### Suggestion:

_No response_
MongoDB agent fixes
Labels: name: area: agent, name: auto:improvement, name: size:L

<!-- Thank you for contributing to LangChain!

Replace this entire 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!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
  - **Description:** Moved the agent designed to interact with and query a MongoDB database using PyMongo into experimental, and fixed the unit test issues that came about using MongoDB Unix sockets. 
  - **Issue:** There were some some test workflows not running in `Harrison/mongo-agent` due to using nonexistent sockets, and Mongo agent should have been moved to experimental due to concerns mentioned in #13991
  - **Dependencies:** `pymongo` in experimental, not optional
    - Reason: Github workflows were throwing `pymongo ModuleNotFound` errors when it was optional, even after adding it to extended testing, running poetry lock, doing everything that the testing documentation said to do
  - **Related:** #14056, #13991
  - **Tag maintainers:** @hwchase17 @efriis
Use extend method for embeddings concatenation in mlflow_gateway
Labels: name: lgtm, name: area: embeddings, name: auto:bug, name: size:XS

## Description
There is a bug in the concatenation of embeddings obtained from MLflow that does not conform to the type hint requested by the function.
``` python  
def _query(self, texts: List[str]) -> List[List[float]]:
```
It is logical to expect a **List[List[float]]** for a **List[str]**. However, the append method encapsulates the response in a global List.
To avoid this, the extend method should be used, which will add the embeddings of all strings at the same list level.

## Testing
I have tried using OpenAI-ADA to obtain the embeddings, and the result of executing this snippet is as follows:  

``` python  
embeds = await MlflowAIGatewayEmbeddings().aembed_documents(texts=["hi", "how are you?"])
print(embeds)
```  

``` python  
[[[-0.03512698, -0.020624293, -0.015343423, ...], [-0.021260535, -0.011461929, -0.00033121882, ...]]]
```
When in reality, the expected result should be:

``` python  
[[-0.03512698, -0.020624293, -0.015343423, ...], [-0.021260535, -0.011461929, -0.00033121882, ...]]
```
The above result complies with the expected type hint: **List[List[float]]** . As I mentioned, we can achieve that by using the extend method instead of the append method.
prevent regexparser output for map_rerank from failing
Labels: name: auto:bug, name: area: models, name: size:M

Description: The Map Rerank chain fails if, for any of the intermediate outputs, a score is not generated. This happens because the regex parser is an exact match on the "Score" keyword. No exception handling is done if this score is not generated and the pipeline fails. This is cumbersome to fix manually for a large set of queries.

Fix: Add an exception case that if a score is not generated, add the "Score : 0" for that case. Logically this means the same as a score having no meaning.

This fix resolves issue: #3970
Update readthedocs_documentation.ipynb
Labels: name: area: doc loader, name: auto:documentation, name: size:XS

Have added latest implementation of ReadTheDocsLoader that I tried out on Langchain docs. 
The important parameter here is "encoding". Many users face the issue of 'UnicodeDecodeError':'character maps to Undefined. So, they need to change encoding according to their html files to utilize full power of ReadTheDocsLoader.

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** 
        Have added latest implementation of ReadTheDocsLoader that I tried out on Langchain docs. 
        The important parameter here is "encoding". Many users face the issue of 'UnicodeDecodeError':'character maps to 
        <Undefined>. So, they need to change encoding according to their html files to use ReadTheDocsLoader.
  - **Issue:** NA,
  - **Dependencies:** No,
  - **Tag maintainer:** @hotchpotch ,
  - **Twitter handle:** NA

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

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. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Unexpected behaviour: CharacterTextSpitter
Labels: name: area: doc loader, name: auto:bug

### System Info


langchain version: 0.0.315
python3.9



### Who can help?

@hwchase17  @eyurtsev 

### Information

- [ ] 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

```
splitter = CharacterTextSplitter(
        separator="\n",
        chunk_size=1000,
        chunk_overlap=i0
    )
    paragraphs = splitter.split_text("This is the first paragraph.\n\nThis is the second paragraph.")
    print(paragraphs)

paragraphs = splitter.split_text("This is the first paragraph.\n \nThis is the second paragraph.")
    print(paragraphs)
```

Returns 
```
This is the first paragraph.\nThis is the second paragraph. #seems wrong, as It omits a new line character.
This is the first paragraph.\n \nThis is the second paragraph. #correct
```


### Expected behavior
```
This is the first paragraph.\n\nThis is the second paragraph.
This is the first paragraph.\n \nThis is the second paragraph.
```
Error catching in BedrockBase
Labels: name: auto:bug, name: area: models

### System Info

I want to use the `with_retry` from the Runnable class with Bedrock class to initiate a retry if Bedrock is raising a ThrottlingException (too many requests)  the problem is the error catching in `BedrockBase` class in the `_prepare_input_and_invoke` method is too broad. (line 269)
```
        except Exception as e:
            raise ValueError(f"Error raised by bedrock service: {e}")
```
Is it possible to use something like :
```
        except Exception as e:
            raise ValueError(f"Error raised by bedrock service: {e}") from e
```
Or:
```
        except Exception as e:
            raise ValueError(f"Error raised by bedrock service: {e}")with_traceback(e.__traceback__)
```
To keep the initial exception type.

Am I missing something that would explain this broad error catching?

### Who can help?

_No response_

### Information

- [ ] 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
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

No reproduction needed

### Expected behavior

Expected behavior explained previously