delayedkarma/langchain-issues huggingface dataset:
Issue: Unable to add a unit test for experimental modules
Labels: name: auto:bug

Adding a unit test for any experimental module in the standard location, such as `tests/unit_tests/experimental/test_baby_agi.py`, leads to this failing unit test:

```python
../tests/unit_tests/output_parsers/test_base_output_parser.py ...................................F
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    def test_all_subclasses_implement_unique_type() -> None:
        types = defaultdict(list)
        for cls in _NON_ABSTRACT_PARSERS:
            try:
                types[cls._type].append(cls.__name__)
            except NotImplementedError:
                # This is handled in the previous test
                pass
        dups = {t: names for t, names in types.items() if len(names) > 1}
>       assert not dups, f"Duplicate types: {dups}"
E       AssertionError: Duplicate types: {<property object at 0xffff9126e7f0>: ['EnumOutputParser', 'AutoGPTOutputParser', 'NoOutputParser', 'StructuredQueryOutputParser', 'PlanningOutputParser'], <property object at 0xffff7f331710>: ['PydanticOutputParser', 'LineListOutputParser']}
E       assert not {<property object at 0xffff9126e7f0>: ['EnumOutputParser', 'AutoGPTOutputParser', 'NoOutputParser', 'StructuredQueryOu...arser', 'PlanningOutputParser'], <property object at 0xffff7f331710>: ['PydanticOutputParser', 'LineListOutputParser']}

../tests/unit_tests/output_parsers/test_base_output_parser.py:55: AssertionError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB post_mortem >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /workspaces/tests/unit_tests/output_parsers/test_base_output_parser.py(55)test_all_subclasses_implement_unique_type()
-> assert not dups, f"Duplicate types: {dups}"
```

