delayedkarma/langchain-issues huggingface dataset:
How to use tools for tasks that are dependent on each other
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

User: Help me reset my password
Agent: Please provide your account number
User: My account is Axxx
Agent: SMS verification code has been sent, please provide SMS verification code
User: 091839
Agent: Account password has been reset to 123456

The Agent is responsible for resetting the password for the user. In this example, the Agent needs to communicate back and forth with the user, such as providing an account to send a verification code, and providing a verification code to reset the password.

I added 4 tools, but when I asked any questions, all the tools were used once, which was not what I expected. I wanted to use the corresponding tool according to the specific situation.

```
> Entering new AgentExecutor chain...
{
    "action": "ResetPasswordAskTool",
    "action_input": "Axxx"
}
Observation: 请提供下您的账号：
Thought:/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:189: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.
  warn_deprecated(
{
    "action": "ReceiveUserAccountTool",
    "action_input": "Axxx"
}
Observation: 已经接收到您的账号，您提供的账号为：Axxx
Thought:/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:189: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.
  warn_deprecated(
{
    "action": "SendSmsTool",
    "action_input": "Axxx"
}
Observation: 短信验证码已发出，请查看手机收到的重置密码的短信验证码，并提供给我。
Thought:/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:189: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.
  warn_deprecated(
{
    "action": "ResetPasswordTool",
    "action_input": "123456"
}
Observation: 密码已经重置为：123321
Thought:/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:189: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.
  warn_deprecated(
{
    "action": "Final Answer",
    "action_input": "密码已经重置为：123321"
}

> Finished chain.
intermediate_steps= [(AgentAction(tool='ResetPasswordAskTool', tool_input='Axxx', log='{\n    "action": "ResetPasswordAskTool",\n    "action_input": "Axxx"\n}'), '请提供下您的账号：'), (AgentAction(tool='ReceiveUserAccountTool', tool_input='Axxx', log='{\n    "action": "ReceiveUserAccountTool",\n    "action_input": "Axxx"\n}'), '已经接收到您的账号，您提供的账号为：Axxx'), (AgentAction(tool='SendSmsTool', tool_input='Axxx', log='{\n    "action": "SendSmsTool",\n    "action_input": "Axxx"\n}'), '短信验证码已发出，请查看手机收到的重置密码的短信验证码，并提供给我。'), (AgentAction(tool='ResetPasswordTool', tool_input='123456', log='{\n    "action": "ResetPasswordTool",\n    "action_input": "123456"\n}'), '密码已经重置为：123321')]
response output= 密码已经重置为：123321
```

### Suggestion:

_No response_
community: fix myscale delete function bug
Labels: name: lgtm, name: area: vector store, name: auto:bug, name: size:XS

Now the SQL used to delete vector doc from myscale is as follow:
```sql
DELETE FROM collection WHERE id = '1' AND id = '2' AND id = '3'
```

But the expected one should be 

```sql
DELETE FROM collection WHERE id IN ('1', '2', '3')
```
class `AzureChatOpenAI` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use langchain_openai.AzureChatOpenAI instead. 
Labels: name: auto:documentation, name: area: models

### Issue with current documentation:

I created an app using AzureOpenAI, and initially, the import statement worked fine:
```
from langchain.chat_models import AzureChatOpenAI
```

My original version details were:

```
langchain==0.0.352
langchain-community==0.0.6
langchain-core==0.1.3
openai==1.6.1

```

Later, I upgraded to:

```
langchain==0.0.354
langchain-community==0.0.9
langchain-core==0.1.7
langchain-experimental==0.0.47
langchain-openai==0.0.2
openai==1.6.1

```

The upgrade led to a deprecation warning for `AzureChatOpenAI`. The suggestion was to use `langchain_openai.AzureChatOpenAI`, but trying to import it gave a `ModuleNotFoundError`. After some trial and error, I found that installing `langchain_openai` separately fixed the issue. Now, I can import `AzureOpenAI`, `AzureOpenAIEmbeddings`, and `AzureChatOpenAI`.






### Idea or request for content:

Despite my research, I couldn't find documentation mentioning the need to install `langchain_openai` separately, which wasted a lot of time and created unnecessary confusion. Sharing this issue here, hope it helps others facing a similar problem. Please add this to the documentation
How to manager the new Variables:TypeError: unsupported operand type(s) for |: 'dict' and 'str'
Labels: name: auto:bug, name: area: models, name: integration: redis

### Issue you'd like to raise.

![image](https://github.com/langchain-ai/langchain/assets/128944251/481c0c04-9cd2-4339-81eb-2b10e369c637)
![image](https://github.com/langchain-ai/langchain/assets/128944251/443caac6-ba56-4052-a465-2744841067bb)


When I deploy the server then it report the error like the above.

How can I fix it ? Thank you !

Heres my code:
`
PROMPT_TEST = """Answer the question based only on the following context:
Based on the previous {history}
Question: {question}

Following: {affection}
Totally,You could select one of the above strategy of mix one.
{format_instructions} 
"""`

`chain_with_history_stream = RunnableWithMessageHistory(
    {
        "question": itemgetter("question"),
        "affection": RunnablePassthrough()
    }
    | PROMPT_TEST | llm,
    lambda session_id: MyRedisChatMessageHistory(session_id, url=REDIS_URL),
    input_messages_key="question",
    history_messages_key="history",
    verbose=True,
    max_message_history=30,
)`

##Error feedback:
`Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/root/miniconda3/envs/xdan-chat/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/workspace/xDAN-Dreamy-Chat/app/server.py", line 254, in <module>
    {
TypeError: unsupported operand type(s) for |: 'dict' and 'str'`

### Suggestion:

_No response_
ImportError: cannot import name '_is_openai_v1'
Labels: name: area: embeddings, name: auto:bug, name: integration: aws

### System Info


Hi, I am encountering this error when trying to import anything from the `langchain.embeddings` on Amazon linux AMI with python 3.9 and `langchain==0.0.350`
```python
Traceback (most recent call last):
  File "/home/ec2-user/app/search/./app.py", line 9, in <module>
    from search import make_chain, postprocess
  File "/home/ec2-user/app/search/search.py", line 6, in <module>
    from langchain.embeddings import HuggingFaceInstructEmbeddings
  File "/home/ec2-user/.local/lib/python3.9/site-packages/langchain/embeddings/__init__.py", line 62, in <module>
    from langchain.embeddings.openai import OpenAIEmbeddings
  File "/home/ec2-user/.local/lib/python3.9/site-packages/langchain/embeddings/openai.py", line 1, in <module>
    from langchain_community.embeddings.openai import (
ImportError: cannot import name '_is_openai_v1' from 'langchain_community.embeddings.openai' (/home/ec2-user/.local/lib/python3.9/site-packages/langchain_community/embeddings/openai.py)
```
The error currently occurs when calling 
```python
from langchain.embeddings import HuggingFaceInstructEmbeddings
```

My requirements.txt file looks like this:
```
fastapi==0.105.0
lancedb==0.3.4
langchain==0.0.350
langserve==0.0.36
numpy==1.26.2
pandas==2.1.4
Requests==2.31.0
uvicorn==0.24.0.post1
```

I should note that I've tried reinstalling langchain, openai and transfomers. I've also tried python 3.10 and got the same error. 

I should also note that none of my modules are called openai.

### 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

Call `from langchain.embeddings import HuggingFaceInstructEmbeddings`  or any of the embeddings modules

### Expected behavior

Should be able to import without errors.
multiple ResponseSchema
Labels: name: auto:bug, name: area: models

### System Info

google-cloud-aiplatform==1.35.0,
langchain-0.0.354

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

### Reproduction

```python
from langchain.output_parsers import ResponseSchema, StructuredOutputParser
from langchain.prompts import PromptTemplate
from langchain.llms import VertexAI
import vertexai


class bcolors:
    SERVER = '\033[92m'
    CLIENT = '\033[93m'
    ENDC = '\033[0m'
    
source_response_schemas = [
    ResponseSchema(name="answer", description="answer to the user's question"),
    ResponseSchema(
        name="source",
        description="source used to answer the user's question, should be a website.",
    ),
]

found_response_schemas = [
    ResponseSchema(name="answer", description="answer to the user's question"),
    ResponseSchema(
        name="found",
        description="whether the model could find the proper answers or not.",
    ),
]
source_output_parser = StructuredOutputParser.from_response_schemas(source_response_schemas)
found_output_parser = StructuredOutputParser.from_response_schemas(found_response_schemas)

format_instructions = source_output_parser.get_format_instructions()
found_checker = found_output_parser.get_format_instructions()

prompt = PromptTemplate(
    template="answer the users question as best as possible.\n{found_cheker}\n{format_instructions}\n{question}",
    input_variables=["question"],
    partial_variables={"found_checker": found_checker, "format_instructions": format_instructions},
)

vertexai.init(project="my_project_id", location="us-central1")
model = VertexAI(model_name='text-bison@001', max_output_tokens=512, temperature=0.2)

chain = prompt | model | found_output_parser | source_output_parser

while 1:
    message = input(bcolors.CLIENT + "Ask to the Cooking Assistant --->> " + bcolors.ENDC)
    for s in chain.stream({"question": message}):
        print(bcolors.SERVER + "<<<<<<<  Cooking Assistant  >>>>>>", str(s) + bcolors.ENDC)
```



this code returns the error saying,
```
KeyError: "Input to PromptTemplate is missing variable 'found_cheker'.  Expected: ['found_cheker', 'question'] Received: ['question']"
```

### Expected behavior

I expect the model responses would be something like,
```
{'answer': 'proper answer', 'found': True, 'source': 'the source found.'}
```
Adding response_schemas to ChatPromptTemplate.from_messages prompt design
Labels: name: auto:improvement, name: area: models

### System Info

google-cloud-aiplatform==1.35.0,
langchain-0.0.354

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

```python
    response_schemas = [
        ResponseSchema(name="answer", description="answer to the user's question"),
        ResponseSchema(
            name="found check",
            description="boolean value (True or False) whether the data found from the reference or not.",
        ),
    ]
    output_parser = StructuredOutputParser.from_response_schemas(response_schemas)
    format_instructions = output_parser.get_format_instructions()
    
    qa_prompt = PromptTemplate(
        input_variables=[
            ("system", template),
            MessagesPlaceholder(variable_name="chat_history"),
            ("user", "{question}"),
        ],
        partial_variables={"format_instructions": format_instructions},
    )

    rag_chain = (
        RunnablePassthrough.assign(
            context=contextualized_question | temp_retriever | format_docs
        )
        | qa_prompt
        | llm
        | remove_prefix
    )
```

### Expected behavior

I expect that I could use something like ChatPromptTemplate.from_messages and response_schemas at a same time to return specific value with the conversation history based prompting.
Issue: __call__ was deprecated use invoke instead warning persists after switching to invoke
Labels: name: auto:bug, name: area: models, name: integration: pinecone

### Issue you'd like to raise.

After upgrading to langchain 0.1.0, I received depreciation warnings and updated my imports to langchain_community which cleared that error, then received depreciation warnings about __call__ to Invoke:

The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.

I switched the invoke method on the call still get some of the same depreciation warnings. Not sure how to fix this or if it's a bug. code:

```python
    qachain = RetrievalQA.from_chain_type(ollama, retriever=vectorstore.as_retriever(search_kwargs={"k": args.top_matches}))
    res = (qachain.invoke({"query": args.question}))
``` 

How do I fix this?

### Suggestion:

_No response_
For New Contributors: Update Integration Documentation
Labels: name: good first issue, name: auto:documentation

### Issue you'd like to raise.

Hello LangChain community,

We're always happy to see more folks getting involved in contributing to the LangChain codebase.

This is a good first issue if you want to learn more about how to set up
for development in the LangChain codebase.

## Goal

Your contribution will make it easier for users to use integrations with the newest LangChain syntax

## Context

As you may have noticed, we’ve recently gone to LangChain 0.1. As part of this, we want to update integration pages to be consistent with new methods. These largely include: (a) new methods for invoking integrations and chains (`invoke`, `stream`), (b) new methods for creating chains (LCEL, `create_xyz_..`).

There are a lot of integrations, so we’d love community help! This is a great way to get started contributing to the library as it will make you familiar with best practices and various integrations.

## Set up for development

There are lots of integration notebooks in https://github.com/langchain-ai/langchain/tree/master/docs/docs/integrations. After making changes there, you should run `make format` from the root LangChain directory to run our formatter.

## Shall you accept

Shall you accept this challenge, please claim one (and only one) of the modules from the list
below as one that you will be working on, and respond to this issue.

Once you've made the required code changes, open a PR and link to this issue.

## Acceptance Criteria

- Uses new methods for calling chains (`invoke`, `stream`, etc)
- Uses LCEL where appropriate
- Follows the format outlined below

## Examples

We've gotten started with some examples to show how we imagine these integration pages should look like. The exact format may look different for each type of integration, so make sure to look at the type you are working on:

- LLMs:
    - https://python.langchain.com/docs/integrations/llms/cohere
- Chat Models:
    - https://python.langchain.com/docs/integrations/chat/cohere
- Vectorstores:
    - https://python.langchain.com/docs/integrations/vectorstores/faiss
- Retrievers:
    - https://python.langchain.com/docs/integrations/retrievers/tavily
    - https://python.langchain.com/docs/integrations/retrievers/ragatouille
- Tools:
    - https://python.langchain.com/docs/integrations/tools/tavily_search
- Toolkits:
    - https://python.langchain.com/docs/integrations/toolkits/gmail
- Memory:
    - https://python.langchain.com/docs/integrations/memory/sql_chat_message_history


## Your contribution

Please sign up by responding to this issue and including the name of the module.

### Suggestion:

_No response_
community: Allow including vectors with text missing for Pinecone
Labels: name: area: vector store, name: auto:improvement, name: integration: pinecone, name: size:M

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

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,
  - **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` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

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/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
  - **Description:** 
  This PR adds the option to include vectors that don't have page content. Currently, any such vectors will be skipped. This change can be useful when you're only concerned about the similarity score and not the page content. I'm a contributor to [Rebuff](https://github.com/protectai/rebuff), and we are working on adding a standalone Python SDK. When we query Pinecone, we only need the vector scores. Currently with Langchain, if a Rebuff user sets up their Pinecone database without a metadata field named `"text"`, they will not receive any vector scores when querying Pinecone. With this PR, it won't matter the name of the metadata field used for page content.
For what it's worth, langchain-js does not skip vectors when the page content cannot be found: [pinecone.ts](https://github.com/langchain-ai/langchainjs/blob/8154c7829fc930a5b4060e830d06cbdd3e9484c4/libs/langchain-community/src/vectorstores/pinecone.ts#L230-L234).
I didn't update the Pinecone integration tests because I could not get the tests to pass (even before my changes). They were repeatedly failing because Pinecone is eventually consistent and the tests were assuming the changes would be applied immediately. 
  - **Issue:** N/A
  - **Dependencies:** No changes needed
Docs: Add missing import of 'ConfigurableField' in 'Full code comparison' example in LCEL
Labels: name: lgtm, name: auto:documentation, name: area: lcel, name: size:XS

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

Replace this entire comment with:
  - **Description:** Add missing import of 'ConfigurableField' in 'Full code comparison' example in LCEL
  - **Issue:** Example code not running
  - **Dependencies:** None
  - **Twitter handle:** @heyyoshan
community: Added python package install Tool
Labels: name: auto:enhancement, name: area: langserve, name: size:XL

# community: Added python package install **Tool**

## Description:

**PackageInstallTool**: A Dynamic Python Package Installer for Runtime Environments

**Overview**: The `PackageInstallTool` is an essential utility for dynamically installing Python packages within a runtime environment. This tool is especially beneficial in scenarios where executing Python code necessitates the use of specific packages that are not already available in the environment.

**Functionality**: 
- **Package Installation**: It allows for the installation of single or multiple Python packages. Users can input either a single package name or a list of package names.
- **Flexibility and Error Handling**: It supports both synchronous and asynchronous operations, although the asynchronous functionality is not implemented yet. The tool also includes error handling to provide feedback in case of installation issues.

**Use Case**: This tool is ideal for environments where Python code execution is dynamic, and there's a need to ensure that all necessary packages are available. It's particularly useful in interactive or automated systems where code dependencies might vary.

**How It Works**: 
1. **Input**: The tool accepts a package name or a list of package names as input.
2. **Installation Process**: It uses the `subprocess` module to call `pip install`, ensuring that the packages are installed in the current Python environment.
3. **Feedback**: Post-installation, it provides feedback on the success or failure of the installation process.

**Benefits**: 
- **Enhanced Efficiency**: Automates the package installation process, saving time and reducing manual effort.
- **Improved Reliability**: Ensures that the necessary Python packages are available when needed, enhancing the reliability of Python code execution.
community: update AzureSearch class to work with azure-search-documents=11.4.0

  - **Description:** Updates `libs/community/langchain_community/vectorstores/azuresearch.py` to support the stable version `azure-search-documents=11.4.0` 
  - **Issue:** https://github.com/langchain-ai/langchain/issues/14534, https://github.com/langchain-ai/langchain/issues/15039, https://github.com/langchain-ai/langchain/issues/15355
  - **Dependencies:** azure-search-documents>=11.4.0