delayedkarma/langchain-issues huggingface dataset:
LLM cache includes `azure_ad_token` in caching key which may frequently change across identical requests.
Labels: name: auto:bug, name: area: models

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

None

### Description

* I am using the `AzureChatOpenAI` integration combined with the `SQLiteCache`.
* I noticed that the cache was working as intended within a single script invocation but not across multiple script invocations.
* I looked at what was being used as the cache key by inspecting what was being passed to the `SQLAlchemyCache.update()` method in the `llm_string` argument. Included is the `azure_ad_token` field used to initialise the `AzureChatOpenAI` class:

```
{"lc": 1, "type": "constructor", "id": ["langchain", "chat_models", "azure_openai", "AzureChatOpenAI"], "kwargs": {"azure_ad_token": "<removed>", "azure_endpoint": "<removed>", "openai_api_version": "2023-09-01-preview", "model": "gpt-4-0613", "temperature": 0.0, "max_tokens": 2000, "openai_api_type": "azure"}}---[('stop', **None)]**
```

* Our workflow involves rotating the `azure_ad_token` for every script invocation which is invalidating any cache matches.

The `azure_ad_token` field does not have any effect on the model output and is thus not needed and should not be included in the caching key.

### System Info

N/A

### 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
Langchain partner libraries (langchain-openai etc.) missing license field pyproject.toml files
Labels: name: auto:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

Not applicable

### Description

The pyproject.toml files of the langchain partner libraries (langchain-openai etc.) are missing a license field. This prevents acceptance with some automated package scanning software.

### System Info

Not applicable

### 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
The `dict` method is deprecated; use `model_dump` instead [pydantic]
Labels: name: auto:bug, name: area: models

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

The followiwng simple example will log the warning:

```python
from langchain_openai import AzureChatOpenAI
from langchain.schema import HumanMessage

chat_llm = AzureChatOpenAI()

chat_llm.invoke([HumanMessage(content='howdy!')])
```


### Description

I'm seeing a few warning logs saying that langchain-openai is using a deprecated method from pydantic: `dict`

```txt
.venv/Lib/site-packages/langchain_openai/chat_models/azure.py:199: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/
    response = response.dict()

tests/test_zllm_completion.py::test_prompt
  .venv/Lib/site-packages/langchain_openai/llms/base.py:344: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/
    response = response.dict()
```

Here:

https://github.com/langchain-ai/langchain/blob/7b084b4cc768a8e5cddc29bfdfb6e5dc1003a5d9/libs/partners/openai/langchain_openai/chat_models/azure.py#L199

And here:

https://github.com/langchain-ai/langchain/blob/7b084b4cc768a8e5cddc29bfdfb6e5dc1003a5d9/libs/partners/openai/langchain_openai/llms/base.py#L344

(There might me other cases)

### System Info

langchain==0.1.0
Microsoft Windows 11 Pro
Python 3.11.3

### 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
[Feature Request] Cloudflare AI Gateway
Labels: name: auto:enhancement, name: area: models

### Feature request

Support Cloudflare AI Gateway's endpoint `https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY`

See https://developers.cloudflare.com/ai-gateway/providers/universal/

### Motivation

