delayedkarma/langchain-issues huggingface dataset:
[docs] fix reduce prompt in summarization example
Labels: name: lgtm, name: auto:documentation, name: size:XS

<!-- 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.
 -->

Small fix to _summarization_ example, `reduce_template` should use `{docs}` variable.

Bug likely introduced as following code suggests using `hub.pull("rlm/map-prompt")` instead of defined prompt.
Merge branch 'master' into pr/xsa-dev/1
Labels: name: auto:nit, name: size:M

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
  - **Tag maintainer:** for a quicker response, tag the relevant maintainer (see below),
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
RunnableBranch doesnt stream correctly
Labels: name: auto:bug, name: area: models

### System Info

LangChain Version: 0.0.339
Platform: Windows 10
Python Version: 3.10.10

### Who can help?

@agol

### 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
- [X] Chains
- [X] Callbacks/Tracing
- [X] Async

### Reproduction

I've implemented this `RunnableBranch` example: https://python.langchain.com/docs/expression_language/how_to/routing
using this `MyCallbackHandler` example: https://python.langchain.com/docs/modules/agents/how_to/streaming_stdout_final_only

For streamming I've used this `streamming` example: https://python.langchain.com/docs/modules/model_io/chat/streaming



the result becomes something like this:
```
##
#Other#
##
(Verse 1)... <the output of the question as a whole, not separated by tokens, generated all at once>
```

### Expected behavior

every single token be surrounded by ##, like this: 
```
#token1#
#token2#
...
```
fix: MergedDataLoader is compatible with load with parameters such as ConfluenceLoader
Labels: name: area: doc loader, name: auto:bug, name: size:S


Replace this entire comment with:
  - **Description:** [a description of the change, ](fix: MergedDataLoader is compatible with load with parameters such as ConfluenceLoader)
  - **Issue:** https://github.com/langchain-ai/langchain/issues/12923
  - **Dependencies:** no
  - **Tag maintainer:** 
  - **Twitter handle:** @chyroc_

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.
 -->
get token count for other LLM Models 
Labels: name: auto:enhancement, name: area: models

### Feature request

it could be better where i can add a callback to get the total token spend on other LLMS apart from OPENAI ?

### Motivation

since there is a call back for openai why don't we have for other models too just to see how much token is consumed ?

### Your contribution

Happy to contribute to the issue with PR later
Issue: <Please write a comprehensive title after the 'Issue: ' prefix>
Labels: name: area: agent, name: auto:bug, name: area: models

### Issue you'd like to raise.

Hi I am running the create_pandas_dataframe_agent agent, and the issue I'm facing is with the call back FinalStreamingStdOutCallbackHandler for some reason when I only have one civ it works fine as soon as I pass through multiple then it doesn't stream the data it just prints it all in one go.

here is my code:


```
def _get_llm(callback):
    return OpenAI(
        callbacks=[callback],
        streaming=True,
        temperature=0
    )

file_path = ['people-100.csv','organizations-100.csv']
dataframes = [pd.read_csv(path) for path in file_path]


agent = create_pandas_dataframe_agent(
            llm = _get_llm(FinalStreamingStdOutCallbackHandler()),
            df = dataframes,
            # agent_executor_kwargs={"memory": memory},
            verbose=False,
            agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
        )
print(agent.run('go in deatil on the explination of the data and give me a statistical list aswell'))
```

### Suggestion:

_No response_
feat: Add ERNIE-Bot-8K model support for ErnieBotChat.
Labels: name: lgtm, name: auto:enhancement, name: area: models, name: size:XS

 - **Description:** According to the document https://cloud.baidu.com/doc/WENXINWORKSHOP/s/6lp69is2a, add ERNIE-Bot-8K model support for ErnieBotChat.
- **Dependencies:** Before using the ERNIE-Bot-8K, you should have the model's access authority.
FIX #13709 rename xml.py-> xml_parser.py 
Labels: name: auto:bug, name: size:XS

