Skip to content

fix(nli): expose model_name property on NLIJudge#213

Merged
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
syf2211:fix/nli-judge-model-name-property
Jul 22, 2026
Merged

fix(nli): expose model_name property on NLIJudge#213
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
syf2211:fix/nli-judge-model-name-property

Conversation

@syf2211

@syf2211 syf2211 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Add a public model_name property on NLIJudge and update faithfulness/relevancy metrics to use it instead of accessing the private _model_name attribute.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Related Issues

Closes #73

How Has This Been Tested?

  • Unit tests pass (pytest tests/unit/test_metrics/test_nli.py — 37/37 passed)
  • Linter passes on changed production files
  • Type checker passes (uv run mypy openagent_eval/)
  • Manual testing performed

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Summary

Expose NLIJudge.model_name as a read-only public accessor and route faithfulness/relevancy metadata through it.

Motivation

Faithfulness and AnswerRelevancy were reading judge._model_name, coupling metrics to private implementation details. A future NLIJudge refactor could silently break scoring via the broad except Exception fallback.

Changes

  • Add @property model_name on NLIJudge
  • Replace judge._model_name with judge.model_name in faithfulness.py and relevancy.py
  • Add test_model_name_property unit test

Tests

pytest tests/unit/test_metrics/test_nli.py  # 37 passed

Notes

  • composer-2.5 review: APPROVE
  • Minimal scope; no behavior change beyond using the public API

Add a public model_name accessor and use it in faithfulness/relevancy
metadata instead of reaching into the private _model_name attribute.

Fixes OpenAgentHQ#73
@himanshu231204

Copy link
Copy Markdown
Member

/oc review the pr in detail

@opencode-agent

Copy link
Copy Markdown

PR Review: fix/nli-judge-model-name-property

Files Changed

File Δ Change
openagent_eval/metrics/nli/judge.py:79-82 +5/-0 Adds @property model_name exposing self._model_name
openagent_eval/metrics/generation/faithfulness.py:138 +1/-1 judge._model_namejudge.model_name
openagent_eval/metrics/generation/relevancy.py:132 +1/-1 judge._model_namejudge.model_name
tests/unit/test_metrics/test_nli.py:221-224 +5/-0 Tests both custom and default model_name

Assessment: APPROVE

Strengths:

  • Correctly adds a read-only @property model_name on NLIJudge following standard Python convention
  • faithfulness.py:L138 and relevancy.py:L132 now access the public API instead of the private _model_name attribute — this is the right fix, as private attribute access is fragile
  • The test covers both paths: custom model name (via constructor) and DEFAULT_MODEL fallback
  • Minimal, focused diff (+12/-2), easy to verify
  • No behavioral change beyond switching from private→public accessor

One minor note: since _model_name is set once in __init__ and never mutated, you could simplify by renaming the attribute to model_name directly and dropping the property. But the property approach is more conventional for a public API and avoids any ambiguity — fine as-is.

No bugs, no regressions. Ship it.

New%20session%20-%202026-07-22T18%3A23%3A06.549Z
opencode session  |  github run

@himanshu231204
himanshu231204 merged commit 3d1e96a into OpenAgentHQ:main Jul 22, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @syf2211!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

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.

metrics(faithfulness/relevancy): accesses private NLIJudge._model_name attribute

2 participants