Skip to content

feat: add citations support#37

Merged
StevanFreeborn merged 13 commits intomainfrom
stevanfreeborn/feat/add-citations
Jul 9, 2025
Merged

feat: add citations support#37
StevanFreeborn merged 13 commits intomainfrom
stevanfreeborn/feat/add-citations

Conversation

@StevanFreeborn
Copy link
Owner

closes #32

  • chore: update editorconfig
  • feat: initial pass at citations in request and response
  • chore: update editor config/fix analyzer suggestions
  • feat: add support for citations
  • fix: when serializing source use media type to deserialize to image or document source
  • feat: add support for citations when streaming

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
@codecov
Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.94%. Comparing base (16ee80a) to head (e351823).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…itation, SourceType, and TextSource classes

chore: update VSCode settings to exclude docs from search
…Delta, ContentBlockLocationCitation, PageLocationCitation, and DocumentContent classes
@StevanFreeborn StevanFreeborn marked this pull request as ready for review July 9, 2025 02:58
@StevanFreeborn StevanFreeborn requested a review from Copilot July 9, 2025 02:58
@StevanFreeborn StevanFreeborn self-assigned this Jul 9, 2025
@StevanFreeborn StevanFreeborn added the enhancement New feature or request label Jul 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces full citations support throughout request/response models and streaming, updates JSON converters, and adds comprehensive tests.

  • Adds new Citation models (e.g., CitationDelta, CharacterLocationCitation) and a CitationOption.
  • Extends TextContent and DocumentContent to 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, and Citations fields on DocumentContent.
  public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()

@StevanFreeborn StevanFreeborn merged commit 5b3df4a into main Jul 9, 2025
@StevanFreeborn StevanFreeborn deleted the stevanfreeborn/feat/add-citations branch July 9, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add support for citations

1 participant