Skip to content

Conversation

@BloggerBust
Copy link
Contributor

This PR introduces a unified opt-in interface for structured outputs across all model
providers.

Overview

  • Adds generate_with_schema() and a_generate_with_schema() to the base model
    layer with automatic fallback for providers that don’t yet support schema args.
  • Introduces capability flags (supports_structured_outputs, supports_json_mode)
    for provider introspection and gradual rollout.
  • Centralizes try/except schema handling, cost tracking and JSON fallback logic via
    gen_and_extract() and a_gen_and_extract() helpers in metrics/utils.py.

In Progress ( this PR is in DRAFT )

  • Extend schema opt-in to all remaining model providers
  • Migrate remaining metrics to the new interface.
  • Add safety-net tests to validate fallback and async behavior.
  • Document structured-output opt-in for future contributors.

Core benefit
This migration eliminates redundant parsing logic across metrics and models, establishes a unified structured output interface, and moves all provider specific behavior into the model layer. By introducing capability flags and opt-in schema helpers, metrics become provider agnostic, future proof, and free of branching logic. This design enables smarter routing, clearer telemetry, and ease of adoption of new provider capabilities without the need of further metric changes.

- Add schema helpers to base models: generate_with_schema / a_generate_with_schema
  with graceful fallback when providers don’t accept `schema`.
- Introduce capability flags via supports_structured_outputs / supports_json_mode for model opt-in.
- OpenAI: opt-in based on allowlists
- Tests: parameterized capability checks across all declared models
via both sync/async schema-path
  tests for structured outputs and JSON mode asserting correct response_format and code path.
…sational GEval via model opt-in

- Use generate_with_schema/a_generate_with_schema for steps and scoring
- Normalize Pydantic vs JSON outputs consistently
- Track evaluation cost where applicable
- Remove legacy native/non-native branching and TypeError fallbacks
…tion helpers

Refactored structured-output metrics to use the new model opt-in
interface.

- Unified cost calculation and structured-output fallback logic
- Introduced gen_and_extract / a_gen_and_extract helpers for sync and async
- Simplified schema extraction via consistent pattern across metrics

The remaining metrics will be updated following the pattern
established in this commit.
@vercel
Copy link

vercel bot commented Oct 22, 2025

@BloggerBust is attempting to deploy a commit to the Confident AI Team on Vercel.

A member of the Team first needs to authorize it.

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