delayedkarma/langchain-issues huggingface dataset:
feat: add BigFramesLLM integration
Labels: name: auto:enhancement, name: area: models

This PR adds [Bigframes (BigQuery DataFrames)](https://cloud.google.com/python/docs/reference/bigframes/latest) integration to Langchain. BigQuery DataFrames provides a Pythonic DataFrame and machine learning (ML) API powered by the BigQuery engine. BigFrames supports manipulating data in the DataFrame to build LLM prompts, and sending DataFrame prompts to the LLM model using [text-bison model of the PaLM API](https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/text)

<!-- 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.
 -->
UnstructuredWordDocumentLoader - Missing Percentages (%) characters in data
Labels: name: area: doc loader, name: auto:bug

### System Info

I am using UnstructuredWordDocumentLoader module to load a .docx file. I already tried several things... but the text data returned is always without the percentages that are several times in the .docx file.

How can I maintain / get this (%) percentage symbol?

Thanks

### Who can help?

@hwchase17 @agola11 @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

loader = UnstructuredWordDocumentLoader("example_data/fake.docx", mode="elements")

data = loader.load()

### Expected behavior

Have in the data the percentages characters also.
DOC: optional ids issue in delete method in vectorstores 
Labels: name: area: vector store, name: auto:enhancement, name: auto:documentation

### Issue with current documentation:

In the documentation for some examples like [Weaviate](https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.weaviate.Weaviate.html#langchain.vectorstores.weaviate.Weaviate.delete) and [ElasticsearchVectorStore](https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.elasticsearch.ElasticsearchStore.html#langchain.vectorstores.elasticsearch.ElasticsearchStore.delete), the delete method is described as having the ids parameter as optional. 

`delete(ids: Optional[List[str]] = None, **kwargs: Any) → None`

However, the ids parameter is mandatory for those vectorstores, and if it is not provided, a ValueError will be raised with the message "No ids provided to delete." Here is the revised [documentation](https://github.com/langchain-ai/langchain/blob/b9fad28f5e093415d76aeb71b5e555eb87fd2ec2/libs/langchain/langchain/vectorstores/elastic_vector_search.py#L336C5-L348C61) to clarify this:

`
def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> None:
        """Delete by vector IDs.

        Args:
            ids: List of ids to delete.
        """

        if ids is None:
            raise ValueError("No ids provided to delete.")

        # TODO: Check if this can be done in bulk
        for id in ids:
            self.client.delete(index=self.index_name, id=id)
`


### Idea or request for content:

Please clarify in the documentation 
Is it also possible to get bulk delete functionality for some vectorstore (ex. ElasticsearchVectorStore/ Weviate)?
Feature: Markdown list output parser
Labels: name: auto:improvement, name: area: models

### Feature request

I would like to implement a `ListOutputParser` that could transform Markdown list into a string list

### Motivation

It seems that most of the lists generated by LLMs are Markdown lists, so I think this will be useful.
It might also make it easier to handle cases where the generated list doesn't work with the existing `ListOutputParser` (Numered and CommaSeparated).

### Your contribution

Here is the PR: https://github.com/langchain-ai/langchain/pull/11411
Redis from_existing_index does not raise ValueError when index does not exist
Labels: name: area: vector store, name: auto:bug, name: integration: redis

### System Info

langchain 0.0.303, python 3.9, redis-py 5.0.1, latest redis stack with RedisSearch module 

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

### Reproduction

Try to create Redis vector store like this from non existent index_name:
`      
               embeddings = OpenAIEmbeddings()
               vectorstore = Redis.from_existing_index(
                        embeddings,
                        index_name=index_name,
                        schema='schema.yaml',
                        redis_url=REDIS_URL,
                    )
` 
it executes and returns object of Redis type, and logs that index was found. However, of course it fails to query later. 

### Expected behavior

It should raise a ValueError accortding to doc.
BooleanOutputParser expected output value error
Labels: name: auto:bug, name: area: models

### System Info

Hi, I am using LLMChainFilter.from_llm(llm) but while running, I am getting this error:

ValueError: BooleanOutputParser expected output value to either be YES or NO. Received Yes, the context is relevant to the question as it provides information about the problem in the.

How do I resolve this error?

Langchain version: 0.0.308

### Who can help?

@agola11

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

### Reproduction

from langchain.retrievers import ContextualCompressionRetriever
from langchain.retrievers.document_compressors import LLMChainExtractor, LLMChainFilter

llm = SageMakerEndpointModel
_filter = LLMChainFilter.from_llm(llm)
compressor = LLMChainExtractor.from_llm(llm)
compression_retriever = ContextualCompressionRetriever(base_compressor=_filter, base_retriever=faiss_retriever)

compressed_docs = compression_retriever.get_relevant_documents("What did the president say about Ketanji Jackson Brown?")


### Expected behavior

Get filtered docs
Issue: prevent a agent from exceeding the token limit
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

Hey there, I'm trying got find a way to prevent an agent from going over the token limit, I've looked at the docs, asked around and had no luck.

This is the error for better content:
 [ERROR] InvalidRequestError: This model's maximum context length is 16384 tokens. However, your messages resulted in 17822 tokens. Please reduce the length of the messages.

Any help would be great 😊

### Suggestion:

_No response_
Fix typing imports in extraction usecase
Labels: name: lgtm, name: auto:documentation

The person class here: https://python.langchain.com/docs/use_cases/extraction#pydantic-1 has attributes `dog_breed` and `dog_name` that use `Optional` from typing, but it hasn't been imported. Fixed the import here

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** Fix python imports in example, 
  - **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 QA doc w/ Runnables
Labels: name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
StreamlitCallbackHandler thinking.. / spinner Not stopping
Labels: name: auto:bug, name: area: models

### System Info

python:3.10.13 bookworm (docker)
streamlit
Version: 1.27.1
langchain
Version: 0.0.306


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

   # Display assistant response in chat message container
    with st.chat_message("🧞‍♂️"):
        message_placeholder = st.empty()
        cbh = StreamlitCallbackHandler(st.container())
        AI_response = llm_chain.run(prompt,callbacks=[cbh])

### Expected behavior

 the "Thinking.." spinner STOPS or hides after LLM finishes its response

No Parameters I can find here
https://api.python.langchain.com/en/latest/callbacks/langchain.callbacks.streamlit.streamlit_callback_handler.StreamlitCallbackHandler.html 
that would affect this
Retrun_source_documets does not work !!!!
Labels: name: auto:bug, name: area: models

### System Info

"There was a BUG when using return_source_documents = True with any chain, it was always raising an error!!
!!, this is a temporary fix that requires the 'answer' key to be present there, but FIX IT, it is now impossible to to return_source_docs !!!!!!!!!!!!" 
def _get_input_output(
        self, inputs: Dict[str, Any], outputs: Dict[str, Any]
    ) -> Tuple[str, str]:
        if self.input_key is None:
            prompt_input_key = get_prompt_input_key(inputs, self.memory_variables)
        else:
            prompt_input_key = self.input_key

        if self.output_key is None:
            if 'answer' in outputs:
                output_key = 'answer'
            else:
                raise ValueError("Output key 'answer' not found.")
        else:
            output_key = self.output_key

        return inputs[prompt_input_key], outputs[output_key]

### Who can help?

@eyur

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

### Reproduction

def create_chain():
    retriever = cretae_retriver....
    )

    memory = memory...

  
    chain = ConversationalRetrievalChain.from_llm(
        llm=ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
        retriever=retriever,
        verbose=True,
        memory=memory,
 
        return_source_documents=True, !!!!!! Here , it does not work
      
    )

    return chain


def run_chat():
    chain = create_chain()
    while True:
        query = input("Prompt: ")

        if query in ["quit", "q", "exit"]:
            sys.exit()

        result = chain({"question": query})

        print(f"ANSWER: {result['answer']}")
        print(f"DOCS_USED: {result['source_documents']}")

        query = None

### Expected behavior

It will say this error 
raise ValueError(f"One output key expected, got {outputs.keys()}")
ValueError: One output key expected, got dict_keys(['answer', 'source_documents'])
Improve output of Runnable.astream_log()
Labels: name: auto:improvement

- Make logs a dictionary keyed by run name (and counter for repeats)
- Ensure no output shows up in lc_serializable format
- Fix up repr for RunLog and RunLogPatch

<!-- 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.
 -->
Sources are not returned in RetrievalQAWithSourcesChain
Labels: name: area: vector store, name: auto:bug, name: area: models

### System Info

I'm using Google Colab, authenticating with my own account.

Packages installation:

!pip install google-cloud-discoveryengine google-cloud-aiplatform langchain==0.0.236 -q

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

Sample code:

import vertexai
from langchain.llms import VertexAI
from langchain.retrievers import GoogleCloudEnterpriseSearchRetriever

vertexai.init(project=PROJECT_ID, location=REGION)
llm = VertexAI(model_name=MODEL, temperature=0, top_p=0.2, max_output_tokens=1024)

retriever = GoogleCloudEnterpriseSearchRetriever(
    project_id=PROJECT_ID, search_engine_id=DATA_STORE_ID
)

from langchain.chains import RetrievalQAWithSourcesChain

search_query = "How to create a new google calendar?"

retrieval_qa_with_sources = RetrievalQAWithSourcesChain.from_chain_type(
    llm=llm, chain_type="stuff", retriever=retriever
)

results = retrieval_qa_with_sources({"question": search_query})

print(f"Answer: {results['answer']}")
print(f"Sources: {results['sources']}")

Return:

Answer: To create a new calendar, follow these steps:

1. On the computer, open Google Calendar.
2. On the left, next to "Other calendars," click Add other calendars->Create new calendar.
3. Add a name and description to the calendar.
4. Click on Create a Schedule.
5. To share the calendar, click on it in the left bar and select Share with specific people.
Sources: 

### Expected behavior

Expected to have the sources as URI from Google Cloud Storage. It sometimes return, sometimes not. It is really random.
Issue: similarity_score_threshold not working with pinecone as expected
Labels: name: area: vector store, name: auto:bug, name: integration: pinecone

### Issue you'd like to raise.

I am using Lang chain version 0.0.307 and I noticed an issue with the similarity_score_threshold. I just upgraded from 0.0.208 or 288 (I forgot). 

This is the code I am using to retrieve the documents from pinecone:

```
 docsearch = Pinecone.from_existing_index(index, embeddings, text_key="text")
  retriever = docsearch.as_retriever(
  search_type="similarity_score_threshold",
  search_kwargs={
  'score_threshold': 0.6
  }
 )
retriever_docs_result = retriever.get_relevant_documents(query)
```
                
it used to work fine but after upgrading the langchain version it stopped returning any docs. Upon investigating the code, I've noticed that  inside the `_similarity_search_with_relevance_scores`  method in `vectorstore.py` , `docs_and_scores`   is returning the scores as expected but then this code tries to calculate the relevance score and inverts the values:
`return [(doc, relevance_score_fn(score)) for doc, score in docs_and_scores]`.

I am getting search score values as 0.7 to 0.85 but then the relevancy score inverts it and makes it (1-score) which is around 0.3 to 0.15. The problem is the score_threshold works the opposite way. So if I set score_threshold to 0.6 it wants scores bigger than 0.6 which is impossible because the relevancy score makes it invert (if the relevancy score is smaller it means it is more closer to what we queried). 

I am using dot product and I have used the following code as well but it also didn't help:
`
docsearch = Pinecone(index, embeddings, text_key="text", distance_strategy=DistanceStrategy.MAX_INNER_PRODUCT)
retriever = docsearch.as_retriever(
search_type="similarity_score_threshold",
search_kwargs={
'score_threshold': 0.6
}
)

`
Can someone help or I am missing something here ?

### Suggestion:

_No response_
Add optional input_types to prompt template
Labels: name: auto:improvement, name: area: models

- default MessagesPlaceholder one to list of messages

<!-- 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 _type to json functions output parser
Labels: name: auto:improvement

<!-- 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.
 -->
Issue: sqlite3.OperationalError: unable to open database file
Labels: name: area: vector store, name: auto:bug, name: auto:question, name: integration: pinecone

### Issue you'd like to raise.

Hi, I have implemented the indexing workflow as in https://python.langchain.com/docs/modules/data_connection/indexing making use of Pinecone and sqlite. This runs perfect within a Pycharm dev environment. But after building the app with Pyinstaller, I get the following error: sqlite3.OperationalError: unable to open database file. I think this one is coming from langchain.indexes.index. The error message is very cryptic. Why can't this file be opened? Is it locked? Is it corrupted - no as I can open it with a desktop sql manager app. I tried different locations for storing the sqlite database but makes no difference. 
Does anyone has some ideas on how to solve this?

### Suggestion:

_No response_