<!-- 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.
 -->
  - **Description:**  rename langchain/output_parsers/xml.py ->  langchain/output_parsers/xml_parser.py, fix  xml.py and the imported module xml.etree.ElementTree as ET is causing the ModuleNotFoundError
  - **Issue:** [ModuleNotFoundError](https://github.com/langchain-ai/langchain/issues/13709),
  -   - **Dependencies:** no dependencies change,
Add option to prefix config keys in configurable_alts
Labels: name: auto:improvement, name: size:L

<!-- 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.
 -->
Agent as tool gives wrong result ( pandas agent)
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

I'm using 
```python 
from langchain.agents import create_pandas_dataframe_agent

pd_agent = create_pandas_dataframe_agent(OpenAI(temperature=0), 
                         df, 
                         verbose=True)

pd_agent.run('some question on dataframe')
```
```python
english_tools = [

        Tool(name="SomeNAME_1",
             func=lambda q: app.finance_chain.run(q),
             description=" Some app related description ",
             return_direct=True,
             coroutine=lambda q: app.finance_chain.arun(q),
             ),
        Tool(name="SomeNAME_2",
             func=lambda q: app.rqa(q),
             description=" Some app related description ",
             coroutine=lambda q: app.rqa_english.arun(q),
             return_direct=True
             ),
        Tool.from_function(
            name="SomeNAME_3",
            func=lambda q: app.pd_agent(q),
            description=" Some app related description",
            coroutine=lambda q: app.pd_agent.arun(q),
        )
    ]
```

when we call this agent seperatly it's gives me a good result
but when i use this agent as a tool along with other tools it's not gives consistent results, mostly wrong answer 




### Suggestion:

_No response_
ModuleNotFoundError: No module named 'xml.etree'; 'xml' is not a package
Labels: name: auto:bug, name: area: models

### System Info

Traceback (most recent call last):
  File "/Users/xxx/anaconda3/envs/kaoyan-chat/lib/python3.10/site-packages/langchain/output_parsers/xml.py", line 2, in <module>
    import xml.etree.ElementTree as ET
  File "/Users/xxx/anaconda3/envs/kaoyan-chat/lib/python3.10/site-packages/langchain/output_parsers/xml.py", line 2, in <module>
    import xml.etree.ElementTree as ET
ModuleNotFoundError: No module named 'xml.etree'; 'xml' is not a package

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

### Reproduction

llm = AzureChatOpenAI(model_name="gpt-35-turbo",
                      deployment_name="gpt-35-turbo", temperature=0.3)

tools = load_tools(["serpapi", "llm-math"], llm=llm)

### Expected behavior

i run this code and hope it can run normally, but it throw the exception. xml is not a package , i think this is beacause the python file is named xml.py , it confilct with import xml.etree.ElementTree as ET
Fix typo/line break in python code
Labels: name: lgtm, name: auto:documentation, name: size:S

<!-- 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.
 -->

- **Description:** simple modify on markdown file
- **Dependencies:** None
Add system_fingerprint in OpenAI callbacks
Labels: name: auto:enhancement

### Feature request

Given that the seed is already in beta phase, the system_fingerprint would also be highly useful in tracking deterministic responses. Suggest to add a `system_fingerprint` as part of the callbacks. https://api.python.langchain.com/en/latest/callbacks/langchain.callbacks.openai_info.OpenAICallbackHandler.html#langchain.callbacks.openai_info.OpenAICallbackHandler

### Motivation

Given that the seed is already in beta phase, the system_fingerprint would also be highly useful

### Your contribution

Proposed suggestion
fix merge None value and non None value error
Labels: name: lgtm, name: auto:bug, name: size:XS

<!-- 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: how to remain the chain in different api calls?
Labels: name: auto:question, name: area: models

### Issue you'd like to raise.

This question may be stupid but I find nothing to refer to.
I'm using langchain.chains.LLMChain in flask api, but I found that the chain will be reloaded and reconstructed if I call the api after a call. So the first question I wanna ask is how to make my LLMChain be remembered so that I can use it directly in the next call.
I tried to use session in flask, but get ```Object of type LLMChain is not JSON serializable```.
Thanks.

### Suggestion:

_No response_
Support Azure gov cloud in Azure Cognitive Search retriever
Labels: name: auto:improvement, name: size:S

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** The existing version hardcoded search.windows.net in the base url. This is not compatible with the gov cloud. I am allowing the user to override the default for gov cloud support., 
  - **Issue:** N/A, did not write up in an issue,
  - **Dependencies:** None

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: 
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/extras` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
fix merge None value and non None value error
Labels: name: auto:bug, name: size:XS

<!-- 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.
 -->
Added SQL report based querying as an option on the chain
Labels: name: area: agent, name: auto:enhancement, name: size:XXL

Summary:

1. During indexing, get description of all tables if they exist and put them in the pickle
2. When running the chain, create sql query agents for any tables that exist
3. Other improvements like fixing the "validation error" on chat history (just make it optional) and running ingestion in batches
added CrossEncoderReranker with HuggingFaceCrossEncoder and SagemakerEndpointCrossEncoder
Labels: name: auto:enhancement, name: area: models, name: size:XL

  - **Description:** Support reranking based on cross encoder models available from HuggingFace.
      - Added `CrossEncoder` schema
      - Implemented `HuggingFaceCrossEncoder` and `SagemakerEndpointCrossEncoder`
      - Implemented `CrossEncoderReranker` that performs similar functionality to `CohereRerank`
      - Added `cross-encoder-reranker.ipynb` to demonstrate how to use it. Please let me know if anything else needs to be done to make it visible on the table-of-contents navigation bar on the left, or on the card list on [retrievers documentation page](https://python.langchain.com/docs/integrations/retrievers).
  - **Issue:** N/A
  - **Dependencies:** None other than the existing ones.
OpenAIModerationChain with OpenAI SDK >= v1.0.0 Broken
Labels: name: auto:bug, name: area: models

### System Info

It appears that OpenAI's SDK v1.0.0 update introduced some needed migrations.

Running the Langchain OpenAIModerationChain with OpenAI SDK >= v1.0.0 provides the following error:
```
You tried to access openai.Moderation, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
```

After briefly reading the mitigation steps I believe the suggested migration is from `openai.Moderation.create()` -> `client.moderations.create()`. 

I believe the `validate_environment` of `OpenAIModerationChain` will want updating from ```values["client"] = openai.Moderation``` to using the recommended `client.moderations` syntax.  (https://api.python.langchain.com/en/latest/_modules/langchain/chains/moderation.html#OpenAIModerationChain) 


### Who can help?

_No response_

### Information

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

### Related Components

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

### Reproduction

With OpenAI SDK >= v1.0.0 try to use `OpenAIModerationChain` to moderate a piece of content. 

Error appears:
```
You tried to access openai.Moderation, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
```

### Expected behavior

When using `OpenAIModerationChain` with OpenAI SDK >= v1.0.0 I expect the chain to properly moderate content and not fail with an error.
[Issue] Error with Bedrock when AWS region is not specified or not in environment variable
Labels: name: auto:bug, name: area: models, name: integration: aws

### System Info

langchain version: 0.0.339
python: 3.9.17

### Who can help?

@hwchase17 @agola11 

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

When creating a Bedrock model without `region_name`
```py
llm_bedrock = Bedrock(model_id='anthropic.claude-instant-v1')
```
It errors out
```py
ValidationError: 1 validation error for Bedrock
__root__
  Could not load credentials to authenticate with AWS client. Please check that credentials in the specified profile name are valid. (type=value_error)
```

This works
```py
llm_bedrock = Bedrock(model_id='anthropic.claude-instant-v1', region_name='us-west-2')
```

The problem is from https://github.com/langchain-ai/langchain/blob/bfb980b96800020d90c9362aaad40d8817636711/libs/langchain/langchain/llms/bedrock.py#L203-L207
where `get_from_dict_or_env` raises an exception if region is neither specified nor in env and default is not set.

To fix it, change default from `None` to `session.region_name`.

### Expected behavior

No error is raised.