delayedkarma/langchain-issues huggingface dataset:
Update tool.py
Labels: name: lgtm, name: auto:bug

Fixed the description of tool QuerySQLCheckerTool, the last line of the string description had the old name of the tool 'sql_db_query', this caused the models to sometimes call the non-existent tool
The issue was not numerically identified.
No dependencies
@baskaryan, @eyurtsev, @hwchase17, @rlancemartin

<!-- 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.
 -->
create_extraction_chain does not work with other LLMs? Replicate models fails to load
Labels: name: auto:bug, name: area: models

### System Info

LangChain 0.0.281

### 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
- [X] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Use this lines of code

```
schema = {
    "properties": {
        "visit": {"type": "string"},
        "date": {"type": "string"},
        "gender": {"type": "string"},
        "age": {"type": "integer"},
    }
 
}

inp = """This 23-year-old white female presents with complaint of allergies. 
She used to have allergies when she lived in Seattle but she thinks they are worse here. 
In the past, she has tried Claritin, and Zyrtec. Both worked for short time but then seemed to lose effectiveness.  """

llm = Replicate(
    model="a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
    input={"temperature": 0.75, "max_length": 500, "top_p": 1},
)
chain = create_extraction_chain(schema, llm)
chain.run(inp)
```


---------------------------------------------------------------------------
```
OutputParserException                     Traceback (most recent call last)
[<ipython-input-9-5e77f11609b2>](https://localhost:8080/#) in <cell line: 72>()
     70 )
     71 chain = create_extraction_chain(schema, llm)
---> 72 chain.run(inp)["data"]

8 frames
[/usr/local/lib/python3.10/dist-packages/langchain/output_parsers/openai_functions.py](https://localhost:8080/#) in parse_result(self, result)
     21         generation = result[0]
     22         if not isinstance(generation, ChatGeneration):
---> 23             raise OutputParserException(
     24                 "This output parser can only be used with a chat generation."
     25             )

OutputParserException: This output parser can only be used with a chat generation.
```

### Expected behavior

Structrued JSON based on schema
add streaming capability to FakeMessagesListChatModel
Labels: name: auto:improvement, name: area: models, name: size:M

Attempt to add streaming capability to `FakeMessagesListChatModel`.

This is an extension of the work from #10152 and #10116

Not sure I've implemented this correctly, but it is working in my testing.

@hwchase17 happy to make any adjustments if the PR needs improvement.
Adding custom tools to SQL Agent
Labels: name: area: agent, name: lgtm, name: auto:improvement

Changes in:
- `create_sql_agent` function so that user can easily add custom tools as complement for the toolkit.
- updating **sql use case** notebook to showcase 2 examples of extra tools.

Motivation for these changes is having the possibility of including domain expert knowledge to the agent, which improves accuracy and reduces time/tokens.
OpenAIEmbeddings: Add optional an optional parameter to skip empty embeddings
Labels: name: area: embeddings, name: auto:improvement

## Description

### Issue
This pull request addresses a lingering issue identified in PR #7070. In that previous pull request, an attempt was made to address the problem of empty embeddings when using the `OpenAIEmbeddings` class. While PR #7070 introduced a mechanism to retry requests for embeddings, it didn't fully resolve the issue as empty embeddings still occasionally persisted.

### Problem
In certain specific use cases, empty embeddings can be encountered when requesting data from the OpenAI API. In some cases, these empty embeddings can be skipped or removed without affecting the functionality of the application. However, they might not always be resolved through retries, and their presence can adversely affect the functionality of applications relying on the `OpenAIEmbeddings` class.

### Solution
To provide a more robust solution for handling empty embeddings, we propose the introduction of an optional parameter, `skip_empty`, in the `OpenAIEmbeddings` class. When set to `True`, this parameter will enable the behavior of automatically skipping empty embeddings, ensuring that problematic empty embeddings do not disrupt the processing flow. The developer will be able to optionally toggle this behavior if needed without disrupting the application flow.

## Changes Made
- Added an optional parameter, `skip_empty`, to the `OpenAIEmbeddings` class.
- When `skip_empty` is set to `True`, empty embeddings are automatically skipped without causing errors or disruptions.

### Example Usage
```python
from openai.embeddings import OpenAIEmbeddings

# Initialize the OpenAIEmbeddings class with skip_empty=True
embeddings = OpenAIEmbeddings(api_key="your_api_key", skip_empty=True)

# Request embeddings, empty embeddings are automatically skipped. docs is a variable containing the already splitted text.
results = embeddings.embed_documents(docs)

# Process results without interruption from empty embeddings
```
Adding a Verbose Hook
Labels: name: auto:improvement, name: area: models

Adding a Verbose Hook, so verbose output wont only be printed, but also handled if chosen to

solution to #5448 (Issue: Get Verbose messages from chain)

Usage:
```python
def handle_verbose(verbose_output, *args, **kwargs):
    print("$$$$$$$ HANDLEING VERBOSE OUTPUT $$$$$$")
    print(verbose_output) # Handle verbose here
    print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", args, kwargs)

worker = LLMChain(prompt=prompt,llm=llm, verbose=verbose, verbose_hook=handle_verbose)
# Verbose messages will be sent to hook
```
Usefull when you want to include verbose output, for example in a custom debugger gui, logger, or for any other usage.
( I've only changed the on_text event, which includes the final (green) prompt before it is sent to the llm, if you like it you can extend to use in other places. )

Hope you find it useful as I do
Have a good one and all the best!

<!-- 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.
 -->
How to develop an efficient question answering solution acting as a customer assistant based on RAG or Fine tuning?
Labels: name: area: agent, name: area: embeddings, name: area: doc loader, name: area: vector store, name: auto:question, name: area: models

### System Info

0.0.274

### Who can help?

@hwchase17 @agola11 @eyurtsev 

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [X] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction


```
from langchain.llms import VertexAI
from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
import os

PROMPT= """
        You are a customer service assistant.
        Your task is to respond to user questions.
        Start by greeting the user and introducing yourself as BotAssistant, and end with a polite closing. If you don't know the answer, suggest contacting customer service at 3232. Always conclude with: "I hope I've answered your request
        Query: """

llm_model=VertexAI(
                model_name="text-bison@001",
                max_output_tokens=1024,
                temperature=0.1,
                top_p=0.8,
                top_k=40,
                verbose=True,
            )
conversation = ConversationChain(
                        llm=llm_model, 
                        verbose=True, 
                        memory=ConversationBufferMemory(),
                    )

qst="I have an issue with my order; I received the wrong item. What should I do?"
conversation.predict(input=PROMPT+qst)

```

### Expected behavior

I want to develop an llm that acts as a customer assistant( to use for E comerce), responding to user queries using a JSON dataset containing question-answer pairs,possibly incorporating pdf documents of terms and conditions and offer descriptions. How can I effectively use Retrieval Augmented Generation to address this challenge? Is fine-tuning a recommended approach?

Sometimes, the answers to queries are indirect, and they may include links to previously provided answers on the same topic.do you think that a graph representation of the questions answers pairs dataset is relevant?

Any help,links would be appreciated,
Issue: RedisVectorStoreRetriever not accessible
Labels: name: area: vector store, name: auto:bug

### Issue you'd like to raise.

After PR [#8612](https://github.com/langchain-ai/langchain/pull/8612), access to [RedisVectorStoreRetriever](https://github.com/langchain-ai/langchain/blob/27944cb611ee8face34fbe764c83e37841f96eb7/libs/langchain/langchain/vectorstores/redis/base.py#L1293) has been removed

### Suggestion:

Include **RedisVectorStoreRetriever** import in [redis/__init__.py](https://github.com/langchain-ai/langchain/blob/27944cb611ee8face34fbe764c83e37841f96eb7/libs/langchain/langchain/vectorstores/redis/__init__.py) on line 1

current: `from .base import Redis`
suggestion update: `from .base import Redis, RedisVectorStoreRetriever`
Add option to disable question augmentation in ConversationalRetrievalQAChain
Labels: name: auto:improvement, name: area: models

              I think it'd better if there was a flag in the ConversationalRetreivalQAChain() where we can choose to not select the chain of question rephrasing before generation. Can this be considered as an issue and dealt with accordingly?

_Originally posted by @AshminJayson in https://github.com/langchain-ai/langchain/issues/4076#issuecomment-1705339045_
Issue: How to configure Amazon SageMaker endpoint
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

#1. Open terminal, install bedrock specific version boto3 SDK,langchain
curl -sS https://d2eo22ngex1n9g.cloudfront.net/Documentation/SDK/bedrock-python-sdk.zip > sdk.zip
sudo yum install unzip -y
unzip sdk.zip -d sdk 
pip install --no-build-isolation --force-reinstall ./sdk/awscli-*-py3-none-any.whl  ./sdk/boto3-*-py3-none-any.whl ./sdk/botocore-*-py3-none-any.whl
pip install --quiet langchain==0.0.249
#pip install 'jupyter-ai>=1.0,<2.0' # If you use JupyterLab 3pip install jupyter-ai # If you use JupyterLab 4
#2. change the default token count to 1024
vi ~/anaconda3/lib/python3.11/site-packages/langchain/llms/sagemaker_endpoint.py
Insert below lines after body = self.content_handler.transform_input(prompt, _model_kwargs)
        parameters={"max_new_tokens": 1024, "top_p": 0.9, "temperature": 0.6, "return_full_text": True}
        t = json.loads(body)
        t["parameters"] = parameters
        body = json.dumps(t)
Insert the line CustomAttributes='accept_eula=true’,  between Accept=accepts, and **_endpoint_kwargs,
#3. aws configure default profile,  make sure the aksk has enough permissions(SageMakerFullAccess)
aws configure
#4.run %%ai in *.ipynb file on ec2 instead of SageMaker notebook instance / SageMaker Studio [also can run in VSCODE] after making sure your Amazon SageMaker endpoint is health
%load_ext jupyter_ai
%%ai sagemaker-endpoint:jumpstart-dft-meta-textgeneration-llama-2-7b --region-name=us-east-1 --request-schema={"inputs":"<prompt>"} --response-path=[0]['generation']
write somthing on Humor


### Suggestion:

_No response_
Update Banana.dev docs to latest correct usage
Labels: name: lgtm, name: auto:documentation, name: area: models

- Description: this PR updates all Banana.dev-related docs to match the latest client usage. The code in the docs before this PR were out of date and would never run.
- Issue: [#6404](https://github.com/langchain-ai/langchain/issues/6404)
- Dependencies: -
- Tag maintainer:  
- Twitter handle: [BananaDev_ ](https://twitter.com/BananaDev_ )
<!-- 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.
 -->
Issue: how to configure Amazon Bedrock
Labels: name: auto:question, name: auto:documentation, name: area: models

### Issue you'd like to raise.

how to configure Amazon Bedrock step by step:
Answers:
#1. Open terminal, install bedrock specific version boto3 SDK,langchain
curl -sS https://d2eo22ngex1n9g.cloudfront.net/Documentation/SDK/bedrock-python-sdk.zip > sdk.zip
sudo yum install unzip -y
unzip sdk.zip -d sdk 
pip install --no-build-isolation --force-reinstall ./sdk/awscli-*-py3-none-any.whl  ./sdk/boto3-*-py3-none-any.whl ./sdk/botocore-*-py3-none-any.whl
pip install --quiet langchain==0.0.249
#pip install 'jupyter-ai>=1.0,<2.0' # If you use JupyterLab 3pip install jupyter-ai # If you use JupyterLab 4
#2. change the default token count to 2048
vi ~/anaconda3/lib/python3.11/site-packages/langchain/llms/bedrock.py
change  this line:  input_body["max_tokens_to_sample"] = 2048
#3. aws configure default profile, make sure the aksk has enough permissions(BedrockFullAccess)
aws configure
#4.run %%ai in *.ipynb file on ec2/local machine [also can run in VSCODE] instead of SageMaker notebook instance / SageMaker Studio
%load_ext jupyter_ai
%%ai bedrock:anthropic.claude-v2
Write something about Amazon



### Suggestion:

_No response_
Integration with ElevenLabs text to speech
Labels: name: auto:enhancement, name: area: models

  - Description: adds integration with ElevenLabs text-to-speech [component](https://github.com/elevenlabs/elevenlabs-python) in the similar way it has been already done for [azure cognitive services](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/tools/azure_cognitive_services/text2speech.py)
  - Dependencies: elevenlabs
  - Twitter handle: @deepsense_ai, @matt_wosinski
  - Future plans: refactor both implementations in order to avoid dumping speech file, but rather to keep it in memory.
MyScale hot fix on type check
Labels: name: area: vector store, 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/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.
 -->
 Previous PR #9353 has incomplete type checks and deprecation warnings. This PR will fix those type check and add deprecation warning to myscale vectorstore
An error occurred: not enough values to unpack (expected 2, got 1) 
Labels: name: area: agent, name: auto:bug, name: area: models

### System Info

langchain                     0.0.279

### Who can help?

@agola11
@hwchase17

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

### Reproduction

def ask_local_vector_db(question):
    # old docsearch_db
    docs = docsearch_db.similarity_search(question, k=10)
    pretty_print_docs(docs)
    print("**************************************************")

    cleaned_matches = []
    total_toknes = 0
    # print(docs)
    for context in docs:
        cleaned_context = context.page_content.replace('\n', ' ').strip()

        cleaned_context = f"{cleaned_context}"
        tokens = tokenizers.encode(cleaned_context, add_special_tokens=False)
        if total_toknes + len(tokens) <= (1536 * 8):
            cleaned_matches.append(cleaned_context)
            total_toknes += len(tokens)
        else:
            break

    # 将清理过的匹配项组合合成一个字符串
    combined_text = " ".join(cleaned_matches)

    answer = local_chain.predict(combined_text=combined_text, human_input=question)
    return answer


# 创建工具列表
tools = [
    Tool(
        name="Google_Search",
        func=GoogleSerper_search.run,
        description="""
        当你用本地向量数据库问答后说无法找到答案的之后，你可以使用互联网搜索引擎工具进行信息查询,尝试直接找到问题答案。 
        注意你需要提出非常有针对性准确的问题。
        """,
    ),
    Tool(
        name="Local_Search",
        func=ask_local_vector_db,
        description="""
        你可以首先通过本地向量数据知识库尝试寻找问答案。 
        注意你需要提出非常有针对性准确的问题
        """
    )
]

agent_kwargs = {
    "extra_prompt_messages": [MessagesPlaceholder(variable_name="memory")],
}
memory = ConversationBufferMemory(memory_key="memory", return_messages=True)

# 初始化agent代理
agent_open_functions = initialize_agent(
    tools,
    llm=llm,
    agent=AgentType.OPENAI_FUNCTIONS,
    verbose=True,
    agent_kwargs=agent_kwargs,
    memory=memory,
    max_iterations=10,
    early_stopping_method="generate",
    handle_parsing_errors=True,  # 初始化代理并处理解析错误
    callbacks=[handler],
)

### Expected behavior

请输入您的问题（纯文本格式），换行输入 n 以结束：
本地搜索gpt
n
===============Thinking===================


> Entering new AgentExecutor chain...

Invoking: `Local_Search` with `gpt`


An error occurred: not enough values to unpack (expected 2, got 1)
请输入您的问题（纯文本格式），换行输入 n 以结束：
fix ChatMessageChunk concat error
Labels: name: auto:bug, name: area: models

<!-- 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.
 -->

- Description: fix `ChatMessageChunk` concat error 
- Issue: #10173 
- Dependencies: None
- Tag maintainer: @baskaryan, @eyurtsev, @rlancemartin
- Twitter handle: None