delayedkarma/langchain-issues huggingface dataset:
Can you make it file handle rather than file/path in langchain_experimental.agents.agent_toolkits.csv.base.create_csv_agent
Labels: name: area: agent, name: auto:improvement

### Feature request

Guys,
Just to make it more 'generic' instead of path, could you not make it file handle ? Any reason it has to be file path ?
langchain_experimental.agents.agent_toolkits.csv.base.create_csv_agent
langchain_experimental.agents.agent_toolkits.csv.base.create_csv_agent(llm: [BaseLanguageModel](https://api.python.langchain.com/en/latest/schema/langchain.schema.language_model.BaseLanguageModel.html#langchain.schema.language_model.BaseLanguageModel), **path: Union[str, IOBase, List[Union[str, IOBase]]]**, pandas_kwargs: Optional[dict] = None, **kwargs: Any)

### Motivation

File handles are anyway used in the codes once file opened. sounds like make sense to use that rather than file/path

### Your contribution

Wish I could
docs `integrations/components` indexes
Labels: name: auto:documentation

this PR is continuing after #12307 
Problem statement:
Here is an [example](https://python.langchain.com/docs/integrations/document_transformers). 
We have a sidebar with Toc and we also have a ToC at the end of the page. 
The ToC at the end of the page is not necessary and it is confusing when we mix the index page styles, moreover, it requires manual work. 
So, instead of the generated index.mdx pages with CardLists, I've created them manually with small text about an entity.
Textract linearizer
Labels: name: lgtm, name: area: doc loader, name: auto:improvement, name: integration: aws

**Description:** Textract PDF Loader generating linearized output, meaning it will replicate the structure of the source document as close as possible based on the features passed into the call (e. g. LAYOUT, FORMS, TABLES). With LAYOUT reading order for multi-column documents or identification of lists and figures is supported and with TABLES it will generate the table structure as well. FORMS will indicate "key: value" with columms.
  - **Issue:** the issue fixes #12068 
  - **Dependencies:** amazon-textract-textractor is added, which provides the linearization
  - **Tag maintainer:** @3coins 

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Redis langserve template
Labels: name: area: vector store, name: auto:enhancement, name: integration: redis

Add Redis langserve template! Eventually will add semantic caching to this too. But I was struggling to get that to work for some reason with the LCEL implementation here.

  - **Description:** Introduces the Redis LangServe template. A simple RAG based app built on top of Redis that allows you to chat with company's public financial data (Edgar 10k filings)
  - **Issue:** None
  - **Dependencies:** The template contains the poetry project requirements to run this template
  - **Tag maintainer:** @baskaryan @Spartee 
  - **Twitter handle:** @tchutch94

**Note**: this requires the commit here that deletes the `_aget_relevant_documents()` method from the Redis retriever class that wasn't implemented. That was breaking the langserve app.
feat: Add Google Cloud Translation document transformer
Labels: name: auto:enhancement

- Adds [Google Cloud Translation API](https://cloud.google.com/translate/docs/overview) document transformer
  - Uses Advanced (v3) API.
- Follows similar structure to [Doctran: language translation](https://python.langchain.com/docs/integrations/document_transformers/doctran_translate_document)

<!-- 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.
 -->
Importing openai causes openai.error.InvalidRequestError: Resource not found
Labels: name: auto:bug, name: area: models

### System Info

langchain==0.0.324
openai==0.28.1
Python 3.9.16
Using gpt-35-turbo-16k model from azure

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

Save this code in a .py file and run it to see the error:
```
import os
from dotenv import load_dotenv, find_dotenv
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
import openai

_ = load_dotenv(find_dotenv())
llm_model_name = os.environ.get('CHAT_MODEL_DEPLOYMENT_NAME')
llm = ChatOpenAI(temperature=0.0, model_kwargs={"engine": llm_model_name})
prompt = ChatPromptTemplate.from_template(
    """tell me a joke about {topic}"""
)
response = llm(prompt.format_messages(topic = "bear"))
print(response.content)
```
Then comment the `import openai` line and run again to get rid of errors.

### Expected behavior

The given code generates expected response from the llm after commenting the `import openai` line:
```
Why don't bears wear shoes?

Because they have bear feet!
```
Fix Typo in clickhouse.ipynb file
Labels: name: area: vector store, name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:fix a typo in langchain/docs/docs/integrations/vectorstores/clickhouse.ipynb {'envrionment'→'environment'}
  - **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:@Uxystayyyy 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.
 -->
Deprecate PythonRepl tools and Pandas/Xorbits/Spark DataFrame/Python/CSV agents (CVE-2023-39659)
Labels: name: area: agent, name: auto:refactor

See discussion here: https://github.com/langchain-ai/langchain/discussions/11680

The code is available for usage from langchain_experimental. The reason for the deprecation is that the agents are relying on a Python REPL. The code can only be run safely with appropriate sandboxing.

Resolves CVE-2023-39659
Add timestamp to parsing for self query retriever
Labels: name: auto:improvement

**Description:** Previously only dates were supported (although they were misnamed as timestamps). This commit adds proper timestamps and tests.

<!-- 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.
 -->
Adding a memory to the openAPI agent
Labels: name: area: memory, name: area: agent, name: auto:question

### Issue you'd like to raise.

In the create_openapi_agent there is an argument called **shared_memory** and it is passed to the LLM in the **ZeroShotAgent**. What is the difference between this one:
agent = ZeroShotAgent(
        llm_chain=LLMChain(llm=llm, prompt=prompt, **memory=shared_memory**), (this is a readonly memory as defined in the doc)
        allowed_tools=[tool.name for tool in tools],
        **kwargs,
    )
and adding it to the AgentExecutor.from_agent_and_tools(
        agent=agent,
        tools=tools,
        callback_manager=callback_manager,
        verbose=verbose,
        **memory=memory,** (I added it myself)
        **(agent_executor_kwargs or {}),
    )

### Suggestion:

_No response_
Developing an api request manager that automatically avoids rate limits
Labels: name: auto:enhancement, name: area: models

### Feature request

Currently: api-based models that pass rate limits raise an error and abort.
Desirable: sending api requests together in parallel, in a way that tracks their global token usage and response times, and waits as needed to avoid the rate limit.

### Motivation

Currently api-based models that pass rate limits raise an error and abort, but it's totally avoidable if the models track the token usage and wait as needed before calls.

### Your contribution

I'm not available to contribute more
Update long_context_reorder.py
Labels: name: lgtm, name: auto:nit

The function comment was confusing and inaccurate

<!-- 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.
 -->
get_relavant_docs with metadata parameter is not working as expected
Labels: name: area: doc loader, name: area: vector store, name: auto:question, name: integration: chroma

### Issue you'd like to raise.

I am trying to fetch relavant topics based on the metadata "country". The documents i am passing as this metadata in this particular format:
Document(page_content=".........", metadata={''Country': 'Ireland'})]..... and so on 
now i want to filter retrived content based on the Country , How can pass the metadata to the get_relavant_docs function along with the query to get the correct content. Or is there any way to using the metadata parameter while intializing the retriver.

Retriever i am trying to use in Parent Document Retriever (Note: I do not want to use Self Query Retriever) , chroma as my vector DB.

Could you please help me on how to use the metadata parameter to get the correct filtered relavant docs

### Suggestion:

_No response_
Mask API key for AI21 LLM
Labels: name: lgtm, name: auto:improvement, name: area: models

  - **Description:** Added masking of the API Key for AI21 LLM when printed and improved the docstring for AI21 LLM.
    - Updated the AI21 LLM to utilize SecretStr from pydantic to securely manage API key.
    - Made improvements in the docstring of AI21 LLM. It now mentions that the API key can also be passed as a named parameter to the constructor.
    - Added unit tests.
  - **Issue:** #12165 
  - **Tag maintainer:** @eyurtsev
openai.error.InvalidRequestError: Unrecognized request argument supplied: functions
Labels: name: area: agent, name: auto:bug, name: area: models

### Issue you'd like to raise.

I basically followed the tutorial and got exception at the last of call to `agent.invoke`, full code:

```
llm = OpenAI(openai_api_key="xxxxxxxxxxxxx")
from langchain.agents import Tool
@tool
def get_word_length(word: str) -> int:
    """Returns the length of a word."""
    return len(word)

tools = [get_word_length]
tools = [Tool(name="GetWordLength", func=get_word_length, description="Returns the length of a word.")]    

template = "You are a helpful assistant that translates from any language to english"
human_template = "{input}"

chat_prompt = ChatPromptTemplate.from_messages([
    ("system", template),
    ("human", human_template),
    MessagesPlaceholder(variable_name="agent_scratchpad"),
])

llm_with_tools = llm.bind(
    functions=[format_tool_to_openai_function(t) for t in tools]
)

agent = {
    "input": lambda x: x["input"],
    "agent_scratchpad": lambda x: format_to_openai_functions(x['intermediate_steps'])
} | chat_prompt | llm_with_tools | OpenAIFunctionsAgentOutputParser()
r = agent.invoke({
    "input": "how many letters in the word educa?",
    "intermediate_steps": []
})
```

could you help?

### Suggestion:

_No response_
Issue: Adding and Deleting PDF/URL/Confluence Data in Combined 'Embeddings' Folder using ChromaDB
Labels: name: area: embeddings, name: area: doc loader, name: auto:enhancement, name: integration: chroma

### Issue you'd like to raise.

I've successfully generated and stored embeddings for PDF documents, Confluence content, and URL data within a single 'embeddings' folder using ChromaDB. However, I'm looking to enhance the functionality and add the ability to delete and re-add PDF/URL/Confluence data from this combined folder while preserving the existing embeddings.

I believe this feature would significantly improve the versatility of the application and make it more user-friendly. Any guidance or contributions in implementing this functionality would be greatly appreciated.



### Suggestion:

_No response_
feat: adaptive model for ChatOpenAI
Labels: name: auto:enhancement, name: area: models

  - **Description:** Implementation of an OpenAIChatModel using OpenAI API. The enhancement proposed it to switch the OpenAI model context window based on the input of the users.
 On API requests with an intensive usage of tokens, it can be useful to use the high context window model, like "gpt-3.5-turbo=16k". My experience on a project showed, we could use requests with a lot of variability on token usage, if the inputs of the prompt has a lot a variability. 
In this regard, using an adaptative model for each request lead to a pricing optimization that is not negligible.
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** https://twitter.com/GuillaumeDELEP5

Thank you for a taking a look ! Looking forwards, any improvements or misconceptions I had while implementing.
Bagatur/deep memory version 1
Labels: name: area: memory, name: auto:enhancement

<!-- 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.
 -->
Accessing ChromaDB Embedding Vector from S3 Bucket
Labels: name: area: embeddings, name: area: vector store, name: auto:question, name: integration: chroma, name: integration: aws

**Accessing ChromaDB Embedding Vector from S3 Bucket**

**Issue Description:**
I am attempting to access the ChromaDB embedding vector from an S3 Bucket and I've used the following Python code for reference:

```python
# Now we can load the persisted database from disk, and use it as normal. 
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)
```

However, I'm uncertain about the steps to follow when I need to specify the S3 bucket path in the code.

**Questions/Clarifications:**
- What specific modifications or additions are required to access the embedding vector from an S3 Bucket?
- Are there any configuration changes needed to integrate S3 access seamlessly?

**Additional Information:**

- Name: chromadb
- Version: 0.3.21
- Summary: Chroma.
- Home-page:
- Author:
- Author-email: Jeff Huber <jeff@trychroma.com>, Anton Troynikov <anton@trychroma.com>
- License:
- Location: c:\users\ibm26\.conda\envs\llms\lib\site-packages
- Requires: clickhouse-connect, duckdb, fastapi, hnswlib, numpy, pandas, posthog, pydantic, requests, sentence-transformers, uvicorn
- Required-by:

Your assistance and guidance on this matter would be greatly appreciated. Thank you!

### Suggestion:

_No response_
convert date and timestamp to string format for qdrant
Labels: name: area: vector store, name: auto:bug

**Description:**
Convert the datetime values to string format to solve `qdrant_client.http.models.MatchValue` pydantic validation errors in QdrantTranslator. 


**Details:**
If the filter value output from llm contains "YYYY-MM-DD" formated datetime, the output parser will format it to `datetime.date`. 
https://github.com/langchain-ai/langchain/blob/d6acb3ed7e8338e42cbe25df38072b2bd15e0092/libs/langchain/langchain/chains/query_constructor/parser.py#L134

However, Qdrant client doesn't support datetime or date format, so this will result in pydantic error: 
https://github.com/qdrant/qdrant-client/blob/6875996cad0b4d15c891e9e81c725aaa3e9afdb5/qdrant_client/http/models/models.py#L1995
```
3 validation errors for MatchValue
value.bool
  Input should be a valid boolean [type=bool_type, input_value=datetime.date(2023, 10, 10), input_type=date]
    For further information visit https://errors.pydantic.dev/2.4/v/bool_type
value.int
  Input should be a valid integer [type=int_type, input_value=datetime.date(2023, 10, 10), input_type=date]
    For further information visit https://errors.pydantic.dev/2.4/v/int_type
value.str
  Input should be a valid string [type=string_type, input_value=datetime.date(2023, 10, 10), input_type=date]
    For further information visit https://errors.pydantic.dev/2.4/v/string_type
```

Similar convertion has been implemented in WeaviateTranslator:
https://github.com/langchain-ai/langchain/blob/d6acb3ed7e8338e42cbe25df38072b2bd15e0092/libs/langchain/langchain/retrievers/self_query/weaviate.py#L56
Issue: PGvector-Langchain-inconsistent similatiry search
Labels: name: area: embeddings, name: area: vector store, name: auto:bug, name: auto:question

### Issue you'd like to raise.

I am using the below code to fetch contents for user queries.

db = PGVector(
    collection_name=collection_name,
    connection_string=CONNECTION_STRING,
    embedding_function=embeddings,
)
retriever = db.as_retriever(
    search_kwargs={"k": 5}
)
while its working fine generally, in some case, the context brought does not represent the contents in the table. While i can query the same content using a simple query with select * from langchain_pg_embedding where document like '%keyword%' fetches records, it fails to bring relevant contents using langchain. I have removed duplicate records in the table, to see if that improves the search, but no improvement. Help me understand the causes and solution please.

### Suggestion:

_No response_
sourceDocuments are not returned when streaming with RetrievalQAChain but returns properly when *not* using streaming
Labels: name: auto:bug, name: area: models

### System Info

Langchain: 0.0.166
Ubuntu: 22.04
NodeJS: 18.18.2

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

### Reproduction

1. Create a retrieval chain with streaming:
```
this.chain = RetrievalQAChain.fromLLM(this.model, this.store.asRetriever(), {
      prompt: PromptTemplate.fromTemplate(this.prompt),
      returnSourceDocuments: true,
      stream: true
    });
```
2. Call `stream()` on the chain:
```
const response = await this.chain.stream({
      query: question,
      callbacks: [
        {
          handleLLMNewToken(token) {
            onChunkCallback(token);
          },
          handleLLMEnd(result, res2) {
            onEnd(result, res2);
          }
        },
      ]
    });
```
3. View the `sourceDocuments` property on the returned response, and set `verbose: true` on the chain and observe the chain output shows a `sourceDocuments` property that is an empty array.

### Expected behavior

The `sourceDocuments` property is populated the same way it is when not using streaming which shows the source documents the model used to generate the answer.