delayedkarma/langchain-issues huggingface dataset:
Multiple values for keyword argument 'embedding_function'
Labels: name: area: embeddings, name: area: vector store, name: auto:bug, name: integration: chroma

### System Info

Running on google colab. 
Everything was working up until today, which makes me think it's openAi update-related.

Versions:
Requirement already satisfied: langchain in /usr/local/lib/python3.10/dist-packages (**0.0.331**)
Requirement already satisfied: chromadb in /usr/local/lib/python3.10/dist-packages (**0.4.16**)
Openai version pinned to 0.28.1 as @hwchase17 recommended prior -- which had fixed my embeddings issue.

### Who can help?

@hwchase17 @agola11 

### Information

- [X] 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

```python3
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings

embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(documents=splits, embedding_function=embeddings, persist_directory='/content/wtf')
vectorstore.persist()
retriever = vectorstore.as_retriever()

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-5-d086aa9b6782>](https://localhost:8080/#) in <cell line: 7>()
      5 
      6 embeddings = OpenAIEmbeddings()
----> 7 vectorstore = Chroma.from_documents(documents=splits, embedding_function=embeddings, persist_directory='/content/wtf')
      8 vectorstore.persist()
      9 retriever = vectorstore.as_retriever()

1 frames
[/usr/local/lib/python3.10/dist-packages/langchain/vectorstores/chroma.py](https://localhost:8080/#) in from_texts(cls, texts, embedding, metadatas, ids, collection_name, persist_directory, client_settings, client, collection_metadata, **kwargs)
    618             Chroma: Chroma vectorstore.
    619         """
--> 620         chroma_collection = cls(
    621             collection_name=collection_name,
    622             embedding_function=embedding,

TypeError: langchain.vectorstores.chroma.Chroma() got multiple values for keyword argument 'embedding_function'

### Expected behavior

It should run without an error and correctly embed the document splits, outputting the data in the persist directory.
No module named 'langserve.packages' when creating langchain-cli apps
Labels: name: auto:bug

### System Info


Windows WSL 2 Ubuntu
Python 3.10.6
langchain-0.0.331 langchain-cli-0.0.15 langserve-0.0.24 langsmith-0.0.60

### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

In a new virtual environment with Python 3.10.6, After running:
`pip install -U "langchain-cli[serve]"`

which installs "langchain-0.0.331 langchain-cli-0.0.15 langserve-0.0.24 langsmith-0.0.60" as shown below:

Successfully installed PyYAML-6.0.1 SQLAlchemy-2.0.23 aiohttp-3.8.6 aiosignal-1.3.1 annotated-types-0.6.0 anyio-3.7.1 async-timeout-4.0.3 attrs-23.1.0 certifi-2023.7.22 charset-normalizer-3.3.2 click-8.1.7 colorama-0.4.6 dataclasses-json-0.6.1 exceptiongroup-1.1.3 fastapi-0.104.1 frozenlist-1.4.0 gitdb-4.0.11 gitpython-3.1.40 greenlet-3.0.1 h11-0.14.0 httpcore-1.0.1 httpx-0.25.1 httpx-sse-0.3.1 idna-3.4 jsonpatch-1.33 jsonpointer-2.4 langchain-0.0.331 langchain-cli-0.0.15 langserve-0.0.24 langsmith-0.0.60 markdown-it-py-3.0.0 marshmallow-3.20.1 mdurl-0.1.2 multidict-6.0.4 mypy-extensions-1.0.0 numpy-1.26.1 packaging-23.2 pydantic-2.4.2 pydantic-core-2.10.1 pygments-2.16.1 requests-2.31.0 rich-13.6.0 shellingham-1.5.4 smmap-5.0.1 sniffio-1.3.0 sse-starlette-1.6.5 starlette-0.27.0 tenacity-8.2.3 tomli-2.0.1 typer-0.9.0 typing-extensions-4.8.0 typing-inspect-0.9.0 urllib3-2.0.7 uvicorn-0.23.2 yarl-1.9.2

I try to run `langchain app new my-app --package rag-conversation`, and get the following error

Traceback (most recent call last):
  File "/home/mert/REPOSITORIES/GenAI/langserve-template/langserve-env/bin/langchain", line 5, in <module>
    from langchain_cli.cli import app
  File "/home/mert/REPOSITORIES/GenAI/langserve-template/langserve-env/lib/python3.10/site-packages/langchain_cli/cli.py", line 6, in <module>
    from langchain_cli.namespaces import app as app_namespace
  File "/home/mert/REPOSITORIES/GenAI/langserve-template/langserve-env/lib/python3.10/site-packages/langchain_cli/namespaces/app.py", line 12, in <module>
    from langserve.packages import get_langserve_export
ModuleNotFoundError: No module named 'langserve.packages'


### Expected behavior

Pulling template into a local repository
refactor: Qdrant async improvements
Labels: name: area: vector store, name: auto:refactor, name: size:L

#### Description:
This PR intends to simplify the async implementation of Qdrant vectorstore using the `AsyncQdrantClient` interface introduced in [`qdrant_client@1.6.2`](https://github.com/qdrant/qdrant-client/releases/tag/v1.6.1).
Issue: UnstructuredExcelLoader 
Labels: name: area: doc loader, name: auto:bug



from langchain.document_loaders import UnstructuredExcelLoader

loader = UnstructuredExcelLoader("example_data/stanley-cups.xlsx", mode="elements")
docs = loader.load()
docs[0]

in the above it gives ouput as 

    Document(page_content='\n  \n    \n      Team\n      Location\n      Stanley Cups\n    \n    \n      Blues\n      STL\n      1\n    \n    \n      Flyers\n      PHI\n      2\n    \n    \n      Maple Leafs\n      TOR\n      13\n    \n  \n', metadata={'source': 'example_data/stanley-cups.xlsx', 'filename': 'stanley-cups.xlsx', 'file_directory': 'example_data', 'filetype': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'page_number': 1, 'page_name': 'Stanley Cups', 'text_as_html': '<table border="1" class="dataframe">\n  <tbody>\n    <tr>\n      <td>Team</td>\n      <td>Location</td>\n      <td>Stanley Cups</td>\n    </tr>\n    <tr>\n      <td>Blues</td>\n      <td>STL</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <td>Flyers</td>\n      <td>PHI</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <td>Maple Leafs</td>\n      <td>TOR</td>\n      <td>13</td>\n    </tr>\n  </tbody>\n</table>', 'category': 'Table'})
    
    when i pass the above to CharacterTextSplitter, it gives error because it expects in the different format.
     text_splitter = CharacterTextSplitter(chunk_overlap=0, chunk_size=1000)
     texts = text_splitter.split_documents(docs[0])
     
     

### Suggestion:

_No response_
看了新的OpenAI开发者大会，langchain还有存在的必要吗
Labels: name: auto:question

### Issue you'd like to raise.

新的chatgpt可以直接帮助人类分析，规划，似乎已经脱离了原本的软件开发模式，从人设计，到了ai设计了，langchain是不是已经过时了？

### Suggestion:

_No response_
help: github util `comment_on_issue` unable to parse `action input` from agent
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

I am using github tools along with an agent following example given (https://python.langchain.com/docs/integrations/toolkits/github), but the comment_on_issue tool is not able to parse the Action Input given by agent (the format seems to be same as given in the prompts), there seems to be some issue with escap sequnces.

Action Input: 2\n\nStarting to review docstrings and add sphinx\n\n

Error: ValueError: invalid literal for int() with base 10: '2\n\nStarting to review docstrings and add sphinx\n\n'

I think there might be some issue decoding (extra \ added to newline character). can anyone pls help with this?

### Suggestion:

_No response_
Add Proper Import Error
Labels: name: area: doc loader, name: auto:bug, name: integration: aws

  - **Description:** The issue was not listing the proper import error for amazon textract loader.
  - **Issue:** Time wasted trying to figure out what to install... (langchain docs don't list the dependency either)
  - **Dependencies:** N/A
  - **Tag maintainer:** @sbusso 
  - **Twitter handle:** @h9ste
Add template for conversational rag with timescale vector
Labels: name: lgtm, name: area: vector store, name: auto:enhancement, name: template

**Description:** This is like the rag-conversation template in many ways. What's different is:
- support for a timescale vector store.
- support for time-based filters.
- support for metadata filters.

<!-- 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.
 -->
redirect ls walkthrough
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/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.
 -->
Agent window management how to
Labels: name: area: agent, 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/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.
 -->
Compatibility Issue with OpenAI Python Package (Version 1.1.1)
Labels: name: auto:bug, name: area: models

### Description

Compatibility issue with the Langchain library due to the recent changes in the OpenAI Python package (version 1.1.1). The Langchain library relies on certain structures and imports from the OpenAI package, which have been modified in the new version. Specifically, the issue seems to be related to the following changes:

- In the Langchain code, the error handling imports in [langchain/llms/openai.py](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/llms/openai.py#L83 ) at line 90 were based on the older structure of the OpenAI package. In the newer version, these imports have been restructured and are available in openai._exceptions.

- In [langchain/llms/openai.py](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/llms/openai.py#L240 ) at line 266, values["client"] = openai.Completion is no longer valid in the new version of OpenAI (version 1.1.1).

```
!pip install langchain openai

