Skip to content

Comments

REVAI-4573: Update SDKs to support new model#124

Open
Greyvend wants to merge 4 commits intodevelopfrom
REVAI-4573/source-config-migration
Open

REVAI-4573: Update SDKs to support new model#124
Greyvend wants to merge 4 commits intodevelopfrom
REVAI-4573/source-config-migration

Conversation

@Greyvend
Copy link

@Greyvend Greyvend commented Feb 19, 2026

Description of Work

Migrates the Python SDK's speech-to-text submit_job_url to use source_config instead of media_url, enabling support for the v3 transcriber (machine_v3). Also fixes the verbatim option to be sent when explicitly set to False (previously skipped due to a falsy check).

What Changed

  • src/rev_ai/apiclient.py_create_job_options_payload:
    • media_url param now builds source_config: {url: media_url} in the payload instead of sending media_url directly
    • Added conflict validation: raises ValueError if both media_url and source_config are provided
    • Fixed if verbatim:if verbatim is not None: so verbatim=False is correctly sent to the API
  • Tests (TDD approach — tests committed first, verified failing, then implementation committed):
    • Updated existing assertions from media_url to source_config in job, summarization, and translation tests
    • Added new tests: media_url/source_config conflict, verbatim=True, verbatim=False, verbatim=None

Screenshots

Integration test script (test_source_config_migration.py)

"""
REVAI-4573: Integration test script for source_config migration.

Demonstrates that submit_job_url now sends source_config instead of media_url,
enabling v3 transcriber support. Also verifies verbatim=False is sent correctly
and that media_url + source_config conflict raises ValueError.
"""

import sys
sys.path.insert(0, 'src')

from rev_ai import apiclient
from rev_ai.models.customer_url_data import CustomerUrlData

LOCAL_API = "http://localhost:5000"
TOKEN = "<your_token>"
MEDIA_URL = "https://www.rev.ai/FTC_Sample_1.mp3"


def test_submit_job_url_sends_source_config():
    """Test 1: submit_job_url(media_url=...) sends source_config in payload."""
    print("=" * 60)
    print("TEST 1: submit_job_url sends source_config instead of media_url")
    print("=" * 60)
    client = apiclient.RevAiAPIClient(TOKEN, url=LOCAL_API)
    try:
        job = client.submit_job_url(
            media_url=MEDIA_URL,
            transcriber='machine_v3',
            language='en'
        )
        print(f"  Job ID:     {job.id}")
        print(f"  Status:     {job.status}")
        print(f"  Created:    {job.created_on}")
        print("  RESULT: PASS")
    except Exception as e:
        print(f"  Response/Error: {e}")
        print("  RESULT: FAIL (see error above)")
    print()


def test_submit_job_url_with_source_config_object():
    """Test 2: submit_job_url(source_config=CustomerUrlData(...)) still works."""
    print("=" * 60)
    print("TEST 2: submit_job_url with source_config object directly")
    print("=" * 60)
    client = apiclient.RevAiAPIClient(TOKEN, url=LOCAL_API)
    try:
        job = client.submit_job_url(
            source_config=CustomerUrlData(
                url=MEDIA_URL,
                auth_headers={"Authorization": "Bearer media_token"}
            ),
            transcriber='machine_v3',
            language='en'
        )
        print(f"  Job ID:     {job.id}")
        print(f"  Status:     {job.status}")
        print(f"  Created:    {job.created_on}")
        print("  RESULT: PASS")
    except Exception as e:
        print(f"  Response/Error: {e}")
        print("  RESULT: FAIL (see error above)")
    print()


def test_media_url_and_source_config_conflict():
    """Test 3: Passing both media_url and source_config raises ValueError."""
    print("=" * 60)
    print("TEST 3: media_url + source_config conflict raises ValueError")
    print("=" * 60)
    client = apiclient.RevAiAPIClient(TOKEN, url=LOCAL_API)
    try:
        client.submit_job_url(
            media_url=MEDIA_URL,
            source_config=CustomerUrlData(url=MEDIA_URL)
        )
        print("  RESULT: FAIL (no error raised)")
    except ValueError as e:
        print(f"  ValueError: {e}")
        print("  RESULT: PASS")
    except Exception as e:
        print(f"  Unexpected error: {e}")
        print("  RESULT: FAIL")
    print()