[Repro is here](https://github.com/borisdev/langchain/pull/12) and [artifact here](https://github.com/borisdev/langchain/actions/runs/5502599425/jobs/10026958854?pr=12).
DOC: Table creation for Supabase (Postgres) has incorrect type
Labels: name: auto:documentation

### Issue with current documentation:

https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/supabase
Under  '-- Create a table to store your documents' the id column is set to big serial but it is referenced later as uuid 10 lines down when creating the function

### Idea or request for content:

It is currently
`id bigserial primary key,`
Changing it to this fixed the error I was getting
'id uuid primary key,'
Add ZepMemory; improve ZepChatMessageHistory handling of metadata; Fix bugs
Labels: name: auto:improvement, name: auto:documentation

Hey @hwchase17 - 

This PR adds a `ZepMemory` class, improves handling of Zep's message metadata, and makes it easier for folks building custom chains to persist metadata alongside their chat history.

We've had plenty confused users unfamiliar with ChatMessageHistory classes and how to wrap the `ZepChatMessageHistory` in a `ConversationBufferMemory`. So we've created the `ZepMemory` class as a light wrapper for `ZepChatMessageHistory`.

Details:
- add ZepMemory, modify notebook to demo use of ZepMemory
- Modify summary to be SystemMessage
- add metadata argument to add_message; add Zep metadata to Message.additional_kwargs
- support passing in metadata
Add spacy sentencizer
Labels: name: auto:improvement

`SpacyTextSplitter` currently uses spacy's statistics-based `en_core_web_sm` model for sentence splitting. This is a good splitter, but it's also pretty slow, and in this case it's doing a lot of work that's not needed given that the spacy parse is then just thrown away.
However, there is also a simple rules-based spacy sentencizer. Using this is at least an order of magnitude faster than using `en_core_web_sm` according to my local tests.
Also, spacy sentence tokenization based on `en_core_web_sm` can be sped up in this case by not doing the NER stage. This shaves some cycles too, both when loading the model and when parsing the text.

Consequently, this PR adds the option to use the basic spacy sentencizer, and it disables the NER stage for the current approach, *which is kept as the default*.

Lastly, when extracting the tokenized sentences, the `text` attribute is called directly instead of doing the string conversion, which is IMO a bit more idiomatic.

@baskaryan
fix SQL toolkit table listing tool name
Labels: name: auto:bug, name: auto:documentation

- Description: This PR fixes the erroneous naming convention of the `list_tables_sql_db` tool used for querying the list of tables present in a database. This is a minor fix which renames all the occurrences of the above tool with the one described in the tool's description.
- Issue: Fixes #7440 
- Dependencies: None
- Maintainer: @hinthornw 
<!-- 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
 -->
list_tables_sql_db is not a valid tool, try another one.
Labels: name: auto:bug

### System Info

langchain: 0.0.215
python: 3.10.11
OS: Ubuntu 18.04

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

### Reproduction

While querying a SQL database, the agent gets stuck in an infinite loop due to `list_tables_sql_db` not being a valid tool.

```
> Entering new  chain...
Action: list_tables_sql_db
Action Input: 
Observation: list_tables_sql_db is not a valid tool, try another one.
Thought:I should look at the tables in the database to see what I can query.  Then I should query the schema of the most relevant tables.
Action: list_tables_sql_db
Action Input: 
Observation: list_tables_sql_db is not a valid tool, try another one.
Thought:I should look at the tables in the database to see what I can query.  Then I should query the schema of the most relevant tables.
Action: list_tables_sql_db
Action Input: 
Observation: list_tables_sql_db is not a valid tool, try another one.
Thought:I don't know how to answer this question.
Thought: I now know the final answer
Final Answer: I don't know

> Finished chain.
```

### Expected behavior

The agent should get the list of tables by using the `list_tables_sql_db` tool and then query the most relevant one.
Added function search_documents_by_metadata for Pinecone vectorstore
Labels: name: auto:enhancement

Hi guys,

I've been working on a new feature that I believe could be a great addition to the Langchain project. It's a function designed to simplify document searches based on metadata within Pinecone. The idea is to simply pass in the metadata, and the function will take care of creating the necessary filters for us. You can also give in your own filters.

I realize this might seem a bit abstract without a practical demonstration, so if you think it would be helpful, I'd be more than happy to whip up a Jupyter notebook. 

Please feel free to let me know your thoughts on this, and if there's anything specific you'd like me to cover in the notebook if we decide to go that route.

Thank you for the great work. 

  - Tag maintainer: @rlancemartin @eyurtsev
  - Twitter handle: @ET_TheDev
Have set my langchain+ tracing key, it is not being recognized
Labels: name: auto:bug

### System Info

```
$ uname -a
MINGW64_NT-10.0-19045 LAPTOP-4HTFESLT 3.3.6-341.x86_64 2022-09-05 20:28 UTC x86_64 Msys

$ python --version
Python 3.10.11

$ pip show langchain
Name: langchain
Version: 0.0.228
Summary: Building applications with LLMs through composability
Home-page: https://www.github.com/hwchase17/langchain
Author:
Author-email:
License: MIT
Location: c:\users\happy\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages
Requires: aiohttp, async-timeout, dataclasses-json, langchainplus-sdk, numexpr, numpy, openapi-schema-pydantic, pydantic, PyYAML, requests, SQLAlchemy, tenacity
Required-by:



```

### Who can help?

I cannot get a trace on langchain. Error:
```
File "c:\Users\happy\Documents\Projects\askjane\.venv\lib\site-packages\langchain\callbacks\manager.py", line 1702, in _configure
    logger.warning(
Message: 'Unable to load requested LangChainTracer. To disable this warning, unset the  LANGCHAIN_TRACING_V2 environment variables.'
Arguments: (LangChainPlusUserError('API key must be provided when using hosted LangChain+ API'),)
```
I do this check:
```
print(os.environ["LANGCHAIN-API-KEY"])
```
the correct LangchainPlus/langsmith/langchain api key is shown.  I thought this was how it was done.  I do set the other os envionment variables.

It doesn't pick up my api key.

i apologize if i am doing something stupid. but it's not working to the best of my knowledge.


### Information

- [ ] The official example notebooks/scripts
- [X] 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

import os
os.environ["OPENAI_API_KEY"] = "..."
os.environ["LANGCHAIN-API-KEY"] = "..."
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.langchain.plus"
os.environ["LANGCHAIN_PROJECT"] = "Explore Evaluating index using LLM" 

print(os.environ["LANGCHAIN-API-KEY"])

from langchain import OpenAI
OpenAI().predict("Hello, world!")



### Expected behavior

go to langsmith and see the trace.
feat(module): add param ids to ElasticVectorSearch.from_texts method
Labels: name: auto:improvement

# add param ids to ElasticVectorSearch.from_texts method.

- Description: add param ids to ElasticVectorSearch.from_texts method.
- Issue: NA. It seems `add_texts` already supports passing in document ids, but param `ids` is omitted in `from_texts` classmethod, 
- Dependencies: None,
- Tag maintainer: @rlancemartin, @eyurtsev please have a look, thanks

```
    # ElasticVectorSearch add_texts
    def add_texts(
        self,
        texts: Iterable[str],
        metadatas: Optional[List[dict]] = None,
        refresh_indices: bool = True,
        ids: Optional[List[str]] = None,
        **kwargs: Any,
    ) -> List[str]:
        ...

```

```
    # ElasticVectorSearch from_texts
    @classmethod
    def from_texts(
        cls,
        texts: List[str],
        embedding: Embeddings,
        metadatas: Optional[List[dict]] = None,
        elasticsearch_url: Optional[str] = None,
        index_name: Optional[str] = None,
        refresh_indices: bool = True,
        **kwargs: Any,
    ) -> ElasticVectorSearch:

```

```
    # FAISS from_texts
    @classmethod
    def from_texts(
        cls,
        texts: List[str],
        embedding: Embeddings,
        metadatas: Optional[List[dict]] = None,
        ids: Optional[List[str]] = None,    # ids support    <--
        **kwargs: Any,
    ) -> FAISS:
```



<!-- 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
 -->
SelfQueryRetriever fails if lark is not installed, but the failure message is not meaningful
Labels: name: needs work, name: auto:bug

  - Description: When we execute SelfQueryRetriever, it will fail if lark is not imported. But the failure message is not meaningful. It just says "TypeError: 'NoneType' object is not callable". This change will provide a meaningful message to import lark
  - Issue: N/A
  - Dependencies: None
  - Tag maintainer: @rlancemartin, @eyurtsev
  - Twitter handle: N/A
docs(agents/agent_types): Fix code example in chat_conversation_agent.mdx
Labels: name: auto:documentation

  - Description: Adds missing code to the example so it can be run. Copied from [conversational agent example](https://python.langchain.com/docs/modules/agents/agent_types/chat_conversation_agent.html).
  - Issue: -
  - Dependencies: -
  - Tag maintainer: @baskaryan
  - Twitter handle: @finnless
docs(agents/agent_types) Fix ReAct link index.mdx
Labels: name: auto:documentation

  - Description: Fix ReAct paper link which currently goes to [MRKL](https://arxiv.org/pdf/2205.00445.pdf) paper instead of the [ReAct paper](https://react-lm.github.io/). The [ReAct agent type page](https://python.langchain.com/docs/modules/agents/agent_types/react.html) links to the paper correctly.
  - Issue: -
  - Dependencies: -
  - Tag maintainer: @baskaryan
  - Twitter handle: @finnless
docs(agents/toolkits): Fix error in document_comparison_toolkit.ipynb
Labels: name: lgtm, name: auto:documentation

Replace this comment with:
  - Description: Removes unneeded output warning in documentation at https://python.langchain.com/docs/modules/agents/toolkits/document_comparison_toolkit
  - Issue: -
  - Dependencies: -
  - Tag maintainer: @baskaryan
  - Twitter handle: @finnless
Can you make system_prefix customizable?
Labels: name: auto:improvement

### Feature request

We are using langchain for non-English applications. The prefix for system is hardcoded as "System":

```python
for m in messages:
        if isinstance(m, HumanMessage):
            role = human_prefix
        elif isinstance(m, AIMessage):
            role = ai_prefix
        elif isinstance(m, SystemMessage):
            role = "System"
        elif isinstance(m, FunctionMessage):
            role = "Function"
        elif isinstance(m, ChatMessage):
            role = m.role
        else:
            raise ValueError(f"Got unsupported message type: {m}")
```

The word "System" will appear in the prompt, e.g., when using summary-based memories. A sudden English word is not friendly to non-English LLMs.


### Motivation

Improving multi-language support.

### Your contribution

Sorry. I am probably not capable enough of developing langchain.
use LlamCpp as LlamaCppEmbeddings base, without model reloading
Labels: name: auto:improvement

When we use LlamaCpp and we need embeddings, earlier we load model in LlamaCpp in memory, then we create LlamaCppEmbeddings and load the same model again. After this modification we can create LlamaCppEmbeddings with existing LlamaCpp model and use as always. Reduce needed memory, reduce time for loading.
Adds async support to agent return_stopped_response
Labels: name: auto:improvement

  - Description: Commit adds an async function `areturn_stopped_response` to use with AgentExecute._acall. Common code parts shared between `areturn_stopped_response` and `return_stopped_response` are extracted to 2 new member utility functions  named `_collect_inputs` and `_parse_outputs`. 
  - Issue: NA: When Agent.llm_chain has an Async Callback, `return_stopped_response` causes error in AgentExecutor.__acall()
  - Dependencies: None
  - Tag maintainer: @agola11,
  - Twitter handle: @soysal_net
Pipe `intermediate_steps` out of map_reduce.run()
Labels: name: auto:improvement

### Feature request

Pipe `intermediate_steps` out of MR chain:
```
# Combining documents by mapping a chain over them, then combining results
    combine_documents = MapReduceDocumentsChain(
        # Map chain
        llm_chain=map_llm_chain,
        # Reduce chain
        reduce_documents_chain=reduce_documents_chain,
        # The variable name in the llm_chain to put the documents in
        document_variable_name="questions",
        # Return the results of the map steps in the output
        return_intermediate_steps=True)
        
    # Define Map=Reduce
    map_reduce = MapReduceChain(
        # Chain to combine documents
        combine_documents_chain=combine_documents,
        # Splitter to use for initial split
        text_splitter=text_splitter)
    
    return map_reduce.run(input_text=input_doc)
```

Error:
```
ValueError: `run` not supported when there is not exactly one output key. Got ['output_text', 'intermediate_steps'].
```

### Motivation

We want to return the intermediate docs

### Your contribution

Will work on this
InvalidRequestError: This model's maximum context length is 4097 tokens. However, your messages resulted in 5822 tokens. Please reduce the length of the messages.
Labels: name: auto:bug

### System Info

Hey! Below is the code i'm using

```
llm_name = "gpt-3.5-turbo"
# llm_name = "gpt-4"
os.environ["OPENAI_API_KEY"] = ""

st.set_page_config(layout="wide")

def load_db(file_path, chain_type, k):
    loader = PyPDFLoader(file_path)
    documents = loader.load()
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=300)
    docs = text_splitter.split_documents(documents)
    embeddings = OpenAIEmbeddings()
    db = DocArrayInMemorySearch.from_documents(docs, embeddings)
    retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": k})
    qa = ConversationalRetrievalChain.from_llm(
        llm=ChatOpenAI(model_name=llm_name, temperature=1), 
        chain_type=chain_type, 
        retriever=retriever, 
        return_source_documents=False,
        return_generated_question=False
    )
    return qa 
```

Even though i'm using RecursiveCharacterTextSplitter function, it is returning below error. 

`InvalidRequestError: This model's maximum context length is 4097 tokens. However, your messages resulted in 5822 tokens. Please reduce the length of the messages.`

Is there anything which will fix this issue?

### Who can help?

_No response_

### Information

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

### Related Components

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

-

### Expected behavior

I'm using RecursiveCharacterTextSplitter function where it'll make use of the function and will exceed the context length. It should work right?
Fix syntax erros in documentation
Labels: name: lgtm, name: auto:nit, name: auto:documentation


- Description: Tiny documentation fix. In Python, when defining function parameters or providing arguments to a function or class constructor, we do not use the `:` character.
- Issue: N/A
- Dependencies: N/A,
- Tag maintainer: @rlancemartin, @eyurtsev
- Twitter handle: @mogaal
Adding function to utilize normal models like distilbert, roberta etc
Labels: name: auto:enhancement

### Feature request

I'm trying to create a Q&A application, where i'm using Vicuna and it's taking lot of time to return the response. Below is the code

```
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import DocArrayInMemorySearch
from langchain.chains import ConversationalRetrievalChain
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import PyPDFLoader
from langchain.embeddings import HuggingFaceEmbeddings
import llama_cpp
from run_localGPT import load_model

def load_db(file, chain_type, k):
    # load documents
    loader = PyPDFLoader(file)
    documents = loader.load()

    # split documents
    text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
    docs = text_splitter.split_documents(documents)

    # define embedding
    embeddings = HuggingFaceEmbeddings()

    # create vector database from data
    db = DocArrayInMemorySearch.from_documents(docs, embeddings)

    # define retriever
    retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": k})
    
    # create a chatbot chain. Memory is managed externally.
    qa = ConversationalRetrievalChain.from_llm(
        llm=load_model(model_id="TheBloke/Wizard-Vicuna-13B-Uncensored-GGML", device_type="mps", model_basename="Wizard-Vicuna-13B-Uncensored.ggmlv3.q2_K.bin"),#ChatOpenAI(model_name=llm_name, temperature=0), 
        chain_type=chain_type, 
        retriever=retriever, 
        return_source_documents=True,
        return_generated_question=True,
    )
    
    return qa 
```


I'm using Vicuna-13b model and hugging face embeddings. What i thought is that it'd be much better if i use hugging face embeddings and any benchmark q&a model, so that the return time will be less. Is there any to load normal models like distilbert, roberta or distilbert-base-uncased-distilled-squad etc?

### Motivation

To utilize the benchmark models for better response time.

### Your contribution

-