from langchain import OpenAI
import os

os.environ["OPENAI_API_KEY"] = "key"

llm = OpenAI(
    model_name="text-davinci-003",
    temperature= 0.2, 
    max_tokens= 64,
    openai_api_key=os.environ["OPENAI_API_KEY"],
)
```

![image](https://github.com/langchain-ai/langchain/assets/101416953/4a8c48df-a37b-498b-ac95-c4d7e061fcfb)

Also
![image](https://github.com/langchain-ai/langchain/assets/101416953/de06a0e8-492b-488e-b09a-2189599370d6)

**Note:**
To avoid the above error, users should downgrade the OpenAI package to version 0.28.1.

### 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

!pip install langchain openai

from langchain import OpenAI
import os

os.environ["OPENAI_API_KEY"] = "key"

llm = OpenAI(
    model_name="text-davinci-003",
    temperature= 0.2, 
    max_tokens= 64,
    openai_api_key=os.environ["OPENAI_API_KEY"],
)

### Expected behavior

Langchain should work without errors when using OpenAI version 1.1.1.
Embedding on Multi-GPU
Labels: name: area: embeddings, name: auto:question

### Issue you'd like to raise.

How can I run embedding with "gte-large" on a multi-GPU machine?
Trying per issue #3486
```
model_name = "thenlper/gte-large" 
encode_kwargs = {"normalize_embeddings": True}
model_kwargs = {"device": "cuda", "multi_process":True}


