delayedkarma/langchain-issues huggingface dataset:
Update root poetry lock with core
Labels: name: lgtm, name: auto:nit, name: size:M

<!-- 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.
 -->
Add rag google sensitive data protection template
Labels: name: lgtm, name: auto:enhancement, name: area: models, name: size:XXL

This is a template demonstrating how to utilize Google Sensitive Data Protection in conjunction with ChatVertexAI(). Tagging you @efriis  as you reviewed my last template. :) Thanks!

Proof of successful execution: 
![image](https://github.com/langchain-ai/langchain/assets/82172964/e4d678aa-85c8-482b-b09d-81fe7e912dd4)
Link to URL to load product details
Labels: name: area: embeddings, name: area: doc loader, name: auto:question

@dosu-bot

I have a project where I need to extract product details from product links online. What is the best url loader for this use case?

Also, for the previous links that I already appended to a csv file called "Lalal". How can I create embeddings only for the new URL link that I will extract so that I dont have to embed the entire document every single time.

Please write the code for me in python.
AzureCosmosDBVectorSearch index creation fixes document key
Labels: name: area: vector store, name: auto:bug

### System Info

Langchain all versions

### Who can help?

@hwchase17 @izzymsft 

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

### Reproduction

Instantiate a new AzureCosmosDBVectorSearch with embeddings key different than vectorContent, and then you get this error
`Similarity index was not found for a vector similarity search query.`

This is because embeddings key is parametrised correctly
https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/vectorstores/azure_cosmos_db.py#L75
https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/vectorstores/azure_cosmos_db.py#L92
, but not used on index creation
https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/vectorstores/azure_cosmos_db.py#L224



### Expected behavior

The embedding_key param should be used to create the index properly
Addition of BinaryPyPdf Loader for Langchain Document Loaders
Labels: name: area: doc loader, name: auto:enhancement

### Feature request

I propose the addition of a new feature, a BinaryPyPdf loader, to the existing Langchain document loaders. This loader is designed to handle PDF files in a binary format, providing a more efficient and effective way of processing PDF documents within the Langchain project.

### Motivation

As a Langchain enthusiast, I noticed that the current document loaders lack a dedicated loader for handling PDF files in binary format. This often leads to inefficiencies and limitations when working with PDF documents. The addition of a BinaryPyPdf loader would address this gap and enhance the overall functionality and versatility of the Langchain document loaders.

### Your contribution

I have already developed a BinaryPyPdf loader using `pypdf` that is ready for integration into the Langchain project. I am prepared to submit a PR for this feature, following the guidelines outlined in the [`CONTRIBUTING.MD`](https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md). I look forward to the opportunity to contribute to the project and enhance its capabilities.
Update openai.py: Fix the bug where openai_proxy is not effective.
Labels: name: auto:bug, name: area: models, name: size:XS

Fix the bug where ChatOpenAI().openai_proxy = HTTP_PROXY is not effective.

Reproduce&Test:

from langchain.chat_models import ChatOpenAI
llm = ChatOpenAI()
llm.openai_proxy = "http://127.0.0.1:8001"
llm.predict("Hello")

<!-- 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.
 -->
docs[patch]: RAG Cookbook example fix
Labels: name: auto:documentation, name: size:XS

### Description:
Hey 👋🏽  this is a small docs example fix. Hoping it helps future developers  who are working with Langchain.

### Problem:
Take a look at the original example code. You were not able to get the `dialogue_turn[0]` while it was a tuple.

Original code:
```python
def _format_chat_history(chat_history: List[Tuple]) -> str:
    buffer = ""
    for dialogue_turn in chat_history:
        human = "Human: " + dialogue_turn[0]
        ai = "Assistant: " + dialogue_turn[1]
        buffer += "\n" + "\n".join([human, ai])
    return buffer
```
In the original code you were getting this error:
```bash
    human = "Human: " + dialogue_turn[0].content
                        ~~~~~~~~~~~~~^^^
TypeError: 'HumanMessage' object is not subscriptable
```
### Solution:
The fix is to just for loop over the chat history and look to see if its a human or ai message and add it to the buffer.
MultiVector Retriever BaseStore
Labels: name: area: memory, name: area: vector store, name: auto:improvement

### Feature request

MultiVectorRetriever is really helpful to add summary and hypothetical queries of our documents to improve the retrievers but only these two are stored in the vectorstore, instead the entire document is within a BaseStore (Memory or Local).
The main issue is that:
- the Memory one is not going to persist across restarts 
- the File one is going to create tons of files
Why not keeping the original document in the vectorstore as well instead of using external file/memory?

### Motivation

Keep documents, questions and summaries on the same vectorstore.

### Your contribution

I could work on that but I would like to know your point of view.
fix: fix qianfan validate_environment typo
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.
 -->
imports of OpenAI and SQLDatabase don't work in .py file
Labels: name: auto:bug, name: area: models

### System Info

Ubuntu 23.10

### Who can help?

@hwchase17 @agola11 

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

```
from langchain import OpenAI, SQLDatabase
from snowflake.snowpark import Session 
from langchain.chains import create_sql_query_chain

from dotenv import load_dotenv
import os
from urllib.parse import quote

load_dotenv()

# use the env vars in comments above to set the vars below
OpenAI_API_KEY = os.getenv("OPENAI_API_KEY")
snowflake_account = os.getenv("ACCOUNT")
username = os.getenv("USER")
password = os.getenv("SNOWSQL_PWD")
warehouse = os.getenv("WAREHOUSE")
database = 'LANGCHAIN_DEMO_DB' #os.getenv("DATABASE")
schema = 'PUBLIC' #os.getenv("SCHEMA")
role = os.getenv("ROLE")


# print out all env vars using f-strings each on a separate line but x out password
print(f"OpenAI_API_KEY: {'x' * len(OpenAI_API_KEY)}")
print(f"snowflake_account: {snowflake_account}")
#print(f"username: {username}")
#print(f"password: {password}")
print(f"warehouse: {warehouse}")
print(f"database: {database}")
print(f"schema: {schema}")
print(f"role: {role}")

encoded_password = quote(password, safe='')
```
but it works in my Jupyter notebook 

![image](https://github.com/langchain-ai/langchain/assets/25189545/5ef3caa3-747e-4622-9714-a96f8e10a5ad)

https://medium.com/@muriithicliffernest/snowflake-langchain-generating-sql-queries-from-natural-language-queries-12c4e2918631 is the tutorial I followed for the .ipynb.

```
pip install --upgrade pip
pip install "snowflake-snowpark-python[pandas]" snowflake-sqlalchemy
pip install langchain openai langchain-experimental jupyter
```
are the instructions to install packages in that Medium article so I matched versions for both the conda env I'm using for the .py and .ipynb.  Even if I use the same `langchain-snowlfake` env for both the error is still there.  See the red line under `from langchain import OpenAI, SQLDatabase 
` in the right half of the image which is showing `lanchain-sql.py`




### Expected behavior

The import should work, no red line.
Support for indexes that do not return a 'metadata' field in '_source'
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: integration: elasticsearch, name: size:XS


Description: Some Elastic indexes do not return a 'metadata' field in '_source'. However, prior to this PR, the code assumed  there always is a 'metadata' field. This PR adds support for cases where the field is missing by adding it manually.

Issue: #13869
AnthropicFunctions  function_call compatibility
Labels: name: lgtm, name: auto:improvement, name: area: models, name: size:M

  - **Description:** Updates to `AnthropicFunctions` to be compatible with the OpenAI `function_call` functionality.
  - **Issue:** The functionality to indicate `auto`, `none` and a forced function_call was not completely implemented in the existing code.
  - **Dependencies:** None
  - **Tag maintainer:** @baskaryan , and any of the other maintainers if needed.
  - **Twitter handle:** None

I have specifically tested this functionality via AWS Bedrock with the Claude-2 and Claude-Instant models.
Issue: Retrieval QA Chain not giving response after Entering new RetrievalQA chain...
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

Sometimes when interacting with the bot using Retrieval QA chain, it just stops at Entering new RetrievalQA chain...
No response, it doesn't give the response, it just stops,
I am using qa.acall
and using the async callback handler
how to fix that, as that is unnacceptable

### Suggestion:

_No response_
Issue: AgentExecutor stopping before reaching the set max_iteration and max_execution_time limits without meeting the stop condition
Labels: name: area: agent, name: auto:bug, name: auto:question, name: area: models

### Issue you'd like to raise.

```python
llm = ChatOpenAI(model=gpt_4, temperature=0, api_key=os.environ['OPENAI_API_KEY'])

llm_chain = LLMChain(llm=llm, prompt=react_prompt)

tool_names = [tool.name]

agent = LLMSingleActionAgent(
    llm_chain=llm_chain,
    output_parser=react_output_parser,
    stop=["\nObservation:"],
    allowed_tools=tool_names,
    max_execution_time=240,
    max_iterations=120,
    handle_parsing_errors=True
)

agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=[tool], verbose=True)
response = agent_executor.run(textual_description)
```

This is my setup for AgentExecutor. It is prompted to solve OpenAI gym's Taxi problem and only stop after the passenger is dropped off at the destination. But as the title suggests the AgentExecutor chain finishes before reaching the stopping limits or achieving the stopping condition.

Also when I use GPT-3 model sometimes it stops following the ReAct template occasionally and raises errors as my output parser cannot process the output correctly. I wonder if there is a way to change that.

### Suggestion:

_No response_
Improve exclude path filesystem logic
Labels: name: area: doc loader, name: auto:improvement, name: size:S

  - **Description:** Improving the use of the exclude arguments for `FileSystemBlobLoader`
  - **Issue:** #13751
  - **Dependencies:** n/a
  - **Tag maintainer:** 
  - **Twitter handle:** this PR won't get announced, but @jlarks32

See the issue above for more detail, but I don't think that the `exclude` parameter is being handled really like what the API is indicating / what we were thinking (largely due to annoyances with pathlib's `Path.match`). Let me know if you all want me to add some more unit tests and build this out a little bit more. 

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:

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.
 -->
Add multi-input Reddit search tool
Labels: name: area: agent, name: auto:enhancement, name: size:XL

  - **Description:** Added a tool called RedditSearchRun and an accompanying API wrapper, which searches Reddit for posts with support for time filtering, post sorting, query string and subreddit filtering. 
  - **Issue:** #13891 
  - **Dependencies:** `praw` module is used to search Reddit
  - **Tag maintainer:** @baskaryan , and any of the other maintainers if needed
  - **Twitter handle:** None.

  Hello,

This is our first PR and we hope that our changes will be helpful to the community. We have run `make format`, `make lint` and `make test` locally before submitting the PR. To our knowledge, our changes do not introduce any new errors.

Our PR integrates the `praw` package which is already used by RedditPostsLoader in LangChain. Nonetheless, we have added integration tests and edited unit tests to test our changes. An example notebook is also provided. These changes were put together by me, @Anika2000, @CharlesXu123, and @Jeremy-Cheng-stack

Thank you in advance to the maintainers for their time.
Adding a multi-input Reddit search tool
Labels: name: area: agent, name: area: doc loader, name: auto:enhancement, name: auto:documentation

### Feature request

We are working on a way to add a multi-input tool to LangChain for searching Reddit posts. Integrating the API as a tool will allow agents to search for posts using a specific search query and some query parameters like sort, time_filter, subreddit etc. to respond to prompts. The tool will use search functionality provided by [the `praw` package](https://praw.readthedocs.io/en/stable/code_overview/models/subreddit.html#praw.models.Subreddit.search).

### Motivation

Although LangChain currently has a document loader for Reddit (RedditPostsLoader), it is more centred around subreddit and username to load posts and we want to create our tool to provide more functionalities.  Our tool will offer functionality for sorting and filtering by time, which is currently not handled by RedditPostsLoader. With this tool, agents can respond to prompts by interacting with the API without the user having to manually load the Reddit posts. The multi-input nature of the tool will make it useful for responding to more diverse prompts and we hope that users can use it to better leverage [multi-input tool](https://python.langchain.com/docs/modules/agents/tools/multi_input_tool) and [shared memory](https://python.langchain.com/docs/modules/agents/how_to/sharedmemory_for_tools) functionalities already provided by LangChain.

### Your contribution

We have our code already prepared and we will be submitting a PR soon. As encouraged by contributing.md, we have added integration tests, a notebook example, and edits for documentation generation. `praw` has also been added as an optional dependency.
DOC: Fix Sample Code for Compatibility with Pydantic 2.0
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:S

  - **Description:** 
I encountered an issue while running the existing sample code on the page https://python.langchain.com/docs/modules/agents/how_to/agent_iter in an environment with Pydantic 2.0 installed. The following error was triggered:

```python
ValidationError                           Traceback (most recent call last)
<ipython-input-12-2ffff2c87e76> in <cell line: 43>()
     41 
     42 tools = [
---> 43     Tool(
     44         name="GetPrime",
     45         func=get_prime,

2 frames
/usr/local/lib/python3.10/dist-packages/pydantic/v1/main.py in __init__(__pydantic_self__, **data)
    339         values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
    340         if validation_error:
--> 341             raise validation_error
    342         try:
    343             object_setattr(__pydantic_self__, '__dict__', values)

ValidationError: 1 validation error for Tool
args_schema
  subclass of BaseModel expected (type=type_error.subclass; expected_class=BaseModel)
```

I have made modifications to the example code to ensure it functions correctly in environments with Pydantic 2.0.
Fixes error loading Obsidian templates
Labels: name: lgtm, name: area: doc loader, name: auto:bug, name: size:M

  - **Description:** Obsidian templates can include [variables](https://help.obsidian.md/Plugins/Templates#Template+variables) using double curly braces.  `ObsidianLoader` uses PyYaml to parse the frontmatter of documents. This parsing throws an error when encountering variables' curly braces. This is avoided by temporarily substituting safe strings before parsing.
  - **Issue:** #13887
  - **Tag maintainer:** @hwchase17
Mask API keys for various LLM/ChatModel Modules
Labels: name: auto:improvement, name: area: models, name: size:L

  **Description:** 
- Added masking of the API Keys for the modules:
  - `langchain/chat_models/openai.py`
  - `langchain/llms/openai.py`
  - `langchain/llms/google_palm.py`
  - `langchain/chat_models/google_palm.py`
  - `langchain/llms/edenai.py`

- Updated the modules to utilize `SecretStr` from pydantic to securely manage API key.
- Added unit/integration tests
- `langchain/chat_models/asure_openai.py` used the `open_api_key` that is derived from the `ChatOpenAI` Class and it was assuming `openai_api_key` is a str so we changed it to expect `SecretStr` instead.

**Issue:** https://github.com/langchain-ai/langchain/issues/12165 ,
**Dependencies:** none,
**Tag maintainer:** @eyurtsev
Extend OpenAIEmbeddings class to support non-`tiktoken` based embeddings
Labels: name: lgtm, name: area: embeddings, name: auto:improvement, name: size:L

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** This extends `OpenAIEmbeddings` to add support for non-`tiktoken` based embeddings, specifically for use with the new `text-generation-webui` API (`--extensions openai`) which does not support `tiktoken` encodings, but rather strings 
  - **Issue:** Not found,
  - **Dependencies:** HuggingFace `transformers.AutoTokenizer` is new dependency for running the model without `tiktoken`
  - **Tag maintainer:** @baskaryan based on last commit for `langchain-core` refactor
  - **Twitter handle:** @xychelsea

Modified the tokenization process to be model-agnostic, allowing for both OpenAI and non-OpenAI model tokenizations, by setting the new default `bool` flag `tiktoken_enabled` to `False`. This requeires HuggingFace’s AutoTokenizer and handling tokenization for models requiring different preprocessing steps to generate a chunked string request rather than a list of integers.

Updated the embeddings generation process to accommodate non-OpenAI models. This includes converting tokenized text into embeddings using OpenAI’s and Hugging Face’s model architectures.
 -->
Add progress bar to OllamaEmbeddings
Labels: name: area: embeddings, name: auto:improvement, name: size:S

- **Description:** Adds a tqdm progress bar to OllamaEmbeddings when embedding a list.
- **Issue:** Related to #13637, but extended to Ollama.
- **Dependencies:** `tqdm` made a necessary dependency.

Thanks to @ugm2 for helping identify a common problem. Embeddings take a very long time to finish on local machines, and require a progress bar to help identify if one should even attempt the workload.
Make contributing to docs easier
Labels: name: auto:documentation, name: size:XS

With this PR readers can suggest changes to the docs with an easy to use WYSIWYG markdown editor.

[This](https://holocron.so/github/pr/langchain-ai/langchain/master/editor) is how the editor looks like for this repo.

https://github.com/remorses/docusaurus-example/assets/31321188/43c8bc68-3668-4a25-bf1c-a70eceab7bcb