delayedkarma/langchain-issues huggingface dataset:
Add client params to aleph alpha (llm and embedding)
Labels: name: lgtm, name: area: embeddings, name: auto:improvement

To make it easier to use aleph alpha models via Langchain, we added the client params to the constructor. This is especially useful for our on-premise users who need to specify the host address.

Also, we updated the default versions of the params so they are consistent with our [API](https://docs.aleph-alpha.com/api/semantic-embed/)
WIP: Weaviate MMR search to support fetch_k greater than amount of docs
Labels: name: area: vector store, name: auto:bug

  - Description: Currently, when searching the weaviate vector db with a fetch_k parameter greater than the amount of docs, an error is thrown, 
  - Issue: #7829 
  - Dependencies: -,
  - Tag maintainer: -,
  - Twitter handle: -

Maintainer(s):
  - VectorStores rlancemartin, eyurtsev
Weaviate MMR Search fails with too high fetch_k parameter 
Labels: name: area: vector store, name: auto:bug

### System Info

Using requirements:
* langchain==0.0.234
* weaviate-client==3.22.1

### 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

The error occurs, when there are less documents stored in weaviate than trying to use with the fetch_k parameter. Otherwise, this will lead to the following error:

>   File "...\Lib\site-packages\langchain\vectorstores\weaviate.py", line 273, in max_marginal_relevance_search
    return self.max_marginal_relevance_search_by_vector(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\Lib\site-packages\langchain\vectorstores\weaviate.py", line 324, in max_marginal_relevance_search_by_vector
    docs.append(Document(page_content=text, metadata=meta))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\Lib\site-packages\langchain\load\serializable.py", line 74, in __init__
    super().__init__(**kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pydantic\main.py", line 341, in pydantic.main.BaseModel.__init__pydantic.error_wrappers.ValidationError: 1 validation error for Document page_content 
  none is not an allowed value (type=type_error.none.not_allowed)
  
Example code for reproduction:
See integration test in fork: https://github.com/yannickulmrich/langchain-issue-7829/commit/a3fea1d08a7e55894ee18099bd5f5751aecf9159


### Expected behavior

I expect the vectorstore to not fail, when the fetch_k parameter is higher, than the amount of Documents in the vector db.
Especially since the default value of the fetch_k parameter is set to 20, this can lead to a lot of unwanted errors, when trying to use the vector db for the first time with few documents to test the behaviour.
Chroma and  Milvus  be larger than 10
Labels: name: area: vector store, name: auto:bug

### System Info

vector_store = Milvus.from_documents(
    text,
    embedding=das_embedding,
    connection_args={"host": MILVUS_HOST, "port": MILVUS_PORT}
)


ValueError: status_code: 400 
 code: InvalidParameter 
 message: batch size is invalid, it should not be larger than 10.: payload.input.contents
 

text[:10]满足，其他不行


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

from langchain.vectorstores import Milvus
vector_store = Milvus.from_documents(
    text,
    embedding=das_embedding,
    connection_args={"host": MILVUS_HOST, "port": MILVUS_PORT}
)

### Expected behavior

ValueError: status_code: 400 
 code: InvalidParameter 
 message: batch size is invalid, it should not be larger than 10.: payload.input.contents
 
这个限制性条件10条怎么改
docs: Improve ApifyDatasetLoader docstring
Labels: name: area: doc loader, name: auto:documentation

I noticed the `ApifyDatasetLoader` is lacking a code example in the docstring. I'm adding it along with a link to Apify's docs about langchain integration to improve developer experience.

PS: I'd be happy to update the search in https://integrations.langchain.com/ to also consider the description, not just the title. But AFAIK the source code for the page is not public, right?
Cannot set up dev container because of Poetry solving dependencies forever
Labels: name: auto:bug

### System Info

OS: Ubuntu 22.04
Docker version: Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3
VSCode: 1.69.0

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

Steps to reproduce the behavior:

1. Go to this documentation page: https://github.com/hwchase17/langchain/tree/master/.devcontainer
2. Click the "Dev Containers Open" button
3. The dev image build is stuck at the last step (Poetry dependencies installation).

When making the Poetry more verbose, it appears that it loops forever on dependencies, like this:

```
   8: derived: pytz-deprecation-shim
   8: fact: pytz-deprecation-shim (0.1.0.post0) depends on tzdata (*)
   8: fact: pytz-deprecation-shim (0.1.0.post0) depends on backports.zoneinfo (*)
   8: selecting pytz-deprecation-shim (0.1.0.post0)
   8: fact: tensorflow-hub (0.14.0) depends on numpy (>=1.12.0)
   8: fact: tensorflow-hub (0.14.0) depends on protobuf (>=3.19.6)
   8: selecting tensorflow-hub (0.14.0)
   8: selecting termcolor (2.3.0)
   8: fact: watchfiles (0.19.0) depends on anyio (>=3.0.0)
   8: selecting watchfiles (0.19.0)
   8: selecting pathspec (0.11.1)
   8: fact: grpcio-reflection (1.47.5) depends on protobuf (>=3.12.0)
   8: fact: grpcio-reflection (1.47.5) depends on grpcio (>=1.47.5)
   8: selecting grpcio-reflection (1.47.5)
   8: selecting iniconfig (2.0.0)
   8: fact: pycares (4.3.0) depends on cffi (>=1.5.0)
   8: selecting pycares (4.3.0)
   8: derived: cffi (>=1.5.0)
   8: selecting colored (1.4.4)
   8: fact: azure-core (1.28.0) depends on requests (>=2.18.4)
   8: fact: azure-core (1.28.0) depends on six (>=1.11.0)
   8: fact: azure-core (1.28.0) depends on typing-extensions (>=4.3.0)
 ```

I even tried to wait for 5 hours, but it was not enough (my internet connection works correctly).

### Expected behavior

The dev container environment should be up and ready in a couple of minutes.
How to use multiple tags in metadata filtering
Labels: name: area: vector store, name: auto:question

### Issue you'd like to raise.

I am using below chain. I want to use multiple categories in the filters. My logic is to bring the results from category=c1 OR category=c2 OR category=c3. How can we modify below code the achieve the objective

`chain = ConversationalRetrievalChain.from_llm(OpenAI(temperature=0),  retriever= vectorstore.as_retriever(search_kwargs={'filter': {'category':category}}), memory=memory, return_source_documents = True) `

### Suggestion:

_No response_
DOC: SupabaseVectorStore.from_documents read operation timed out.
Labels: name: area: vector store, name: auto:question, name: auto:documentation

### Issue with current documentation:

```
# We're using the default `documents` table here. You can modify this by passing in a `table_name` argument to the `from_documents` method.
vector_store = SupabaseVectorStore.from_documents(docs, embeddings, client=supabase)
```

### Idea or request for content:

throw error: httpx.ReadTimeout: The read operation timed out

Is it because the documents are too large? Is there a way to change the timeout?
DOC: Azure Cognitive Search Vector Store
Labels: name: area: vector store, name: auto:question, name: auto:documentation

### Issue with current documentation:

https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/azuresearch

### Idea or request for content:

Can anyone explain more about how to create the index?
If your run the example you get: 
`ResourceNotFoundError: () The index 'langchain-vector-demo' for service 'cognitivesearchitest' was not found.
`
I split docs and add title to metadata, so now, my documents are **_page_content_** and **_metadata_**(source, title, start_index)
Do I need to manually create the  'cognitivesearchitest' index with what fields? Only with id and then the index is updated when inserting the docs?

Regards.
Add option to embed documents without tokenizing using OpenAI interface
Labels: name: area: embeddings, name: auto:improvement

This PR updates `embedding_ctx_length` to be optional. If this value is nil, we will perform a batched call to `embed_with_retry` without tokenizing the text. If it is not nil, we will call `_get_len_safe_embeddings` as per usual. This allows us to use the OpenAI interface for embedding documents without having to rely on the OpenAI model tokenizers.
minor langsmith notebook fixes
Labels: name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this 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!

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Azure Cognitive Search
Labels: name: area: vector store, name: auto:bug

### System Info

...

### 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
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I am trying to use vector search as shown below:

`os.environ["AZURESEARCH_FIELDS_CONTENT_VECTOR"] = "section_summary_vector"
os.environ["AZURESEARCH_FIELDS_CONTENT"] = "section_of_summary"

docs = vector_store.similarity_search(
    query="What did the president say about Ketanji Brown Jackson",
    k=3,
    engine = "gpt35turbo",
    search_type="similarity"
)
print(docs[0].page_content)`

I am getting an error saying: 

HttpResponseError: () Unknown field 'content_vector' in vector field list.
Parameter name: vectorFields
Code: 
Message: Unknown field 'content_vector' in vector field list.
Parameter name: vectorFields

It seems that the custom vector field and is not being used by the function.

### Expected behavior

Be able to customize the vector field to use in doing vector similarity search.
add filter to sklearn vector store functions
Labels: name: area: vector store, name: auto:improvement

# What
- This is to add filter option to sklearn vectore store functions

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: Add filter to sklearn vectore store functions.
  - Issue: None
  - Dependencies: None
  - Tag maintainer: @baskaryan
  - Twitter handle: @MlopsJ

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
docs(zilliz): connection_args add token description for serverless cl…
Labels: name: lgtm, name: area: vector store, name: auto:documentation

Description:

Currently, Zilliz only support dedicated clusters using a pair of username and password for connection. Regarding serverless clusters, they can connect to them by using API keys( [ see official note detail](https://docs.zilliz.com/docs/manage-cluster-credentials)), so I add API key(token) description in Zilliz docs to make it more obvious and convenient for this group of users to better utilize Zilliz. No changes done to code.

Maintainer:
@baskaryan
Add/test faiss
Labels: name: area: vector store, name: auto:improvement

# What
- Add missing test cases to faiss vectore stores

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: add missing tests to faiss vectore stores
  - Issue: None
  - Dependencies: None
  - Tag maintainer: @baskaryan
  - Twitter handle: @MlopsJ

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
add serializer methods
Labels: name: area: vector store, name: auto:improvement

Added serialize and deserialize methods in faiss vectorstore. there was a method called save_local method but instead of saving the file to local disk, I wanted it in the format so that i can save in the SQL database in Blob field. I used this method while i was working on something.

i wanted to add tests and add to documentation but make is not working ..... see #6182 

@rlancemartin @eyurtsev
vectorstores Chroma client_settings anonymized_telemetry=False dont work
Labels: name: area: vector store, name: auto:bug

### System Info

0.0.234 MacOS Big Sur

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

### Reproduction

Create a vectorstore with some documents

Try this code to retrieve the documents

`
from chromadb.config import Settings
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma

embeddings = OpenAIEmbeddings()

vectorstore = Chroma(
    collection_name="langchain_store",
    embedding_function=embeddings,
    client_settings=Settings(anonymized_telemetry=False),
    persist_directory="./dist/vectordb",
)
retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
docs = retriever.get_relevant_documents("quantos litros de oleo vai no motor?")
print(docs)`

The result is [] no documents 

Now if I change the client_settings parameter to 
client_settings=Settings(anonymized_telemetry=False, chroma_db_impl="duckdb+parquet", persist_directory="./dist/vectordb"),

I get the results correct

### Expected behavior

Should be able to set 
client_settings=Settings(anonymized_telemetry=False) # to disable telemetry 
and receive the results back from the vectorstore
Confluence loader usage of id causes a conflict with Weaviate
Labels: name: area: embeddings, name: area: doc loader, name: area: vector store, name: auto:bug

### System Info

Langchain Version 0.0.233

### Who can help?

_No response_

### Information

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

### Related Components

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

Embed from the confluence loader documents direct to weaviate.from_documents and you will get errors related to the id. (e.g.: {'error': [{'message': "'id' is a reserved property name, no such prop with name 'id' found in class 'LangChain_96f9046045fd4623acec34b0ee6acebb' in the schema. Check your schema files for which properties in this class are available"}]}_

**** Code to reproduce ****

from langchain.document_loaders import ConfluenceLoader

loader = ConfluenceLoader(url="https://yoursite.atlassian.com/wiki", token="12345")
documents = loader.load(
    space_key="SPACE", include_attachments=True, limit=50, max_pages=50
)

text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

embeddings = OpenAIEmbeddings()

db = Weaviate.from_documents(docs, embeddings, weaviate_url=WEAVIATE_URL, by_text=False)


I can fix it by creating a new list with documents that have pageid instead of id in metadata:

new_documents = []
for doc in documents:
    metadata = doc.metadata.copy()  
    metadata['pageid'] = metadata.pop('id') 
    new_doc = Document(page_content=doc.page_content, metadata=metadata)  
    new_documents.append(new_doc) 

and then continue with :

db = Weaviate.from_documents(docs, embeddings, weaviate_url=WEAVIATE_URL, by_text=False)


### Expected behavior

Documents to get embedded without the error of:  {'error': [{'message': "'id' is a reserved property name, no such prop with name 'id' found in class 'LangChain_96f9046045fd4623acec34b0ee6acebb' in the schema. Check your schema files for which properties in this class are available"}]}
Bm25 retriever without specific vector store dependency
Labels: name: area: vector store, name: auto:enhancement

<!-- Thank you for contributing to LangChain!

Replace this 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!

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
### Description

This PR aims to enhance the flexibility of retrievers by creating a new BM25 retriever that doesn't depend on a vector store backend. The current [ElasticSearchBM25Retriever](https://github.com/hwchase17/langchain/blob/c58d35765daa063b87733e006a4d65e2e1f388d3/langchain/retrievers/elastic_search_bm25.py) is limited to ElasticSearch, but this new retriever can be used with more flexibility. The BM25 implementation used in this retriever is based on [Gensim](https://github.com/RaRe-Technologies/gensim/blob/3ae286ee7970ab5ffebfcb2ea383e1bf4b5f0b8b/gensim/models/bm25model.py), which is widely used in many applications. With this new retriever, users can now utilize BM25 retrieval without being tied to a specific backend.

### Dependencies
[Gensim](https://github.com/RaRe-Technologies/gensim)

@rlancemartin, @eyurtsev
Nc/protocol
Labels: name: auto:improvement

Objects implementing Runnable: BasePromptTemplate, LLM, ChatModel, Chain, Retriever, OutputParser

- [x] Implement Runnable in base Retriever
- [x] Raise TypeError in operator methods for unsupported things 
- [x] Implement dict which calls values in parallel and outputs dict with results 
- [x] Merge in `+` for prompts
- [x] Confirm precedence order for operators, ideal would be `+` `|`, https://docs.python.org/3/reference/expressions.html#operator-precedence
- [x] Add support for openai functions, ie. Chat Models must return messages
  - [x] Implement BaseMessageChunk return type for BaseChatModel, a subclass of BaseMessage which implements __add__ to return BaseMessageChunk, concatenating all str args
  - [x] Update implementation of stream/astream for llm and chat models to use new `_stream`, `_astream` optional methods, with default implementation in base class `raise NotImplementedError` use https://stackoverflow.com/a/59762827 to see if it is implemented in base class
  - [x] Delete the IteratorCallbackHandler (leave the async one because people using)
  - [x] Make BaseLLMOutputParser implement Runnable, accepting either str or BaseMessage

For a future PR:
- [ ] Implement Runnable in BaseTool
- [ ] Export some openai function utils?
- [ ] Add `functions` and `function_call` args to chatopenai