hf = HuggingFaceBgeEmbeddings(
    model_name=model_name,  model_kwargs=model_kwargs, encode_kwargs=encode_kwargs,
)
embedding = hf.embed_query("hi this is harrison")
len(embedding)
```
uses a single GPU
added system prompt and template fields to ollama
Labels: name: lgtm, name: auto:improvement, name: area: models

**Description**
the ollama api now supports passing system prompt and template directly instead of modifying the model file , but the ollama integration in langchain did not have this change updated . The update just adds these two parameters to it ( there are 2 more parameters that are pending to be updated, I was not sure about their utility wrt to langchain )
Refer : https://github.com/jmorganca/ollama/commit/8713ac23a86e1eaf8b94f93bb0d51d13b0225d87

**Issue** : None Applicable

**Dependencies** : None Changed

**Twitter handle** : https://twitter.com/violetto96
Support Pinecone Hybrid Search upsert parallelization
Labels: name: area: vector store, name: auto:improvement, name: integration: pinecone

Issue: closes #13017 

* Add integration tests for Pinecone HybridSearch
* Modify notebook example for Pinecone HybridSearch
* Create an abstraction and factory that handles single thread vs multithread upsert to Pinecone - This can be applied to regular Pinecone upsert in vectorstore package.
* The speed up is 5 times using following settings:
    * `chunk_size=1000`
    * `batch_size=64`
    * `pool_threads=4`
    * BM25 sparse encoder

**Note: Breaking Change!!!** 
Line: https://github.com/langchain-ai/langchain/commit/1e317211a83154f93dd7acb6b3a008a59d594968?diff=split#diff-70d9590693d1256849a37f005de03ac82cf4c1a2f5eb05993b6382227ccf373eR213

In `PineconeHybridSearchRetriever` classes instead of passing Pinecone Index I put a wrapper around it. The reason is to use abstration for handling single-threaded and multi-threaded upsert since they are different and they require different instantiation of `pinecone.Index`. The wrapper class can be obtained by calling `PineconeIndexUpsert.get_index(index_name='index-name', pool_threads=1)`.

The alternative (non breaking approach) would be to pass a flag `is_threaded=True` to `add_texts` method and then instantiate appropriate wrapper object for handling the upsert inside the method. It might happen that someone instantiate pinecone.index without `pool_threads` and then calls `add_texts` with `is_threaded=True` without any significant speed gain. 

I appreciate your feedback and pelase let me know which approach should we take?
Support Pinecone Hybrid Search upsert parallelization
Labels: name: area: embeddings, name: area: vector store, name: auto:improvement, name: integration: pinecone

### Feature request

Feature request
We can take advantage from pinecone parallel upsert (see example: https://docs.pinecone.io/docs/insert-data#sending-upserts-in-parallel)

This will require modification of the current `add_texts` pipeline.

Create a batch (chunk) for doing embeddings (ie have a chunk size of 1000 for embeddings)
Perform a parallel upsert to Pinecone index on that chunk
This way we are in control on 3 things:

* Thread pool for pinecone index
* Parametrize the batch size for embeddings (ie it helps to avoid rate limit for OpenAI embeddings)
* Parametrize the batch size for upsert (it helps to avoid throttling of pinecone API)

Similar to the #9855 

One additional requirement is to set `flag` for single threaded vs multithreaded upsert implementation.

### Motivation

The function `add_texts` for index upsert doesn't take advantage of parallelism especially when embeddings are calculated by HTTP calls (ie OpenAI embeddings). This makes the whole sequence inefficient from IO bound standpoint as the pipeline is following:

* Take a small batch ie 32/64 of documents
* Calculate embeddings --> WAIT
* Upsert a batch --> WAIT

We can benefit from using paralellised upsert.

### Your contribution

I will do it.
Demonstrate use of get_buffer_string
Labels: name: lgtm, name: area: doc loader, name: auto:documentation, name: size:L

**Description**

The docs for creating a RAG chain with Memory [currently use a manual lambda](https://python.langchain.com/docs/expression_language/cookbook/retrieval#with-memory-and-returning-source-documents) to format chat history messages. [There exists a helper method within the codebase](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/schema/messages.py#L14C15-L14C15) to perform this task so I've updated the documentation to demonstrate its usage

Also worth noting that the current documented method of using the included `_format_chat_history ` function actually results in an error:

```
TypeError: 'HumanMessage' object is not subscriptable
```
Issue: Sources are lost in the final_answer by agents
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

I have a STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION agent which uses a QA (retreival based) tool to answer questions. The QA tool returns references in the response. However the final answer provided by the agent is missing the sources. What can I do to ensure that sources are provided in the final_answer?



### Suggestion:

_No response_
Bagatur/oai assistant
Labels: name: auto:enhancement, name: area: models

<!-- 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.
 -->
Max Characters doesn't increase when value is updated 
Labels: name: auto:bug, name: area: models

### System Info

https://python.langchain.com/docs/integrations/llms/huggingface_hub

I followed this documentation and increased max_length. But, It seems like the response max_length not increasing. At max, I would get the response text with 110 characters. Please help me to fix my issue

<img width="528" alt="image" src="https://github.com/langchain-ai/langchain/assets/68229944/7d47b36c-21f4-42df-bf0f-48a4f6f03a5a">


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

1. install dependencies and use the template code in the above link and screenshot
2. Try to increase the max length and check whether increasing max_length is refelecting in the response.

### Expected behavior

increasing max_length isn't reflecting. This value should enable to increase the generated response text length.