Merged
Conversation
BREAKING CHANGE: Changed type of public Source properties. Updated `Source` property on `DocumentContent` and `ImageContent` types to use base `Source` type - include support for citing custom sources - include support for citing PDF sources - include support for citing text sources
…r document source
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
==========================================
+ Coverage 98.85% 98.94% +0.09%
==========================================
Files 81 93 +12
Lines 1479 1619 +140
Branches 127 137 +10
==========================================
+ Hits 1462 1602 +140
Misses 5 5
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…itation, SourceType, and TextSource classes chore: update VSCode settings to exclude docs from search
…Delta, ContentBlockLocationCitation, PageLocationCitation, and DocumentContent classes
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces full citations support throughout request/response models and streaming, updates JSON converters, and adds comprehensive tests.
- Adds new
Citationmodels (e.g.,CitationDelta,CharacterLocationCitation) and aCitationOption. - Extends
TextContentandDocumentContentto carry citations, updates converters (CitationConverter,SourceConverter,ContentDeltaConverter) and serialization options. - Integrates citation accumulation in streaming logic and adds unit/end-to-end tests for citations.
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/AnthropicClient/Models/TextContent.cs | Added Citations property to carry citation data in text content |
| src/AnthropicClient/Models/DocumentContent.cs | Switched to generic Source, added Title, Context, Citations fields |
| src/AnthropicClient/Models/Citation*.cs | New abstract Citation and concrete citation types (page, character, block) |
| src/AnthropicClient/Json/CitationConverter.cs | New converter handling citation JSON serialization/deserialization |
| src/AnthropicClient/Json/SourceConverter.cs | Extended converter to handle text, content, base64/image/document sources |
| src/AnthropicClient/Json/ContentDeltaConverter.cs | Registered CitationDelta support in delta converter |
| src/AnthropicClient/AnthropicApiClient.cs | Updated streaming loop to accumulate citations alongside text deltas |
| tests/** | Added unit tests for all citation types and end-to-end tests for streaming |
Comments suppressed due to low confidence (2)
src/AnthropicClient/Models/ContentBlockLocationCitation.cs:12
- Fix the XML comment: remove the stray
///so the closing summary tag reads/// </summary>.
/// /// </summary>
tests/AnthropicClient.Tests/Unit/Models/DocumentContentTests.cs:113
- Add assertions to this test to verify serialization of the new
Title,Context, andCitationsfields onDocumentContent.
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #32