delayedkarma/langchain-issues huggingface dataset:
GGML_ASSERT when using LlamaCppEmbeddings using langchain with quantized Llama 7B chat model 
Labels: name: area: embeddings, name: area: vector store, name: auto:bug, name: area: models

when i used vocab_only=True for tokenize and add documents to opensearch vectors store, facing the following issue. could you please help me to fix,

GGML_ASSERT: C:\Users\pip-install-vabntc\project\llama-cpp-python\vendor\llama.cpp\llama.cpp:4032: !!kv_self.ctx
example of reusing the same prompt with different inputs
Labels: name: auto:documentation, name: size:M

<!-- 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.
 -->
Fix AddableDict raising exception when used with non-addable values
Labels: name: auto:bug

<!-- 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.
 -->
Fix on_llm_new_token(chunk=) for some chat models
Labels: name: auto:bug, name: area: models

It was passing in message instead of generation

<!-- 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.
 -->
Update langchain to langchain-cli in README.md
Labels: name: auto:documentation

When I tried this quick start, I had to substitute all the `langchain` command for `langchain-cli` commands. This PR updates the README to reflect that.

<!-- 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.
 -->
In Runnable.stream_log build up final_output from adding output chunks
Labels: name: lgtm, name: auto:improvement, name: size:L

Add arg to omit streamed_output list, in cases where final_output is enough this saves bandwidth

<!-- 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.
 -->
UnboundLocalError in langchain.retrievers.google_vertex_ai_search 
Labels: name: area: vector store, name: auto:bug

### System Info

Version 0.0.328, macOS, Python 3.11.5

