langchain/libs/community/langchain_community
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
..
adapters community: Add the additonnal kward 'context' for openai (#28351) 2024-12-02 16:43:30 -05:00
agent_toolkits fixes#30182: update tool names to match OpenAI function name pattern (#30183) 2025-03-08 20:48:25 -05:00
agents community: add truncation params when an openai assistant's run is created (#28158) 2024-11-27 10:53:53 -05:00
callbacks community: Add cost data for aws bedrock anthropic.claude-3-7 model (#30016) 2025-02-27 09:51:52 -05:00
chains community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
chat_loaders community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
chat_message_histories community: uuidv1 is unsafe (#30432) 2025-03-22 15:27:49 -04:00
chat_models community: fix perplexity response parameters not being included in model response (#30440) 2025-03-26 22:28:08 -04:00
cross_encoders multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
docstore infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
document_compressors Community: RankLLMRerank AttributeError (Handle list-based rerank results) (#29840) 2025-02-20 12:38:31 -05:00
document_loaders community: Azure Document Intelligence parser features not available fixed (#30370) 2025-03-26 14:40:14 -04:00
document_transformers community: fallback on core async atransform_documents method for MarkdownifyTransformer (#27866) 2024-12-13 22:32:22 +00:00
embeddings Update ascend.py (#30060) 2025-03-01 14:10:41 -05:00
example_selectors multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
graph_vectorstores community: deprecate graph vector store (#30328) 2025-03-25 13:52:54 +00:00
graphs community: Add edge properties to the gremlin graph schema (#30449) 2025-03-24 19:03:01 -04:00
indexes community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
llms Add request_id field to improve request tracking and debugging (for Tongyi model) (#30110) 2025-03-05 11:03:47 -05:00
memory community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
output_parsers multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
query_constructors community: refactor opensearch query constructor to use wildcard instead of match in the contain comparator (#26653) 2024-12-16 11:16:34 -05:00
retrievers community[fix]: Handle None value in raw_content from Tavily API response (#30021) 2025-02-27 10:53:53 -05:00
storage community: Bump ruff version to 0.9 (#29206) 2025-02-08 01:21:10 +00:00
tools community[fix] : Pass API_KEY as argument (#30272) 2025-03-13 22:19:31 +00:00
utilities community: fix Jira API wrapper failing initialization with cloud param (#30117) 2025-03-05 10:49:25 -05:00
utils community: Use Blockbuster to detect blocking calls in asyncio during tests (#29609) 2025-02-08 01:10:39 +00:00
vectorstores feature: added warning when duckdb is used as a vectorstore without pandas (#30435) 2025-03-22 19:27:21 +00:00
__init__.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
cache.py cosmosdbnosql: Added Cosmos DB NoSQL Semantic Cache Integration with tests and jupyter notebook (#24424) 2024-12-16 21:57:05 -05:00
py.typed