CF Workers AI (https://developers.cloudflare.com/workers-ai/get-started/rest-api/) is currently supported via the `CloudflareWorkersAI`, 

Cloudflare AI Gateway is a different product with a different API (`CloudflareWorkersAI` with a custom `endpoint_url` won't work), and is currently unsupported.

### Your contribution

Yes I can make a PR.
community: Add PolygonLastQuote Tool and Toolkit
Labels: name: area: agent, name: auto:enhancement, name: size:L

**Description:** 
In this PR, I am adding a `PolygonLastQuote` Tool, which can be used to get the latest price quote for a given ticker / stock. 

Additionally, I've added a Polygon Toolkit, which we can use to encapsulate future tools that we build for Polygon.

**Twitter handle:** [@virattt](https://twitter.com/virattt)
Add the 'id' attribute to the Document class.
Labels: name: integration: weaviate, name: area: doc loader, name: auto:improvement

### Feature request

Add the 'id' attribute to the Document class. Or add a method to get id.

### Motivation

Adding an 'id' attribute makes data manipulation easier.
When using the Weaviate database, I need to manually set additional parameters to query the 'id', and it's not convenient to use.

### Your contribution

At the moment, there isn't one. I'd like to discuss this issue first.
not able to use local llm endpoints in chains
Labels: name: auto:bug, name: area: models

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

qa_chain = (
            RunnablePassthrough.assign(context=( lambda x: format_docs(x["context"])))
            | rag_prompt
            | local_llm_api()
            | StrOutputParser()
            )


### Description

I am trying to call my local api endpoint in the qa chain. 
The return type of the endpoint is a dict of list.
The error i am getting is  :
Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'list'>


### System Info

python version - 3.11

### 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
integration Test CI fix

<!-- 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.
 -->
langchain[minor] - more generic streaming support

This PR introduces astream_event interface to all runnables.

Checklist:

- [x] Verify that each event has a good schema
- [x]  Verify that each event does not do unintuitive type coercsions (inputs/outputs should not be automatically upgraded to dicts). This needs to be addressed `inputs=inputs if isinstance(inputs, dict) else {"input": inputs}`
- [ ] ~~Event `data` should not be dict if it doesn't need to be, but we don't want to get this wrong in case we need to dump extra info there!~~  `data` will always be a dict, with optional keys of `input` / `output` / `chunk` depending on event type. The reason is that `input` is not always available at event start
- [x] We need to make sure that the root run also generates event information
- [x] Propagate inputs when possible in Runnables
- [x]  Tool inputs are encoded as json strings? Need to decode potentially
- [ ] Documentation

Changes downstream:

- `inputs` available in `logs` path of astream_log -- this could lead to breaking changes in langserve if langserve fails to serialize any of the messages. (If there are messages there that are well known but haven't been registered as well known messages).
- the `output` and `final_output` has been made more consistent, one could argue that this is a bug fix, but if it's widely used could cause user's code to break.

Potential Future Changes: 

* StreamingEvent add `parent_id` key which has the id of the parent runnable
* [Internal] Update the BaseTracer or create a new version of it that stops doing type
  coercions (needs to be backwards compatibility to avoid breaking existing functionality that relies on dictinoaries)
langchain: Add konlpy based text splitter for Korean text
Labels: name: area: embeddings, name: auto:improvement, name: size:M

  - **Description:** Add a text splitter based on [Konlpy](https://konlpy.org/en/latest/#start) which is a Python package for natural language processing (NLP) of the Korean language. (It is  like Spacy or NLTK for Korean)
  - **Issue:** the issue # it fixes if applicable,
  - **Dependencies:** Konlpy would have to be installed before this splitter is used,
  - **Twitter handle:** @untilhamza



If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17
docs(community): update Amadeus toolkit to langchain v0.1
Labels: name: lgtm, name: auto:documentation, name: size:L

- **Description:** docs update following the changes introduced in #15879 

<!-- 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.
 -->
Make openai extra dependency import langchain-openai
Labels: name: auto:nit, name: area: models, 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:** 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.
 -->
NB: langchain-openai pulls openai and tiktoken
community: Add PolygonAPIWrapper and get_last_quote endpoint
Labels: name: area: agent, name: lgtm, name: auto:enhancement, name: size:L

- **Description:** Added a `PolygonAPIWrapper` and an initial `get_last_quote` endpoint, which allows us to get the last price quote for a given `ticker`.  Once merged, I can add a Polygon tool in `tools/` for agents to use.
- **Twitter handle:** [@virattt](https://twitter.com/virattt)

The Polygon.io Stocks API provides REST endpoints that let you query the latest market data from all US stock exchanges.
Fix bug in login functionality
Labels: name: auto:bug, name: integration: supabase, name: size:L

<!-- 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.
 -->
Bug in langchain_community/embeddings/huggingface_hub.py  HuggingFaceHubEmbeddings.embed_query
Labels: name: area: embeddings, name: auto:bug, name: integration: aws

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

from langchain_community.embeddings import HuggingFaceHubEmbeddings
url = "https://svvwc5yh51gt1pp3.us-east-1.aws.endpoints.huggingface.cloud"
text = "You do not need a weatherman to know which way the wind blows"
token = "<my_token>"

embeddings = HuggingFaceHubEmbeddings( 
    model = url,
    huggingfacehub_api_token=token 
)
qembed = embeddings.embed_query(text)


### Description

The code above should call my HuggingFace inference endpoint and generate an embedding.  Instead, it throws:

Traceback (most recent call last):
  File "/Users/jraby/python/hfhub/callhub2.py", line 29, in <module>
    qembed = embeddings.embed_query(text)
  File "/opt/homebrew/lib/python3.10/site-packages/langchain_community/embeddings/huggingface_hub.py", line 109, in embed_query
    response = self.embed_documents([text])[0]
KeyError: 0

The "[0]" at the end of line 109 is incorrect.  self.embed_documents returns JSON, -not a list.  The first node in the JSON is 'embeddings', and it contains the list of embedding arrays.

I believe that this line:
    response = self.embed_documents([text])[0]
Should be replaced with this:
    response = self.embed_documents([text])['embeddings'][0]  

This resolves the problem for me.


### System Info

Platform = MacOS
python version  = 3.10
pip3 
huggingface_hub (0.20.2)

### 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
core[patch]: simple prompt pretty printing
Labels: name: auto:improvement, name: area: models, name: size:M

Nothing fancy. No support for partials, few shot prompts, multimodal prompts yet. Can add later if people request.

![Screenshot 2024-01-12 at 1 48 38 PM](https://github.com/langchain-ai/langchain/assets/22008038/dc22c387-4173-4549-9ff6-26b8297ac631)
community: Added new Utility runnables for NVIDIA Riva.
Labels: name: auto:enhancement, name: area: lcel, name: size:XXL

**Please tag this issue with `nvidia_genai`**

- **Description:** Added new Runnables for integration NVIDIA Riva into LCEL chains for Automatic Speech Recognition (ASR) and Text To Speech (TTS).
- **Issue:** N/A
- **Dependencies:** To use these runnables, the NVIDIA Riva client libraries are required. It they are not installed, an error will be raised instructing how to install them. The Runnables can be safely imported without the riva client libraries.
- **Twitter handle:** N/A

All of the Riva Runnables are inside a single folder in the Utilities module. In this folder are four files:
- common.py - Contains all code that is common to both TTS and ASR
- stream.py - Contains a class representing an audio stream that allows the end user to put data into the stream like a queue.
- asr.py - Contains the RivaASR runnable
- tts.py - Contains the RivaTTS runnable

The following Python function is an example of creating a chain that makes use of both of these Runnables:

```python
def create(
    config: Configuration,
    audio_encoding: RivaAudioEncoding,
    sample_rate: int,
    audio_channels: int = 1,
) -> Runnable[ASRInputType, TTSOutputType]:
    """Create a new instance of the chain."""
    _LOGGER.info("Instantiating the chain.")

    # create the riva asr client
    riva_asr = RivaASR(
        url=str(config.riva_asr.service.url),
        ssl_cert=config.riva_asr.service.ssl_cert,
        encoding=audio_encoding,
        audio_channel_count=audio_channels,
        sample_rate_hertz=sample_rate,
        profanity_filter=config.riva_asr.profanity_filter,
        enable_automatic_punctuation=config.riva_asr.enable_automatic_punctuation,
        language_code=config.riva_asr.language_code,
    )

    # create the prompt template
    prompt = PromptTemplate.from_template("{user_input}")

    # model = ChatOpenAI()
    model = ChatNVIDIA(model="mixtral_8x7b")  # type: ignore

    # create the riva tts client
    riva_tts = RivaTTS(
        url=str(config.riva_asr.service.url),
        ssl_cert=config.riva_asr.service.ssl_cert,
        output_directory=config.riva_tts.output_directory,
        language_code=config.riva_tts.language_code,
        voice_name=config.riva_tts.voice_name,
    )

    # construct and return the chain
    return {"user_input": riva_asr} | prompt | model | riva_tts  # type: ignore
```

The following code is an example of creating a new audio stream for Riva:

```python
input_stream = AudioStream(maxsize=1000)
# Send bytes into the stream
for chunk in audio_chunks:
    await input_stream.aput(chunk)
input_stream.close()
```

The following code is an example of how to execute the chain with RivaASR and RivaTTS

```python
output_stream = asyncio.Queue()
while not input_stream.complete:
    async for chunk in chain.astream(input_stream):
        output_stream.put(chunk)    
```

Everything should be async safe and thread safe. Audio data can be put into the input stream while the chain is running without interruptions.
Runnable error
Labels: name: auto:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

qa_chain = (
            RunnablePassthrough.assign(context=( lambda x: format_docs(x["context"])))
            | rag_prompt
            | custom_model_api(query)
            | StrOutputParser()
            )


### Description

I am getting the below error

Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'list'>


### System Info

python version 3.10

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