delayedkarma/langchain-issues huggingface dataset:
Using batches for update document with a new function in ChromaDB
Labels: name: area: vector store, name: auto:improvement

https://github.com/hwchase17/langchain/blob/2a4b32dee24c22159805f643b87eece107224951/langchain/vectorstores/chroma.py#L355-L375

Currently, the defined update_document function only takes a single document and its ID for updating. However, Chroma can update multiple documents by taking a list of IDs and documents for batch updates. If we update 'update_document' function both document_id and document can be `Union[str, List[str]]` but we need to do type check. Because embed_documents and update functions takes List for text and document_ids variables. I believe that, writing a new function is the best option.

I update the Chroma vectorstore with refreshed information from my website every 20 minutes. Updating the update_document function to perform simultaneous updates for each changed piece of information would significantly reduce the update time in such use cases. 

For my case I update a total of 8810 chunks. Updating these 8810 individual chunks using the current function takes a total of 8.5 minutes. However, if we process the inputs in batches and update them collectively, all 8810 separate chunks can be updated in just 1 minute. This significantly reduces the time it takes for users of actively used chatbots to access up-to-date information.

I can add an integration test and an example for the documentation for the new update_document_batch function.

@hwchase17 

[berkedilekoglu](https://twitter.com/berkedilekoglu)
docs: New experimental UI for Mendable Search

This PR introduces a new Mendable UI tailored to a better search experience.

We're more closely integrating our traditional search with our AI generation.
With this change, you won't have to tab back and forth between the mendable bot and the keyword search. Both types of search are handled in the same bar. This should make the docs easier to navigate. while still letting users get code generations or AI-summarized answers if they so wish. Also, it should reduce the cost.

Would love to hear your feedback :)

Cc: @dev2049 @hwchase17
Update README.md

change to capital letter

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
GPU Usage with GPT4All Integration

### Issue you'd like to raise.

Hi guys, I'm wanting to use the
llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True)
and know if I can make it use the GPU instead of the CPU.
Specifically the GPT4All integration, I saw that it does not have any parameters that indicate the use of GPUs so I wanted to know if it is possible to use Langchain loading this model "ggml-gpt4all-l13b-snoozy.bin" with the activation of GPUs?
Outside of Langchain I was able to load the model in GPU!

### Suggestion:

_No response_
Added function _list_all_collections() to milvus.py
Labels: name: area: vector store, name: auto:improvement

Added a function to list all the available collections in the connected Milvus database.

Can be useful when users want to get rid of old collections to make space for new collections.

Also, agents can autonomously pick which collection to search in based on the name of the collection without needing users to specify it.

Twitter handle: JacksonZheng_


#### Who can review?

  @hwchase17 - project lead

  VectorStores / Retrievers / Memory
  - @dev2049
Prebuild a dev container image to improve build time

### Feature request

Thanks so much for merging the PR to update the dev container in this repo https://github.com/hwchase17/langchain/pull/6189!

While the dev container now builds and runs successfully, it can take some time to build. One recommendation is for the LangChain team to pre-build an image.

### Motivation

We recommend pre-building images with the tools you need rather than creating and building a container image each time you open your project in a dev container. Using pre-built images will result in a faster container startup, simpler configuration, and allows you to pin to a specific version of tools to improve supply-chain security and avoid potential breaks. You can automate pre-building your image by scheduling the build using a DevOps or continuous integration (CI) service like GitHub Actions.

There's further info in our docs: https://containers.dev/implementors/reference/#prebuilding.

### Your contribution

We're more than happy to answer any questions and would love to hear feedback if you're interested in hosting a pre-built image! On the dev container team side, we're also looking to even better document pre-building: https://github.com/devcontainers/spec/issues/261, which should help as a reference for scenarios like this too.
Set doc_content_chars_max with ArxivLoader

### Issue you'd like to raise.

In order to read all the text of an arxiv article, we want to specify the number of characters that can be read by the ArxivLoader.
Is there a way to achieve this in the current code?

### Suggestion:

If not, we will create a PR that exposes doc_content_chars_max so that it can be specified on the ArxivLoader side.

Thank you!
Update defaults for text splitters
Labels: name: auto:improvement

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
Issue: <Please write a comprehensive title after the 'Issue: ' prefix>

### Issue you'd like to raise.

I try to use this code:

`from langchain.agents import create_csv_agent
from langchain.llms import AzureOpenAI


agent = create_csv_agent(AzureOpenAI(temperature=0,  deployment_name="text-davinci-003"), 'data.csv', sep='|', on_bad_lines='skip', verbose=True)

print(agent.run("how many rows are there?"))`

but when I execute them I obtain a ParserError: 

pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 679, saw 2

but if I try to open the same file with pandas.read_csv function I do not have any error.

Can you help me please?

Thank you


### Suggestion:

