delayedkarma/langchain-issues huggingface dataset:
Streaming Turns on Verbose mode for AgentType.CONVERSATIONAL_REACT_DESCRIPTION
Labels: name: area: agent, name: auto:bug

### System Info

With Streaming turned on, verbose mode is turned on.
Am I doing something wrong?

Python 3.10.9
Name: langchain
Version: 0.0.284
llm2 = ChatOpenAI(
    temperature=0,
    streaming=True,
    callbacks=[StreamingStdOutCallbackHandler()],
    model="gpt-4-0613",
)

agent = initialize_agent(
    tools,
    llm2,
    agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
    memory=memory,
    verbose=False,
)

Thought: Do I need to use a tool? Yes
Action: Search for Property Owners
Action Input: 5954A Bartonsville RoadDo I need to use a tool? No
AI: The house at 5954A Bartonsville Road is owned by Rainbown Johonson.The house at 5954A Bartonsville Road is owned by Rainbown Johonson.
Thought: Do I need to use a tool? Yes
Action: Search for Property Owners
Action Input: 1163 Annamarie WayDo I need to use a tool? Yes
Action: Search for People
Action Input: Randolph HillDo I need to use a tool? No

### Who can help?

_No response_

### Information

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

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

llm2 = ChatOpenAI(
    temperature=0,
    streaming=True,
    callbacks=[StreamingStdOutCallbackHandler()],
    model="gpt-4-0613",
)

agent = initialize_agent(
    tools,
    llm2,
    agent=AgentType.CONVERSATIONAL_REACT_DESCRIPTION,
    memory=memory,
    #verbose=False,
)
print(
    agent.run(
        input="Who owns the house at the following address 5954A Bartonsville Road?"
    )
)

### Expected behavior

I do not expect verbose output.
DOC: LLMSingleActionAgent vs. Agent
Labels: name: area: agent, name: auto:documentation

### Issue with current documentation:

Hello. 

I think there is little to no explanation as to which are the differences between `LLMSingleActionAgent` and `Agent` classes, and which is suitable for what scenario. Both classes inherit from `BaseSingleActionAgent`.

Thanks in advance.

### Idea or request for content:

_No response_
TextGen parameter to silence the print in terminal
Labels: name: auto:improvement, name: area: models

### Feature request

I'd like a way to silence TextGen's output in my terminal. For example, a parameter would be perfect.

Looking at TextGen's source code, I see this line `print(prompt + result)`. 
If I remove this line, then I get the desired effect where nothing is printed to my terminal.

### Motivation

I'm working on an app with lots of logging and thousands of requests are sent via TextGen. 
My output is very noisy with every prompt and result printed, and it's troublesome to scroll through it all. I only care about the result I receive.

### Your contribution

My suggestion is to add a parameter flag to TextGen such that I can control the print (on or off), instead of it being hardcoded in.

There are 2 areas where I'd like to see it changed:
1. When streaming is enabled `print(prompt + combined_text_output)`
2. When streaming is disabled `print(prompt + result)`
Issue with Few Short prompt when passed to agent 
Labels: name: auto:bug, name: area: models

### System Info

I have used the SemanticSimilarityExampleSelector and created a prompt. When I try to pass this to agent it fails saying: **ValueError: Saving an example selector is not currently supported**

