anthropic[patch]: support citations in streaming (#29591)

This commit is contained in:
ccurme
2025-02-05 09:12:07 -05:00
committed by GitHub
parent 5ae4ed791d
commit 5cbe6aba8f
4 changed files with 59 additions and 17 deletions

View File

@@ -649,3 +649,12 @@ def test_citations() -> None:
assert isinstance(response, AIMessage)
assert isinstance(response.content, list)
assert any("citations" in block for block in response.content)
# Test streaming
full: Optional[BaseMessageChunk] = None
for chunk in llm.stream(messages):
full = chunk if full is None else full + chunk
assert isinstance(full, AIMessageChunk)
assert isinstance(full.content, list)
assert any("citations" in block for block in full.content)
assert not any("citation" in block for block in full.content)