_No response_
feat: faiss filter from list
Labels: name: lgtm

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

### Feature

Using FAISS on a retrievalQA task, I found myself wanting to allow in multiple sources. From what I understood, the filter feature takes in a dict of form {key: value} which then will check in the metadata for the exact value linked to that key.
I added some logic to be able to pass a list which will be checked against instead of an exact value. Passing an exact value will also work.

Here's an example of how I could then use it in my own project:

```
    pdfs_to_filter_in = ["file_A", "file_B"]
    filter_dict = {
        "source": [f"source_pdfs/{pdf_name}.pdf" for pdf_name in pdfs_to_filter_in]
    }
    retriever = db.as_retriever()
    retriever.search_kwargs = {"filter": filter_dict}
```

I added an integration test based on the other ones I found in `tests/integration_tests/vectorstores/test_faiss.py` under `test_faiss_with_metadatas_and_list_filter()`.

It doesn't feel like this is worthy of its own notebook or doc, but I'm open to suggestions if needed.


#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
VectorStores related: @dev2049
Minor Grammar Fixes in Docs and Comments
Labels: name: lgtm

<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->

<!-- Remove if not applicable -->

Fixes # (issue)
Just some grammar fixes: I found "retriver" instead of "retriever" in several comments across the documentation and in the comments. I fixed it.

#### Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:
@hwchase17, @agola11, @eyurtsev, @dev2049

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
S3 Directory Loader reads prefix directory as file_path

### System Info

Langchain version: 0.0.190
boto3: 1.26.156
python: 3.11.4
Linux OS

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

### Reproduction

Code:

```
from langchain.document_loaders import S3DirectoryLoader
loader = S3DirectoryLoader("my-bucket", prefix="folder contains document files")
print(loader.load())
```
Error msg:
![image](https://github.com/hwchase17/langchain/assets/25132365/27c749ff-3f47-4add-9643-ac0842c84ea0)

The code to fix is within the for statement of line 29 in s3_directory.py:
```
docs = []
for obj in bucket.objects.filter(Prefix=self.prefix):
       loader = S3FileLoader(self.bucket, obj.key)
       docs.extend(loader.load())
return docs
```

It needs to catch out the prefix path that is the first obj.key in the loop, which is not a file (obj.key) that the S3FileLoader (in s3_file.py) can download. 

A solution could be to bypass any directory/prefix paths and collect only files. 
```
docs = []
for obj in bucket.objects.filter(Prefix=self.prefix):
       if obj.key.endswith("/"):   # bypass the prefix directory
              continue
       else:
              loader = S3FileLoader(self.bucket, obj.key)
              docs.extend(loader.load())
return docs
```


### Expected behavior

I expect the obj.key for S3FileLoader to point to an obj.key that is a file_path e.g. prefix/file_name.docx that will create a temporary file e.g., /tmp/tmp0rlkir33/prefix/file_name.docx and download will be successful into the loader object.
Issue: in "Tool()" seperate the chat models input to "func"

### Issue you'd like to raise.

`realistic_vision_tool = Tool(
    name="realistic_vision_V1.4 image generating",
    func=realistic_vision_v1_4, #would like to pass some params here
    description="""Use when you want to generate an image of something with realistic_vision model. Input like "a dog standing on a rock" is decent for this tool so input not-so-detailed prompts to this tool. If an image is generated, tool will return "Successfully generated image.\". Say something like "Generated. Hope it helps.\" if you use this tool. Always input english prompts for the input, even if the user is not speaking english. Enter the inputs in english to this tool.""",
)`

And i tried to give the chat model params, but it behaived badly

### Suggestion:

maybe you can add a param to isolate some params to the "func". Maybe i dont know the solution or im so dumb.
Keep retrying and writing output to local file in an unstructured way in AutoGPT implemented in LangChain

### System Info

AutoGPT on LangChain implementation has shown bugs in internal steps and file output processing phase. In particular, I noticed occasional inconsistencies within the internal processes of the AutoGPT implementation. These slight hitches, though infrequent, interrupt the seamless flow of operations. Also, in the file output processing phase, the actual data output seems to diverge from the expected format, hinting at a potential misalignment during the conversion or translation stages.
<img width="1003" alt="AutoGPT LangChain Issues Screenshot 1" src="https://github.com/hwchase17/langchain/assets/63427721/d5bc1ecf-35fb-4636-828c-52f8782b8f3d">
<img width="1272" alt="AutoGPT LangChain Issues Screenshot 2" src="https://github.com/hwchase17/langchain/assets/63427721/4d037c55-b572-4c6d-b479-374927c2ec45">
<img width="1552" alt="AutoGPT LangChain Issues Screenshot 3" src="https://github.com/hwchase17/langchain/assets/63427721/fbb82a50-6600-49f4-8a8d-dd075a209893">





### Who can help?

@TransformerJialinWang @alon

### Information

- [ ] The official example notebooks/scripts
- [ ] 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
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

# Define your embedding model
embeddings_model = OpenAIEmbeddings()

# Initialize the vectorstore as empty
import faiss

embedding_size = 1536 #openai embeddings has 1536 dimensions
index = faiss.IndexFlatL2(embedding_size) #Index that stores the full vectors and performs exhaustive search
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {})

