Skip to content

update TranscriptionResponse output to list of words and segments ins…#181

Merged
Fesenko-A merged 2 commits into
mainfrom
develop
May 14, 2026
Merged

update TranscriptionResponse output to list of words and segments ins…#181
Fesenko-A merged 2 commits into
mainfrom
develop

Conversation

@Fesenko-A
Copy link
Copy Markdown
Contributor

@Fesenko-A Fesenko-A commented May 14, 2026

Update word and segment outputs for the 'Create transcription' action

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 464ffe58-e505-4ade-9088-cde22dc0844e

📥 Commits

Reviewing files that changed from the base of the PR and between 31e5554 and 027504e.

📒 Files selected for processing (1)
  • Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs

📝 Walkthrough

Walkthrough

The PR refactors audio transcription response handling from JSON-serialized strings to strongly-typed lists. TranscriptionResponse properties Words and Segments change from string to List<WordResponse> and List<SegmentResponse>, with supporting classes converted from records to classes with primary constructors. CreateTranscription removes Newtonsoft.Json and maps responses via null-safe projections. Tests are simplified and logging statements removed. Version updated to 2.8.43.

Changes

Audio Transcription Response Type Refactoring

Layer / File(s) Summary
Response schema: Typed lists and class declarations
Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs
TranscriptionResponse properties Words and Segments change from string to List<WordResponse> and List<SegmentResponse>. WordResponse and SegmentResponse are converted from records to classes with primary constructors. System.Collections.Generic import added.
Action implementation: Remove JSON dependency and map to typed responses
Apps.OpenAI/Actions/AudioActions.cs
CreateTranscription removes Newtonsoft.Json using directive and replaces JsonConvert.SerializeObject with null-safe LINQ projections that map response DTOs to typed lists, defaulting to empty collections when fields are absent.
Tests and version: Simplified assertions and project version bump
Tests.OpenAI/AudioServiceTests.cs, Apps.OpenAI/Apps.OpenAI.csproj
OpenAI transcription test simplified by removing diarized JSON parsing and narrowing ContextDataSource to ConnectionTypes.OpenAi. Logging statements removed from two other tests. Project version incremented from 2.8.42 to 2.8.43.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A transcription refactor hops into place,
From JSON strings to typed lists we race!
No more Newtonsoft weighs us down,
Strong types replace the serialized crown.
Words and Segments now shine so bright,
This refactoring makes the responses right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: updating TranscriptionResponse to return words and segments as lists instead of JSON-serialized strings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
Tests.OpenAI/AudioServiceTests.cs (1)

32-34: ⚡ Quick win

Strengthen this test to validate the new contract fields.

Right now it won’t catch regressions in Words/Segments population.

Suggested fix
         PrintResult(result);
         Assert.IsNotNull(result);
+        Assert.IsNotNull(result.Transcription);
+        Assert.IsNotNull(result.Words);
+        Assert.IsNotNull(result.Segments);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Tests.OpenAI/AudioServiceTests.cs` around lines 32 - 34, The test currently
only checks result is non-null and should be extended to assert the new contract
fields are populated: after PrintResult(result) and Assert.IsNotNull(result) add
assertions that result.Words and result.Segments are not null and contain
expected entries (e.g., Assert.IsNotEmpty/Assert.IsTrue(result.Words.Any()) and
similar checks for result.Segments), and optionally validate a few properties on
the first Word/Segment (like Word.Text, Word.StartTime/EndTime or
Segment.Start/End) to catch regressions in the Words/Segments population for the
AudioService test.
Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs (1)

12-15: ⚡ Quick win

Initialize non-nullable collections with empty defaults.

This makes the response model safer when instantiated outside the current action path.

Suggested fix
-    public List<WordResponse> Words { get; set; }
+    public List<WordResponse> Words { get; set; } = [];

-    public List<SegmentResponse> Segments { get; set; }
+    public List<SegmentResponse> Segments { get; set; } = [];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs` around lines 12
- 15, The Words and Segments properties on TranscriptionResponse are
non-nullable but not initialized; change their declarations (or add a
constructor) so both Words and Segments are initialized to empty lists by
default (e.g., new List<WordResponse>() and new List<SegmentResponse>()),
ensuring any new TranscriptionResponse instance has safe, non-null collections;
update the properties Words and Segments (or the TranscriptionResponse
constructor) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs`:
- Around line 11-15: The Display labels on the TranscriptionResponse properties
Words and Segments incorrectly indicate "(serialized)"; update the Display
attributes for the Words property (List<WordResponse> Words) and the Segments
property (List<SegmentResponse> Segments) to remove the "(serialized)" wording
(e.g., change to "Words" and "Segments") so the UI reflects that these are typed
lists rather than serialized strings.

---

Nitpick comments:
In `@Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs`:
- Around line 12-15: The Words and Segments properties on TranscriptionResponse
are non-nullable but not initialized; change their declarations (or add a
constructor) so both Words and Segments are initialized to empty lists by
default (e.g., new List<WordResponse>() and new List<SegmentResponse>()),
ensuring any new TranscriptionResponse instance has safe, non-null collections;
update the properties Words and Segments (or the TranscriptionResponse
constructor) accordingly.

In `@Tests.OpenAI/AudioServiceTests.cs`:
- Around line 32-34: The test currently only checks result is non-null and
should be extended to assert the new contract fields are populated: after
PrintResult(result) and Assert.IsNotNull(result) add assertions that
result.Words and result.Segments are not null and contain expected entries
(e.g., Assert.IsNotEmpty/Assert.IsTrue(result.Words.Any()) and similar checks
for result.Segments), and optionally validate a few properties on the first
Word/Segment (like Word.Text, Word.StartTime/EndTime or Segment.Start/End) to
catch regressions in the Words/Segments population for the AudioService test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dd037ac1-dc78-4d4d-8b7d-08cac35e087b

📥 Commits

Reviewing files that changed from the base of the PR and between a47167c and 31e5554.

📒 Files selected for processing (4)
  • Apps.OpenAI/Actions/AudioActions.cs
  • Apps.OpenAI/Apps.OpenAI.csproj
  • Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs
  • Tests.OpenAI/AudioServiceTests.cs

Comment thread Apps.OpenAI/Models/Responses/Audio/TranscriptionResponse.cs Outdated
@Fesenko-A Fesenko-A merged commit e8bc7d2 into main May 14, 2026
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant