1414
1515
1616class AsyncScorer :
17- """Asynchronous wrapper around a scenario scorer resource."""
17+ """A custom scorer for evaluating scenario outputs (async).
1818
19- def __init__ (
20- self ,
21- client : AsyncRunloop ,
22- scorer_id : str ,
23- ) -> None :
24- """Initialize the wrapper.
19+ Scorers define bash scripts that produce a score (0.0-1.0) for scenario runs.
20+ Obtain instances via ``runloop.scorer.create()`` or ``runloop.scorer.from_id()``.
2521
26- :param client: Generated AsyncRunloop client
22+ Example:
23+ >>> runloop = AsyncRunloopSDK()
24+ >>> scorer = await runloop.scorer.create(type="my_scorer", bash_script="echo 'score=1.0'")
25+ >>> await scorer.validate(scoring_context={"output": "test"})
26+ """
27+
28+ def __init__ (self , client : AsyncRunloop , scorer_id : str ) -> None :
29+ """Create an AsyncScorer instance.
30+
31+ :param client: AsyncRunloop client instance
2732 :type client: AsyncRunloop
28- :param scorer_id: Scorer ID returned by the API
33+ :param scorer_id: ID of the scorer
2934 :type scorer_id: str
3035 """
3136 self ._client = client
@@ -37,54 +42,36 @@ def __repr__(self) -> str:
3742
3843 @property
3944 def id (self ) -> str :
40- """Return the scorer ID .
45+ """The scorer's unique identifier .
4146
42- :return: Unique scorer ID
47+ :return: Scorer ID
4348 :rtype: str
4449 """
4550 return self ._id
4651
47- async def get_info (
48- self ,
49- ** options : Unpack [BaseRequestOptions ],
50- ) -> ScorerRetrieveResponse :
51- """Retrieve the latest scorer details.
52+ async def get_info (self , ** options : Unpack [BaseRequestOptions ]) -> ScorerRetrieveResponse :
53+ """Fetch current scorer details from the API.
5254
53- :param options: Optional request configuration
54- :return: API response describing the scorer
55+ :param options: See :typeddict:`~runloop_api_client.sdk._types.BaseRequestOptions` for available options
56+ :return: Current scorer details
5557 :rtype: ScorerRetrieveResponse
5658 """
57- return await self ._client .scenarios .scorers .retrieve (
58- self ._id ,
59- ** options ,
60- )
59+ return await self ._client .scenarios .scorers .retrieve (self ._id , ** options )
6160
62- async def update (
63- self ,
64- ** params : Unpack [SDKScorerUpdateParams ],
65- ) -> ScorerUpdateResponse :
66- """Update the scorer.
61+ async def update (self , ** params : Unpack [SDKScorerUpdateParams ]) -> ScorerUpdateResponse :
62+ """Update the scorer's type or bash script.
6763
6864 :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScorerUpdateParams` for available parameters
69- :return: API response with updated scorer details
65+ :return: Updated scorer details
7066 :rtype: ScorerUpdateResponse
7167 """
72- return await self ._client .scenarios .scorers .update (
73- self ._id ,
74- ** params ,
75- )
68+ return await self ._client .scenarios .scorers .update (self ._id , ** params )
7669
77- async def validate (
78- self ,
79- ** params : Unpack [SDKScorerValidateParams ],
80- ) -> ScorerValidateResponse :
81- """Validate the scorer with a given context.
70+ async def validate (self , ** params : Unpack [SDKScorerValidateParams ]) -> ScorerValidateResponse :
71+ """Run the scorer against the provided context and return the result.
8272
8373 :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScorerValidateParams` for available parameters
84- :return: API response with validation results
74+ :return: Validation result with score
8575 :rtype: ScorerValidateResponse
8676 """
87- return await self ._client .scenarios .scorers .validate (
88- self ._id ,
89- ** params ,
90- )
77+ return await self ._client .scenarios .scorers .validate (self ._id , ** params )
0 commit comments