def test_verbatim_false_is_sent():
    """Test 4: verbatim=False is included in the payload."""
    print("=" * 60)
    print("TEST 4: verbatim=False is sent in payload")
    print("=" * 60)
    client = apiclient.RevAiAPIClient(TOKEN, url=LOCAL_API)
    try:
        job = client.submit_job_url(
            media_url=MEDIA_URL,
            transcriber='machine_v3',
            verbatim=False,
            language='en'
        )
        print(f"  Job ID:     {job.id}")
        print(f"  Status:     {job.status}")
        print(f"  Verbatim:   {job.verbatim}")
        print("  RESULT: PASS")
    except Exception as e:
        print(f"  Response/Error: {e}")
        print("  RESULT: FAIL (see error above)")
    print()


if __name__ == '__main__':
    print(f"Rev AI Python SDK — source_config migration test")
    print(f"API endpoint: {LOCAL_API}")
    print()
    test_submit_job_url_sends_source_config()
    test_submit_job_url_with_source_config_object()
    test_media_url_and_source_config_conflict()
    test_verbatim_false_is_sent()
    print("All tests completed.")

Test run output (against local API on localhost:5000)

Rev AI Python SDK — source_config migration test
API endpoint: http://localhost:5000

============================================================
TEST 1: submit_job_url sends source_config instead of media_url
============================================================
  Job ID:     NhZpnf4hLCQV
  Status:     in_progress
  Created:    2026-02-19T13:12:09.322Z
  RESULT: PASS

============================================================
TEST 2: submit_job_url with source_config object directly
============================================================
  Job ID:     gUDieEdBoHeo
  Status:     in_progress
  Created:    2026-02-19T13:12:09.338Z
  RESULT: PASS

============================================================
TEST 3: media_url + source_config conflict raises ValueError
============================================================
  ValueError: media_url is not compatible with source_config. Use source_config for all URL-based submissions.
  RESULT: PASS

============================================================
TEST 4: verbatim=False is sent in payload
============================================================
  Job ID:     QGgphget9T0I
  Status:     in_progress
  Verbatim:   False
  RESULT: PASS

All tests completed.

Additional Comments

Changes are scoped to the speech-to-text API client only (RevAiAPIClient). The GenericApiClient used by language identification, sentiment analysis, and topic extraction clients is untouched.

Greyvend and others added 2 commits February 19, 2026 12:56
TDD red phase: tests expect source_config instead of media_url in STT
payload, verbatim=False to be included, and media_url/source_config
conflict to raise ValueError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- submit_job_url now sends source_config: {url: media_url} instead of
  media_url directly, enabling v3 transcriber (machine_v3) support
- Raise ValueError when both media_url and source_config are provided
- Fix verbatim to be sent when False (was skipped due to falsy check)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Greyvend Greyvend requested a review from a team as a code owner February 19, 2026 12:57
@Greyvend Greyvend requested a review from dmtrrk February 19, 2026 13:20
@Greyvend
Copy link
Author

@dmtrrk the CI builds are failing. There is some dependency problem with the setup. Should we address that as well?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dmtrrk
Copy link
Contributor

dmtrrk commented Feb 19, 2026

@dmtrrk the CI builds are failing. There is some dependency problem with the setup. Should we address that as well?

yes, looks like this should be a good time to update the workflow. let's just call pytest direwctly, e.g.

- name: Test
  run: python -m pytest -q

The pytest-runner package and setup.py's tests_require/test_suite options
are deprecated and incompatible with newer setuptools versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
if verbatim:
if verbatim is not None:
payload['verbatim'] = verbatim
if rush:
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like we need to make this fix to all boolean options

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.

2 participants