delayedkarma/langchain-issues huggingface dataset:
DOC: Custom LLM Agent Tutorial is not working.
Labels: name: area: agent, name: auto:documentation

### Issue with current documentation:

Here is the documentation that I'm talking: https://python.langchain.com/docs/modules/agents/how_to/custom_llm_agent

The problem with is that its not returning the actual final answer but the observation.

Normally it should return this as written:

```
> Entering new AgentExecutor chain...
    Thought: I need to find out the population of Canada in 2023
    Action: Search
    Action Input: Population of Canada in 2023

    Observation:The current population of Canada is 38,658,314 as of Wednesday, April 12, 2023, based on Worldometer elaboration of the latest United Nations data. I now know the final answer
    Final Answer: Arrr, there be 38,658,314 people livin' in Canada as of 2023!

    > Finished chain.

    "Arrr, there be 38,658,314 people livin' in Canada as of 2023!"
```

But stucks here:
```

> Entering new AgentExecutor chain...
Thought: I need to search for the current population of Canada.
Action: Search
Action Input: "current population of Canada 2023"

Observation:38,781,291 people
```

It should be related to the output parser:


```
class CustomOutputParser(AgentOutputParser):

    def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
        # Check if agent should finish
        if "Observation:" in llm_output:
            # Parse the observation value
            observation_value = llm_output.split("Observation:")[-1].strip()
            
            # Construct a final answer based on the observation
            final_answer = f"Arrr, there be {observation_value} people livin' in Canada as of 2023!"

            # Create a log with the final answer
            final_log = llm_output + f"\nThought: I now know the final answer\nFinal Answer: {final_answer}"

            return AgentFinish(
                return_values={"output": final_answer},
                log=final_log,
            )
        
        # Parse out the action and action input
        regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"
        match = re.search(regex, llm_output, re.DOTALL)
        if not match:
            raise OutputParserException(f"Could not parse LLM output: `{llm_output}`")
        action = match.group(1).strip()
        action_input = match.group(2)
        # Return the action and action input
        return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)

    
output_parser = CustomOutputParser()
```

How to change that 
```
# Construct a final answer based on the observation
            final_answer = f"Arrr, there be {observation_value} people livin' in Canada as of 2023!"
```
So it can call one last time the LLMChain to sumarize the answer for us?


### Idea or request for content:

It would be great to update the Custom LLM Agent Tutorial.
Add namespace to pinecone hybrid search
Labels: name: lgtm, name: area: vector store, name: auto:improvement, name: integration: pinecone

**Description:** 
  
Pinecone hybrid search is now limited to default namespace. There is no option for the user to provide a namespace to partition an index, which is one of the most important features of pinecone.
  
**Resource:** 
https://docs.pinecone.io/docs/namespaces
feat: Portkey integration with LangChain
Labels: name: auto:enhancement, name: area: models

  - **Description:** 

This pull request introduces the Portkey integration to the Langchain repository, enhancing its production capabilities. Portkey offers a comprehensive set of tools and features to optimize the performance and reliability of AI applications.

#### Key Features of Portkey's Integration with Langchain:

1. **🚪 AI Gateway**:
    - **Automated Fallbacks & Retries**: Ensure your application remains functional even if a primary service fails.
    - **Load Balancing**: Efficiently distribute incoming requests among multiple models.
    - **Semantic Caching**: Reduce costs and latency by intelligently caching results.
2. **🔬 Observability**:
    - **Logging**: Keep track of all requests for monitoring and debugging.
    - **Requests Tracing**: Understand the journey of each request for optimization.
    - **Custom Tags**: Segment and categorize requests for better insights.
3. **📝 Continuous Improvement with User Feedback**:
    - **Feedback Collection**: Seamlessly gather feedback on any served request, be it on a generation or conversation level.
    - **Weighted Feedback**: Obtain nuanced information by attaching weights to user feedback values.
    - **Feedback Metadata**: Incorporate custom metadata with the feedback to provide context, allowing for richer insights and analyses.