agent = AutoGPT.from_llm_and_tools(
    ai_name="Tom",
    ai_role="Assistant",
    tools=tools,
    llm=ChatOpenAI(temperature=0),
    memory=vectorstore.as_retriever()
)
# Set verbose to be true
agent.chain.verbose = True

agent.run(["Recommend 5 best books to read in Python"])

### Expected behavior

The primary goal is to solve the infinite loop in AutoGPT. The minor one is to provide structured output int local file.
fix for 'content' key missing in response from Azure OpenAI instance
Labels: name: auto:bug


<!--
Thank you for contributing to LangChain! Your PR will appear in our release under the title you set. Please make sure it highlights your valuable contribution.

Replace this with a description of the change, the issue it fixes (if applicable), and relevant context. List any dependencies required for this change.

After you're done, someone will review your PR. They may suggest improvements. If no one reviews your PR within a few days, feel free to @-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd like us to shout you out on Twitter, please also include your handle!
-->
It is a fix for issue #6205 , I don't have right now OpenAI endpoint to double check, hence limiting change only to Azure OpenAI part. Also following already existed logic with the ValueError exception, decided not to go for a custom exception

<!-- Remove if not applicable -->

Fixes #6205 

#### Before submitting

<!-- If you're adding a new integration, please include:

See contribution guidelines for more information on how to write tests, lint
etc:

https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->
No new test, very limited change.

#### Who can review?

Tag maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @hwchase17

  VectorStores / Retrievers / Memory
  - @dev2049

 -->

Possible reviewers   @hwchase17 , @agola11
Issue: Changing Prompt (from Default) when Using ConversationalRetrievalChain?

### Issue you'd like to raise.

Hello!

First, thanks a lot for this awesome framework!

My question is: As I was trying out ConversationalRetrievalChain, I see that it has the prompt saying:
"System: Use the following pieces of context to answer the users question. 
If you don't know the answer, just say that you don't know, don't try to make up an answer."

Is there a way for me to change this generic prompt? I'm talking about the prompt that comes with the retriever results, not the "condense_question_prompt". 

I could modify "condense_question_prompt" where the default template is 'Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.\n\nChat History:\n{chat_history}\nFollow Up Input: {question}\nStandalone question:'

The reason I'm asking this is.... as the conversation gets longer (k > 4 or 5), the model start hallucinating. I was expecting it would answer based on the retrieved context every single time. But later conversation tends to go astray. Is there a way to control that behavior, if not through prompts? (still think prompts are the best way....)

Thank you!!

### Suggestion:

_No response_
langchain use AzureOpenai would generate the wrong content

### System Info

langchain version:0.0.207
python version: 3.9.7

When I use the AzureOpenai  llms of Langchain. It doesn't generate the right result according to my prompt.
But when i use the AzureOpenai of openai. It can generate the right result.

langchain's AzureOpenai:
![image](https://github.com/hwchase17/langchain/assets/50695030/673e907f-34fe-4458-9618-3071cfc141f6)

openai AzureOpenai:
![image](https://github.com/hwchase17/langchain/assets/50695030/51e1869f-f593-4fa5-92a5-fbb666c19d63)



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

Here are the code example and the output result
```python
  from langchain.llms import AzureOpenAI
  from langchain.chat_models import ChatOpenAI
  from langchain.prompts import PromptTemplate
  from langchain.chains import LLMChain
  
  def tool_select_chain(azure=True):
      prompt_template = """
      imagine you are a tool selector,
      user input: {input}
      now give the following tool list and tool function description [查询天气, 查询食品, 查询衣服]
      please find the most suitable tool according to the content of the user input and output the tool name.
      the output format is json format, the field is tool.
      tool[查询天气]: used to search the weather 
      tool[查询食品]: used to search the food
      tool[查询衣服]: used to search the clothes
      If you can't find the right tool, output [无]
      just output the tool name with the json format answer:
      """
      PROMPT = PromptTemplate(
          template=prompt_template, input_variables=["input"]
      )
      if not azure:
          llm = ChatOpenAI(temperature=0,
                           model_name='gpt-3.5-turbo-0301',
                           )
      else:
          llm = AzureOpenAI(temperature=0,
                            deployment_name="gpt-35-turbo",
                            model_name='gpt-35-turbo')
  
      chain = LLMChain(llm=llm, prompt=PROMPT)
      return chain
```

### Expected behavior

Find out the reason why this condition appeared and fix this error.
Thank you~