![image](https://github.com/langchain-ai/langchain/assets/75229326/81a38ed5-b2d2-4756-ae30-e89e41c6a734)

ValueError: Saving an example selector is not currently supported
to create prompt I have used https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/similarity

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Use the above code provided along with prompt selector provided in the original docuementation 

### Expected behavior

To produce the output for the question asked
PineconeHynridSearchRetriever missing several args and not returning ids of vectors when adding texts
Labels: name: area: vector store, name: auto:bug, name: auto:documentation, name: integration: pinecone

### System Info

There are a few differences between the PineconeHybridSearchRetriever and base Pinecone retriever making it difficult to switch to the former.
@hw
You can pass search_kwargs to pinecone index.as_retriver(search_kwargs:{filter: 'value'}) because it inherits from base VectorStore which has the as_retriever method with search_kwarg args. 

But it is not clear from the documentation of PineconeHybridSearchRetriever, which inherits from BaseRetriever, how to pass those same arguments. 

Also, the add_text method in Pinecone class returns the IDs, whereas in HybridSearch it does not. 
`[[docs]](https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.pinecone.Pinecone.html#langchain.vectorstores.pinecone.Pinecone.add_texts)    def add_texts(
        self,
        texts: Iterable[str],
        metadatas: Optional[List[dict]] = None,
        ids: Optional[List[str]] = None,
        namespace: Optional[str] = None,
        batch_size: int = 32,
        embedding_chunk_size: int = 1000,
        **kwargs: Any,
....
....
        for i in range(0, len(texts), embedding_chunk_size):
            chunk_texts = texts[i : i + embedding_chunk_size]
            chunk_ids = ids[i : i + embedding_chunk_size]
            chunk_metadatas = metadatas[i : i + embedding_chunk_size]
            embeddings = self._embed_documents(chunk_texts)
            async_res = [
                self._index.upsert(
                    vectors=batch,
                    namespace=namespace,
                    async_req=True,
                    **kwargs,
                )
                for batch in batch_iterate(
                    batch_size, zip(chunk_ids, embeddings, chunk_metadatas)
                )
            ]
            [res.get() for res in async_res]

        return ids`





### Who can help?

_No response_

### Information

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

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Create pinecone index and use as_retriever with passing search_kwargs('filter':{key:value})
Vs
Create PineconeHybridSearchRetriever, there is no way to pass filters

### Expected behavior

Pass search_kwargs in the class instantiation of PineconeHybridSearchRetriever so it can be used downstream in conversationalretrievalchain
Adding Self-querying for Vectara
Labels: name: area: vector store, name: auto:enhancement

  - Description: Adding support for self-querying to Vectara integration
  - Issue: per customer request
  - Tag maintainer: @rlancemartin @baskaryan 
  - Twitter handle: @ofermend 

Also updated some documentation, added self-query testing, and a demo notebook with self-query example.
Response is sometimes in different language
Labels: name: auto:bug, name: area: models

### System Info

Got no system info to share.


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

### Reproduction

I just want to say that what you developed is awesome, but I have small bug to report, sometimes when I am chatting the response will be in french/spanish although training documentation and question asked is in English.


How to reproduce:

Say hello to bot, he will respond information is not in the given context.
Ask him some question about docs it learned from in English, answer will be in another language French/Spanish/etc.

Here is the code.

```
for message in st.session_state.messages:
        with st.chat_message(message["role"]:
            st.markdown(message["content"])

    if prompt := st.chat_input("State your question"):
        st.session_state.messages.append({"role": "user", "content": prompt})
        with st.chat_message("user"):
            st.markdown(prompt)

        llm = ChatOpenAI(temperature=0.5, max_tokens=1000,
                         model_name="gpt-3.5-turbo")
        conversation = ConversationalRetrievalChain.from_llm(
            llm, vector_store.as_retriever())

        final= conversation ({"question": prompt, "chat_history": [
                    (message["role"], message["content"]) for message in st.session_state.messages]})

        with st.chat_message("assistant):
            message_placeholder = st.empty()
            final_response= final["answer"]
            message_placeholder.markdown(final_response)
        message_placeholder.markdown(final_response)
        st.session_state.messages.append(
            {"role": "assistant", "content": final_response})

```

### Expected behavior

Answer should be in same language question was asked.
Multilingual anonymization
Labels: name: auto:enhancement

### Description

Add multiple language support to Anonymizer

PII detection in Microsoft Presidio relies on several components - in addition to the usual pattern matching (e.g. using regex), the analyser uses a model for Named Entity Recognition (NER) to extract entities such as:
- `PERSON`
- `LOCATION`
- `DATE_TIME`
- `NRP`
- `ORGANIZATION`

[[Source]](https://github.com/microsoft/presidio/blob/main/presidio-analyzer/presidio_analyzer/predefined_recognizers/spacy_recognizer.py)

To handle NER in specific languages, we utilize unique models from the `spaCy` library, recognized for its extensive selection covering multiple languages and sizes. However, it's not restrictive, allowing for integration of alternative frameworks such as [Stanza](https://microsoft.github.io/presidio/analyzer/nlp_engines/spacy_stanza/) or [transformers](https://microsoft.github.io/presidio/analyzer/nlp_engines/transformers/) when necessary.

### Future works

- **automatic language detection** - instead of passing the language as a parameter in `anonymizer.anonymize`, we could detect the language/s beforehand and then use the corresponding NER model. We have discussed this internally and @mateusz-wosinski-ds will look into a standalone language detection tool/chain for LangChain :smile: 

### Twitter handle
@deepsense_ai / @MaksOpp

### Tag maintainer
@baskaryan @hwchase17 @hinthornw
Enhancement: add parameter boto3_session for AWS DynamoDB cross account use cases
Labels: name: area: memory, name: lgtm, name: auto:enhancement

  - Description: to allow boto3 assume role for AWS cross account use cases to read and update the chat history, 
  - Issue: use case I faced in my company,
  - Dependencies: no
  - Tag maintainer: @baskaryan ,
  - Twitter handle: @tmin97
Running SQLDatabaseChain return records that does not match the query
Labels: name: auto:bug, name: stale, name: area: models

### System Info

Running SQLDatabaseChain with LangChain version 0.0.271 and SQLite return records that does not match the query. 

Using SQLDatabaseChain with verbose set to true I am getting these in the console:
```sql
SQLQuery:SELECT id, sale_type, sold_date, property_type, address, city, state_or_province, zip_or_postal_code, price, beds, baths, location, square_feet, lot_size, year_built, day_on_market, usd_per_square_feet, hoa_per_month, url, latitude, longitude FROM properties WHERE city = 'New York' AND price <= 900000 AND property_type = 'House' AND beds >= 2 ORDER BY price DESC LIMIT 5;
```

```
SQLResult:
Answer:[{"id":3,"sale_type":"MLS Listing","sold_date":"None","property_type":"Condo/Co-op","address":"225 Fifth Ave Ph -H","city":"New York","state_or_province":"NY","zip_or_postal_code":10010,"price":3495000,"beds":3,"baths":3.0,"location":"NoMad","square_feet":"1987","lot_size":31106,"year_built":1907,"day_on_market":1,"usd_per_square_feet":"1987","hoa_per_month":"HOAMONTH","url":"https://www.redfin.com/NY/New-York/225-5th-Ave-10010/unit-H/home/174298359","latitude":40.7437447,"longitude":-73.9875513},{"id":2,"sale_type":"MLS Listing","sold_date":"None","property_type":"Condo/Co-op","address":"416 W 52nd St #520","city":"New York","state_or_province":"NY","zip_or_
```

The SQLResult does not match the SQLQuery. The SQLResult contains a property with a price of 3495000 which is higher than the 900000 filter in the SQLQuery.  Also property_type "Condo/Co-op" does not match "house" from the query. Note that for any reason the results string is truncated at "zip_or_" around 770 characters. 

When I execute a copy/paste of the SQL query from SQLQuery in console directly in the database it returns me 0 result. which what it should return. For info the "price" column is an INTEGER.

This is the code :
```python
def ask_question():
    data = request.get_json()
    question = data['question']
    question = QUERY.format(question=question)    
    text = db_chain.run(question)
```
Did I miss something ?

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

### Reproduction

Run an SQLDatabaseChain with verbose to True
Compare the SQLquery and the SQLresult from the console. The result is not what is expected with the query.

### Expected behavior

The SQL result from the console should match the SQL query.
Multilingual anonymization
Labels: name: auto:enhancement

<!-- 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
sqlite3.OperationalError: too many SQL variables
Labels: name: area: embeddings, name: area: vector store, name: auto:bug

### Issue you'd like to raise.

I have pdf which has more than 2000 pages. file read successfully, but vector db was not created and getting this error. please suggest any solution. 

**complete error:** 
embeddings
    results = cur.execute(sql, params).fetchall()
sqlite3.OperationalError: too many SQL variables

### Suggestion:

_No response_
added ContentFormatter escape special characters for message content
Labels: name: auto:improvement, name: area: models

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - Description: for azure ml chat endpoint added support for ContentFormatter escape special characters for message content, 
  - Issue: escape special character for message content,
  - Dependencies: not required any
  - 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/hwchase17/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. These live is docs/extras directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17, @rlancemartin.
 -->
Langchain doesnt work with Databricks Model serving asking generate (str type expected (type=type_error.str)
Labels: name: auto:bug, name: area: models

### System Info

I have created a LLama 7b model and in Databricks i have used model serving options. When i test model it works in databricks, but when i use the same model to connect with Langchain i get this error.

this works in Databricks model endpoint:

Json input:
{
  "dataframe_split": {
    "columns": [
      "prompt",
      "temperature",
      "max_tokens"
    ],
    "data": [
      [
        "what is ML?",
        0.5,
        100
      ]
    ]
  }
}


code:-
from langchain.llms import Databricks

llm = Databricks(endpoint_name="databricks-llama-servingmodel", model_kwargs={"temperature": 0.1, "max_tokens": 100})
llm ("who are you")

Error:-
ValidationError: 1 validation error for Generation
text
  str type expected (type=type_error.str)

### Who can help?

 @hwchase17
  @agola11


### Information

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

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Any model you take LLM and use the below notebook
https://github.com/databricks/databricks-ml-examples/blob/master/llm-models/llamav2/llamav2-7b/02_mlflow_logging_inference.py (for model serving)

Try using model serving in Langchain as show in the code and official langchain documents

from langchain.llms import Databricks

llm = Databricks(endpoint_name="databricks-llama-servingmodel", model_kwargs={"temperature": 0.1, "max_tokens": 100})
llm ("who are you")

### Expected behavior

llm("who are you")
expected output:- I am language model
Issue: How to customize the question_generator_chain in ConversationalRetrievalChain
Labels: name: area: memory, name: auto:question

### Issue you'd like to raise.

I am writing a ConversationalRetrievalChain with a question_generator_chain. When writing a prompt for condensing the chat_history, I found it doesn't work well with the whole {chat_history}. I guess if I only give all questions asked by "human:", it will perform better. But I don't know how to do that.

The original prompt is:
Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, if the follow up question is already a standalone question, just return the follow up question.

    Chat History:
    {chat_history}
    Follow Up Question: {question}
    Standalone question:
    
What I want may looks like:
.........
Question asked:
{chat_history.human}
Follow Up Question: {question}
Standalone question:

Thanks for attention

### Suggestion:

_No response_
Final answer streaming problem
Labels: name: auto:bug, name: area: models

### System Info

hi, 
I am unable to stream the final answer from llm chain to chianlit UI. 
langchain==0.0.218
Python 3.9.16

here are the details:
https://github.com/Chainlit/chainlit/issues/313

is this implemented? -  https://github.com/langchain-ai/langchain/pull/1222/

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

### Reproduction

the code given above can reproduce the behaviour

### Expected behavior

expected behaviour :  the final answer from  llm chain to be streamed properly to chianlit UI
apply embeddings to pandas dataframe
Labels: name: area: embeddings, name: auto:bug

### System Info

jupyter notebook, RTX 3090

### Who can help?

@agola11 @hwchase17 @ey

### Information

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

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```
from langchain.embeddings import SentenceTransformerEmbeddings 

embedding=lambda x: x['combined_info'].apply(lambda text: embeddings.embed_documents(text))
```

does not work
Any workarounds on it?

### Expected behavior

outputs embeddings
DOC: <Observation Streaming Using Call Back>
Labels: name: area: doc loader, name: auto:documentation

### Issue with current documentation:

When I am using a tool with `return_direct = True` , the observation step will provide the answer. Is there a way to stream that observation from the intermediate steps using callbacks. I found no information regarding this. It is much appreciated if we can add something  regarding that as well.



### Idea or request for content:

_No response_
Issue: Obeservation is capping out when passing to Action Input [CONVERSATIONAL_REACT_DESCRIPTION]
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

When working with the `CONVERSATIONAL_REACT_DESCRIPTION`, I found Observation was capped out when passing to the action input. For example I have retrieved a JsonArray by using a structured tool but when the agent passes it to the final tool jsonArray was capped out. Can I handle it?

### Suggestion:

_No response_