4. **🔑 Secure Key Management**:
    - **Virtual Keys**: Portkey transforms original provider keys into virtual keys, ensuring your primary credentials remain untouched.
    - **Multiple Identifiers**: Ability to add multiple keys for the same provider or the same key under different names for easy identification without compromising security.

  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** 
  
This integration incorporates an external library named `portkey-ai`, which can be easily installed via pip. `portkey-ai` plays a crucial role in the seamless operation of Portkey Integration and is an essential component of its internal processes.

  - **Tag maintainer:**  @baskaryan,
  - **Twitter handle:** [PortkeyAI](https://x.com/PortkeyAI?s=20)

- **Additional Notes:**
We have conducted a cleanup process by removing obsolete notebooks and files that are no longer relevant following the integration changes.
RecursiveCharacterTextSplitter immutably memorizes chunk size
Labels: name: area: vector store, name: auto:bug, name: integration: chroma

### System Info

The code snipped will execute. However, when changing the chunk size down, executing again, and then changing the chunk size up again, the chunk size will stay on the low value.
It seems that the chunk size is sometimes saved, even though the objects get ge-instantiated.
I ran the code snipped in a colab file.

versions:
chromadb-0.4.10-py3-none-any.whl
langchain-0.0.291-py3-none-any.whl



### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction


```
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma

doc =  Document(page_content=pdf_texts[0][1], metadata={})

def storeDocument(doc):
  text_splitter4 = RecursiveCharacterTextSplitter(chunk_size = 400, chunk_overlap = 5)
  all_splits4 = text_splitter4.split_documents([doc])

  vectorStore = Chroma.from_documents(documents=all_splits4, embedding=OpenAIEmbeddings(openai_api_key="..."))

  return vectorStore


storeDocument(doc).similarity_search_with_score("Where is the fund's geographic location?",k=10)
```

### Expected behavior

I would expect the chunk size to change the output of similarity matching.
Milvus - Pymilvus insert is not offering partition_name as optional argument
Labels: name: area: vector store, name: auto:improvement

### Feature request

When calling from_documents directly from vectorstore I do this:
```
vector_db = Milvus.from_documents(
        docs,
        embeddings,
        connection_args={
            "host": config.MILVUS_HOST,
            "port": config.MILVUS_PORT,
        },
        collection_name = collection_name,
        
    )
```
This argument is not accepted: 
 
`partition_name = 'tes'`
  
If you deep dive inside the `from_documents` to `from_text` in `milvus.py` you notice that uses `add_texts` method, which also is not accepting `partition_name`. This uses the `add_texts` uses `collection.py` - insert from pymilvus orm that does accept `partition_name` as an optional argument:
```
def insert(
        self,
        data: Union[List, pd.DataFrame, Dict],
        partition_name: Optional[str] = None,
        timeout: Optional[float] = None,
        **kwargs,
    ) -> MutationResult:`
    ``

### Motivation

Having a way of inserting directly in a partition from langchain to Milvus 

### Your contribution

To add the "partition_name" attribute as optional in the from_documents somehow
MapRerankDocumentsChain UserWarning & ValueError
Labels: name: auto:bug, name: area: models

### System Info

langchain==0.0.292
OS Windows10
Python 3.11

### Who can help?

Probably  @hwchase17 @agola11


### Information

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

### Related Components

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

### Reproduction

Example code for Q/A chain with "Map Re-Rank" following the official tutorials:

```
precise_chat_model = ChatOpenAI(
    model_name='gpt-3.5-turbo',
    temperature=0,
    openai_api_key=OPENAI_API_KEY
)
qa_chain: MapRerankDocumentsChain = load_qa_chain(
    llm=precise_chat_model,
    chain_type='map_rerank',
    verbose=True,
    return_intermediate_steps=True
)
question = 'Question'
query = {'input_documents': pages,  'question': question}
answer = qa_chain(query, return_only_outputs=False)
```
Full example with PDF that raises Exception all the time: https://gist.github.com/ton77v/eb5b90e72b1652ebccee86ac80b1e01f

Every time I use this chain with any page the UserWarning appears:
```
UserWarning: The apply_and_parse method is deprecated, instead pass an output parser directly to LLMChain.
```

And for the specific documents (usually when 10+ pages) the ValueError is raised upon finishing the chain.
* Gist above raises this error all the time!

```
File "...site-packages\langchain\output_parsers\regex.py", line 35, in parse
raise ValueError(f"Could not parse output: {text}")
ValueError: Could not parse output: Code execution in Ethereum....
```




### Expected behavior

I expect to get an answer without any Exceptions and Warnings
CHAT_CONVERSATIONAL_REACT_AGENT never uses more than 1 tool per turn. 
Labels: name: area: agent, name: auto:bug, name: auto:question, name: area: models

### Issue you'd like to raise.

The effect of tools with return_direct=False for CHAT_CONVERSATIONAL_REACT_AGENT only causes the LLM to generate a final answer based on tool observation, but never in another tool invocation.
The same is not happening with CONVERSATIONAL_REACT_AGENT which seems able to generate new tool queries after the first one.

Is this a feature that can be fixed simply acting on the agent policy prompt, or is there a better way to enable such feature?
Thank you very much.

### Suggestion:

_No response_
database -> db in from_llm
Labels: name: lgtm, name: auto:nit

**Description:** Renamed argument `database` in `SQLDatabaseSequentialChain.from_llm()` to `db`, 

I realize it's tiny and a bit of a nitpick but for consistency with SQLDatabaseChain (and all the others actually) I thought it should be renamed.  Also got me while working and using it today.

:heavy_check_mark:  Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.
AzureOpenAI is missing
Labels: name: area: embeddings, name: auto:bug, name: area: models

### System Info

Hello,
I noticed that the `AzureOpenAI` is missing from the latest release. Now we kind of have to create our own custom class. Is this the direction of the project? 

Thank you 



### Who can help?

_No response_

### Information

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

### Related Components

- [X] 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.llms import AzureOpenAI

no logner availiable 

no possibility to add engine or deployment id, nor the possibility to add extra headers 

### Expected behavior

from langchain.llms import AzureOpenAI

os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"

embeddings = OpenAIEmbeddings(deployment="your-embeddings-deployment-name")
OpenAI function calling docstring and notebook imports
Labels: name: auto:documentation

This PR is a documentation fix.

Description:
* fixes imports in the code samples in the docstrings of `create_openai_fn_chain` and `create_structured_output_chain`
* fixes imports in `docs/extras/modules/chains/how_to/openai_functions.ipynb`
* removes unused imports from the notebook

Issues:
* the docstrings use `from pydantic_v1 import BaseModel, Field` which this PR changes to `from langchain.pydantic_v1 import BaseModel, Field`
* importing `pydantic` instead of `langchain.pydantic_v1` leads to errors later in the notebook
Add ClickUp Toolkit
Labels: name: area: agent, name: lgtm, name: auto:enhancement

- **Description:** Adds a toolkit to interact with the [ClickUp](https://clickup.com/) [Public API](https://clickup.com/api/) 
- **Dependencies:** None
- **Tag maintainer:** @rodrigo-georgian, @rodrigo-clickup, @aiswaryasankarwork
- **Twitter handle:** 
   - Aiswarya (https://twitter.com/Aiswarya_Sankar, https://www.linkedin.com/in/sankaraiswarya/)
   - Rodrigo (https://www.linkedin.com/in/rodrigo-ceballos-lentini/)

Pre-reqs:
- [x] format
- [x] linting
- [x] tests

New Integration Checks:
- [x] Integration Tests
- [x] Example Notebook
Kay retriever
Labels: name: lgtm, name: auto:enhancement

- **Description**: Adding retrievers for [kay.ai](https://kay.ai) and SEC filings powered by Kay and Cybersyn. Kay provides context as a service: it's an API built for RAG.
- **Issue**: N/A
- **Dependencies**: Just added a dep to the [kay](https://pypi.org/project/kay/) package
- **Tag maintainer**: @baskaryan @hwchase17 Discussed in slack
- **Twtter handle:** [@vishalrohra_](https://twitter.com/vishalrohra_)
use cases sidebar nit
Labels: name: auto:documentation

<!-- 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/hwchase17/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 feature for extracting images from pdf and recognizing text from images. 
Labels: name: lgtm, name: area: doc loader, 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/hwchase17/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**

It is for #10423 that it will be a useful feature if we can extract images from pdf and recognize text on them. I have implemented it with `PyPDFLoader`, `PyPDFium2Loader`,  `PyPDFDirectoryLoader`, `PyMuPDFLoader`, `PDFMinerLoader`, and `PDFPlumberLoader`.  [RapidOCR](https://github.com/RapidAI/RapidOCR.git) is used to recognize text on extracted images.  It is time-consuming for ocr so a boolen parameter `extract_images` is set to control whether to extract and recognize. I have tested the time usage for each parser on my own laptop thinkbook 14+ with AMD R7-6800H by unit test and the result is:

| extract_images  | PyPDFParser | PDFMinerParser | PyMuPDFParser | PyPDFium2Parser | PDFPlumberParser |
| ------------- | ------------- | ------------- | ------------- | ------------- | ------------- |
| False | 0.27s | 0.39s | 0.06s | 0.08s | 1.01s |
| True  | 17.01s  | 20.67s | 20.32s | 19,75s | 20.55s |

**Issue**

#10423 

**Dependencies**

rapidocr_onnxruntime in [RapidOCR](https://github.com/RapidAI/RapidOCR/tree/main)
PydanticOutputParser doc nb: use langchain.pydantic_v1; remove unused imports
Labels: name: auto:improvement

Description: This PR changes the import section of the `PydanticOutputParser` notebook.
* Import from `langchain.pydantic_v1` instead of `pydantic`
* Remove unused imports

Issue: running the notebook as written, when pydantic v2 is installed, results in the following:
```python
PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
```
[...]
```python
PydanticUserError: The `field` and `config` parameters are not available in Pydantic V2, please use the `info` parameter instead.

For further information visit https://errors.pydantic.dev/2.3/u/validator-field-config-info
```
Add integration for Timescale Vector(Postgres)
Labels: name: lgtm, name: area: vector store, name: auto:enhancement

**Description:**
This commit adds a vector store for the Postgres-based vector database (`TimescaleVector`).

Timescale Vector(https://www.timescale.com/ai) is PostgreSQL++ for AI applications. It enables you to efficiently store and query billions of vector embeddings in `PostgreSQL`:
- Enhances `pgvector` with faster and more accurate similarity search on 1B+ vectors via DiskANN inspired indexing algorithm.
- Enables fast time-based vector search via automatic time-based partitioning and indexing.
- Provides a familiar SQL interface for querying vector embeddings and relational data.

Timescale Vector scales with you from POC to production:
- Simplifies operations by enabling you to store relational metadata, vector embeddings, and time-series data in a single database.
- Benefits from rock-solid PostgreSQL foundation with enterprise-grade feature liked streaming backups and replication, high-availability and row-level security.
- Enables a worry-free experience with enterprise-grade security and compliance.

Timescale Vector is available on Timescale, the cloud PostgreSQL platform. (There is no self-hosted version at this time.) LangChain users get a 90-day free trial for Timescale Vector.

<!-- 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/hwchase17/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.
 -->
Pass HuggingFacePipeline kwargs on inference
Labels: name: auto:improvement, name: area: models

**Description:**

Pass HuggingFacePipeline kwargs at inference, not just when it's instantiated, so that changing the arguments of the pipeline would actually affect the result, e.g.
```python
from langchain import HuggingFacePipeline

pipe = HuggingFacePipeline.from_model_id(
    task="text-generation",
    device=1,
    model_id="meta-llama/Llama-2-7b-chat-hf",
    pipeline_kwargs={
        'max_length': 100,
        'temperature': 0.1
    },
)

pipe('hello, how are you?')  # this can return up to 100 tokens w temperature 0.1

pipe.pipeline_kwargs['temperature'] = 0.9
pipe.pipeline_kwargs['max_length'] = 50
pipe('hello, how are you?')  # this can return up to 50 tokens w temperature 0.9
```
**Issue:**
None
**Dependencies:**
None 
**Tag maintainer:**
None
**Twitter handle:**
None