langchain/libs/community/tests/unit_tests/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
konko.py
test_anthropic.py core,integrations[minor]: Dont error on fields in model_kwargs (#27110) 2024-10-04 11:30:27 -07:00
test_azureml_endpoint.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_azureopenai.py
test_baichuan.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_bedrock.py
test_cloudflare_workersai.py standard-tests: rename langchain_standard_tests to langchain_tests, release 0.3.2 (#28203) 2024-11-18 19:10:39 -08:00
test_dappier.py
test_deepinfra.py community[patch]: fix model initialization bug for deepinfra (#25727) 2024-08-28 02:02:35 -07:00
test_edenai.py
test_ernie.py
test_fireworks.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_friendli.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_google_palm.py
test_huggingface.py
test_hunyuan.py Feature/update hunyuan (#25779) 2024-09-02 12:55:08 +00:00
test_imports.py community: Outlines integration (#27449) 2024-11-20 16:31:31 -05:00
test_kinetica.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_litellm.py standard-tests: rename langchain_standard_tests to langchain_tests, release 0.3.2 (#28203) 2024-11-18 19:10:39 -08:00
test_llama_edge.py
test_mlflow.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_mlx.py
test_naver.py community: Add Naver chat model & embeddings (#25162) 2024-10-24 20:54:13 +00:00
test_oci_data_science.py infra: migrate to uv (#29566) 2025-02-06 13:36:26 -05:00
test_oci_generative_ai.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_oci_model_deployment_endpoint.py community: Update OCI data science integration (#27083) 2024-10-15 08:32:54 -07:00
test_octoai.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_ollama.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_openai.py
test_outlines.py community: Outlines integration (#27449) 2024-11-20 16:31:31 -05:00
test_perplexity.py community: fix perplexity response parameters not being included in model response (#30440) 2025-03-26 22:28:08 -04:00
test_premai.py multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
test_reka.py community: add reka chat model integration (#27379) 2024-11-15 13:37:14 -05:00
test_snowflake.py
test_sparkllm.py community: Fix the failure of ChatSparkLLM after upgrading to Pydantic V2 (#27418) 2024-10-23 21:17:10 -04:00
test_tongyi.py community: make DashScope models support Partial Mode for text continuation. (#30108) 2025-03-05 16:22:14 +00:00
test_writer.py community[patch]: fix import in test (#28339) 2024-11-25 19:28:01 +00:00
test_yandex.py infra: migrate to uv (#29566) 2025-02-06 13:36:26 -05:00
test_yuan2.py community:yuan2[patch]: standardize init args (#21462) 2024-08-23 17:56:19 +00:00
test_zhipuai.py community[patch]: Add ToolMessage for ChatZhipuAI (#25547) 2024-08-19 11:26:38 -04:00