In [_convert_website_search_response() ](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/google_vertex_ai_search.py#L120-L154) of [langchain.retrievers.google_vertex_ai_search](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/google_vertex_ai_search.py), if no documents are found it will try and print:

```
print(
                f"No {chunk_type} could be found.\n"
                "Make sure that your data store is using Advanced Website Indexing.\n"
                "https://cloud.google.com/generative-ai-app-builder/docs/about-advanced-features#advanced-website-indexing"  # noqa: E501
            )
```

However, the `chunk_type` variable is defined only if documents have been found, and is therefore unbound, leading to exception and crash.

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

Any query that will fail to produce documents at all.

### Expected behavior

The variable should be bound so that the exception is avoided.
bump 329
Labels: name: auto:nit

<!-- 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.
 -->
Fix broken links to use cases
Labels: name: lgtm, name: auto:documentation

This PR replaces broken links to end to end usecases ([/docs/use_cases](https://python.langchain.com/docs/use_cases)) with a non-broken version ([/docs/use_cases/qa_structured/sql](https://python.langchain.com/docs/use_cases/qa_structured/sql)), consistently with the "Use cases" navigation button at the top of the page.
WebResearchRetriever enhancement with Memory and Reingestion of Documents
Labels: name: area: memory, name: area: vector store, name: auto:enhancement

### Feature request

WebResearchRetriever is a really great way to build a RAG based solution on public data. The challenge with using it in production is two things:

1. WebResearchRetriever contains a field called url_database and its an in memory python list, it would be good to provide some sort of alternative (maybe a memory based backend). 
2. Documents on the web get updated, so some sort of staleness after the google search to reload and reingest the document again would be very great. (i.e expire the url from the database after some time delta, check if the url is already in the vectorstore, purge the docs, then regingest the site).


Suggestion:
add the following fields to WebResearchRetriever:
1. url_seen_ttl: TimeDelta
2. url_database_backend: MemoryBackend (some memory object in langchain that supports ttl or the ability to save a last lived field
3. purge_already_existing_documents: bool

I think the above should be optional to avoid adding more latency for purging documents to avoid performance regressions. Vectorstore abstraction doesnt also provide a simple way to filter by metadata unsure what to do there. 

### Motivation

I am trying to make a WebResearchRetriever on public technical documentation and it gets updated every sprint release cycle, thus having something that is long living in a vectordb does not meet the requirements. Those two specific asks will help me use the out of the box functionality in langchain rather than overriding the baseretriever an making my own custom websearchretriever with memory.

### Your contribution

I can help with a PR if it makes sense to have in langchain, otherwise I will take this as not something the community wants which is fair, I have a good sense of how to implement it for my own use case.
Core dump with Hugginface Embedding on aarch64 (M1 macbook)
Labels: name: area: embeddings, name: auto:bug

### System Info

linux: 6.5.0-asahi-15-1-edge-ARCH
python=3.11.5
langchain=0.0.327
sentence-transformers=2.2.2

### Who can help?

_No response_

### Information

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

### Reproduction

The followig code simply causes the script to crash with a core dump: `zsh: segmentation fault (core dumped)  python3 bge.py`. Note that I have no trouble downloading the model when this script runs for the first time.  Also, this works as expected on my x86 machines.

```
from langchain.embeddings import HuggingFaceBgeEmbeddings

def embed(query):
    model_name = "BAAI/bge-base-en-v1.5"
    encode_kwargs = {'normalize_embeddings': True} # set True to compute cosine similarity

    bge_model = HuggingFaceBgeEmbeddings(
        model_name=model_name,
        model_kwargs={'device': 'cpu'},
        encode_kwargs=encode_kwargs
    )

    vector = bge_model.embed_query(query)
    print(vector)


def main():
    embed("Hello there.")


if __name__ == "__main__":
    main()
```

### Expected behavior

This script should simply print a list of floating point numbers, i.e., the result of the embedding.
Fixed a typo in templates/docs/CONTRIBUTING.md (delimeters =>delimiters)
Labels: name: lgtm, name: auto:documentation

  - **Description:** Just fixed a minor typo in templates/docs/CONTRIBUTING.md.
  - **Issue:** No linked issues.

Very small contribution!

<!-- 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.
 -->
Add option to set request parameters for MathpixPDFLoader 
Labels: name: area: doc loader, name: auto:improvement

### Feature request

**Status Quo**

Currently, the [MathpixPDFLoader](https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/pdf.html#MathpixPDFLoader) sets its data property as follows:

```
    @property
    def data(self) -> dict:
        options = {"conversion_formats": {self.processed_file_format: True}}
        return {"options_json": json.dumps(options)}
```

However, there are a variety of additional useful parameters that can be defined in the MathPix API calls: https://docs.mathpix.com/#request-parameters-6 For instance, this includes `enable_tables_fallback`, `numbers_default_to_math`, `enable_spell_check` etc.

It would be great if these parameters could be specified as keyword arguments directly in the MathpixPDFLoader.

### Motivation

For instance, tables do not always get parsed properly in PDFs and therefore in some cases it can make sense to set enable_tables_fallback=True.

### Your contribution

TBD
Issue: Schema error when ingesting documents
Labels: name: area: doc loader, name: auto:bug

### Issue you'd like to raise.

The error
{'error': [{'message': "'id' is a reserved property name, no such prop with name 'id' found in class 'LangChain_14ee2519c3154dcb9ea3f47a8967d0e8' in the schema. Check your schema files for which properties in this class are available"}]}

loader = ConfluenceLoader(
url="URL", username="USERNAME", api_key="API_KEY")
documents = loader.load(space_key="SPACE_KEY", include_attachments=True, limit=150)
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
documents = text_splitter.split_documents(documents)
db = Weaviate.from_documents(documents, embeddings, client=client, by_text=False)
chatbot = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=db.as_retriever(search_type="similarity",search_kwargs={"k": 1}),
)
prompt = PromptTemplate(template=template, input_variables=["query"])
import sys
while True:
message=input("prompt: ")
if message=='exit':
print('Exiting')
sys.exit()
if message=='':
continue
response = chatbot.run(prompt.format(query=message))

### Suggestion:

_No response_
YoutubeLoader throws 'module not found' error
Labels: name: area: doc loader, name: auto:bug

### System Info

Running langchain in Nextjs app
```
"langchain": "^0.0.175",
"next": "^13.5.2",
"react": "18.2.0",
```

### Who can help?

@eyurtsev 

### 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
- [X] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I'm using the YoutubeLoader as described in the docs. The YoutubeLoader is part of a route handler in my NextJs application.

```
// in youtube service
export async function getYoutubeTranscript(youtubeUrl: string) {
  const loader = YoutubeLoader.createFromUrl(youtubeUrl, {
    language: 'en',
    addVideoInfo: true,
  })
  const docs = await loader.load()
  return docs
    .map((doc) => doc.pageContent)
    .join(' ')
    .replaceAll('\n', ' ')
}
```

```
// in route handler
const transcript = await getYoutubeTranscript(link)
```

When using the route, I get an error because of a missing dependency - on my machine the route still works though.
![image](https://github.com/langchain-ai/langchain/assets/113305699/0890279e-f741-408a-9cb1-7e6cbc49c878)

Manually installing canvas via `npm i canvas` fixes the issue, but when I deploy to vercel, the function exceeds the maximum size limit of 50 MB compressed, because the canvas package is 45 MB compressed...

Not manually installing the dependency causes the route on Vercel to always return a 405 because of the missing dependency:
![image](https://github.com/langchain-ai/langchain/assets/113305699/bf1b95bf-4f99-4ceb-8e6f-740f14346cd3)

I realize that this is not caused by the YoutubeLoader itself, but still hoping for any pointers or ideas how to fix this.

### Expected behavior

YoutubeLoader works without throwing a 'module not found' error
Use data from all Google search results in SerpApi.com wrapper
Labels: name: lgtm, name: auto:improvement

  - **Description:** Use all Google search results data in SerpApi.com wrapper instead of the first one only
  - **Tag maintainer:** @hwchase17 

_P.S. `libs/langchain/tests/integration_tests/utilities/test_serpapi.py` are not executed during the `make test`._
Add LCEL-compatible `SerpApiRun` and `SerpApiResults` tools
Labels: name: area: agent, name: auto:enhancement

  - **Description:** Add LCEL-compatible `SerpApiRun` and `SerpApiResults` tools
  - **Tag maintainer:** @baskaryan
  - **Twitter handle:** [@ilyazub_](https://twitter.com/ilyazub_)

Example usage:

```python
# docs/docs/expression_language/cookbook/tools.ipynb
search = SerpApiRun()

template = """turn the following user input into a search query for a search engine:

{input}"""
prompt = ChatPromptTemplate.from_template(template)

model = ChatOpenAI()

chain = prompt | model | StrOutputParser() | search

chain.invoke({"input": "Which club is Cristiano Ronaldo playing right now?"})
```
Issue: When using FAISS vector store, how can I get the size of vector store
Labels: name: area: vector store, name: auto:question

### Issue you'd like to raise.

When using FAISS vector store, how can I get the size of vector store?
For example, I used FAISS.load_local(path, embeddings) to load a vector store, how to get the size of the loaded vector store? Which should be the total number of documents in it.

### Suggestion:

_No response_
ConversationEntityMemory + SQLiteEntityStore doesn't store chat_history to the database at all
Labels: name: area: memory, name: auto:bug, name: area: models, name: integration: chroma

### System Info

Langchain == 0.0.327
sqlite3

Here's how the setup is done 

Entity memory
```
memory = ConversationEntityMemory(
            llm=llm,
            input_key='question',
            entity_store=store,
            chat_history_key='chat_history',
            return_messages=True
        )
```

Entity store
```
store = SQLiteEntityStore(
            session_id=f'session_{name}',
            db_file=os.path.abspath('storage/db/chat_history.sqlite3'),
            table_name='chat_history'
        )
```

It doesn't store any chat history to the sqlite database. Ofcourse a table for each conversation id is getting created and it does store only one row i.e. the summary of the conversation. But nothing else getting stored.

I am using ```RetrievalQA``` as well as ```ConversationalRetrievalChain``` and it doesn't work with either of them

```
chain = RetrievalQA.from_chain_type(
            llm=llm,
            retriever=vectordb, // chroma db is used and works properly
            chain_type_kwargs={
                "prompt": QUERY_PROMPT,
                "memory": memory,
                "verbose": False
            },
            # memory=memory, // doesnt work here
            verbose=False
)
```

or
```
chain = ConversationalRetrievalChain.from_llm(
            retriever=vectordb,
            llm=llm,
            memory=memory
        )
```

LLM is as provided
```
llm = ChatOpenAI(...)
```

### 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
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

As I have checked the chat_history.py script, found out that the particular method is not implemented till now

File path
```
.venv/lib/python3.11/site-packages/langchain/schema/chat_history.py
```

Method details (line 56-63)
```
@abstractmethod
def add_message(self, message: BaseMessage) -> None:
    """Add a Message object to the store.

    Args:
        message: A BaseMessage object to store.
    """
    raise NotImplementedError()
```

I think this method is responsible for storing the chat history to the persistent database

### Expected behavior

The code should save the chat_history (prompt + response) to the sqlite database after each prompt.
create_sql_agent checks schema of a table with partiton field always goes wrong
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

In create_Sql_agent, when the agent is querying a table schema with partition field, it nevers adds parition and the program goes wrong, how to let the agent add partition field everytime it queries a table schema? Many thanks.

### Suggestion:

_No response_