langchain/libs/community/langchain_community/chat_models
David Sánchez Sánchez 75823d580b
community: fix perplexity response parameters not being included in model response (#30440)
This pull request includes enhancements to the `perplexity.py` file in
the `chat_models` module, focusing on improving the handling of
additional keyword arguments (`additional_kwargs`) in message processing
methods. Additionally, new unit tests have been added to ensure the
correct inclusion of citations, images, and related questions in the
`additional_kwargs`.

Issue: resolves https://github.com/langchain-ai/langchain/issues/30439

Enhancements to `perplexity.py`:

*
[`libs/community/langchain_community/chat_models/perplexity.py`](diffhunk://#diff-d3e4d7b277608683913b53dcfdbd006f0f4a94d110d8b9ac7acf855f1f22207fL208-L212):
Modified the `_convert_delta_to_message_chunk`, `_stream`, and
`_generate` methods to handle `additional_kwargs`, which include
citations, images, and related questions.
[[1]](diffhunk://#diff-d3e4d7b277608683913b53dcfdbd006f0f4a94d110d8b9ac7acf855f1f22207fL208-L212)
[[2]](diffhunk://#diff-d3e4d7b277608683913b53dcfdbd006f0f4a94d110d8b9ac7acf855f1f22207fL277-L286)
[[3]](diffhunk://#diff-d3e4d7b277608683913b53dcfdbd006f0f4a94d110d8b9ac7acf855f1f22207fR324-R331)

New unit tests:

*
[`libs/community/tests/unit_tests/chat_models/test_perplexity.py`](diffhunk://#diff-dab956d79bd7d17a0f5dea3f38ceab0d583b43b63eb1b29138ee9b6b271ba1d9R119-R275):
Added new tests `test_perplexity_stream_includes_citations_and_images`
and `test_perplexity_stream_includes_citations_and_related_questions` to
verify that the `stream` method correctly includes citations, images,
and related questions in the `additional_kwargs`.
2025-03-26 22:28:08 -04:00
..
__init__.py community: Outlines integration (#27449) 2024-11-20 16:31:31 -05:00
anthropic.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
anyscale.py community[patch]: fix errors introduced by pydantic 2.10 (#28297) 2024-11-22 17:50:13 -05:00
azure_openai.py Community/Partner: Adding Azure community and partner user agent to better track usage in Python (#29561) 2025-02-07 23:28:30 +00:00
azureml_endpoint.py all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
baichuan.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
baidu_qianfan_endpoint.py community: re-arrange function call message parse logic for Qianfan (#27935) 2024-11-06 09:58:16 -05:00
bedrock.py community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
cloudflare_workersai.py multiple: enforce standards on tool_choice (#30372) 2025-03-20 17:48:59 +00:00
cohere.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
coze.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
dappier.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
databricks.py docs: Updating the imports for langchain-databricks to databricks-langchain (#29646) 2025-02-06 13:28:07 -08:00
deepinfra.py docs: updated ChatLiteLLM model_kwargs description (#29937) 2025-02-23 19:27:13 +00:00
edenai.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
ernie.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
everlyai.py anthropic[major]: support python 3.13 (#27916) 2024-11-12 14:31:07 -05:00
fake.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
fireworks.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
friendli.py community: update documentation and model IDs for FriendliAI provider (#28984) 2025-01-02 12:15:59 -05:00
gigachat.py community: Add deprecation warning for GigaChat integration in langchain-community (#28022) 2024-11-20 21:03:47 +00:00
google_palm.py docs: fix GOOGLE_API_KEY typo (#28322) 2024-11-25 09:45:22 -05:00
gpt_router.py community[patch]: fix errors introduced by pydantic 2.10 (#28297) 2024-11-22 17:50:13 -05:00
huggingface.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
human.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
hunyuan.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
javelin_ai_gateway.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
jinachat.py all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
kinetica.py community[patch]: fix errors introduced by pydantic 2.10 (#28297) 2024-11-22 17:50:13 -05:00
konko.py community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
litellm_router.py community: Fix ChatLiteLLMRouter runtime issues (#28163) 2024-12-16 18:17:39 -05:00
litellm.py community:ChatLiteLLM support output reasoning content (#30430) 2025-03-22 07:43:33 -04:00
llama_edge.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
llamacpp.py community[patch]: fix structured_output in llamacpp integration (#27202) 2024-10-08 15:16:59 -04:00
maritalk.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
meta.py docs: docstrings langchain_community update (#14889) 2023-12-19 08:58:24 -05:00
minimax.py (Community): Changing the BaseURL and Model for MiniMax (#29299) 2025-01-19 14:15:02 -05:00
mlflow_ai_gateway.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
mlflow.py Fix typo in mlflow code example in mlflow.py (#26931) 2024-09-27 12:41:39 +00:00
mlx.py community/mlx_pipeline: fix crash at mlx call (#29915) 2025-02-21 09:14:53 -05:00
moonshot.py docs: Standardize MoonshotChat docstring (#28159) 2024-12-09 18:46:25 +00:00
naver.py community: fix some features on Naver ChatModel & embedding model 2 (#29243) 2025-01-20 11:01:03 -05:00
oci_data_science.py community: add new parameter default_headers (#28700) 2024-12-18 22:33:23 +00:00
oci_generative_ai.py [oci_generative_ai] Option to pass auth_file_location (#29481) 2025-02-03 21:44:13 -05:00
octoai.py community[patch]: fix errors introduced by pydantic 2.10 (#28297) 2024-11-22 17:50:13 -05:00
ollama.py community: deprecate community ollama integrations (#26733) 2024-10-01 09:18:07 -07:00
openai.py anthropic[major]: support python 3.13 (#27916) 2024-11-12 14:31:07 -05:00
outlines.py community: make old stub for QuerySQLDataBaseTool private to skip api ref (#28711) 2024-12-13 10:43:23 -08:00
pai_eas_endpoint.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
perplexity.py community: fix perplexity response parameters not being included in model response (#30440) 2025-03-26 22:28:08 -04:00
premai.py community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
promptlayer_openai.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
reka.py multiple: enforce standards on tool_choice (#30372) 2025-03-20 17:48:59 +00:00
sambanova.py libs: add sambanova-lagchain integration package (#29417) 2025-01-27 20:34:55 +00:00
snowflake.py community: ChatSnowflakeCortex - Add streaming functionality (#27753) 2024-12-11 18:35:40 -08:00
solar.py partner: Update Upstage Model Names and Remove Deprecated Model (#29093) 2025-01-08 10:13:22 -05:00
sparkllm.py community: Fix the failure of ChatSparkLLM after upgrading to Pydantic V2 (#27418) 2024-10-23 21:17:10 -04:00
symblai_nebula.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
tongyi.py support return reasoning content for models like qwq in dashscope (#30317) 2025-03-18 11:43:10 -04:00
vertexai.py all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
volcengine_maas.py community[patch]: add stop parameter support to volcengine maas (#19052) 2024-03-17 01:58:50 +00:00
writer.py community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
yandex.py comminity[patch]: fix #25575 YandexGPTs for _grpc_metadata (#25617) 2024-08-28 18:48:10 -07:00
yi.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
yuan2.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
zhipuai.py community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00