llama-stack/llama_toolchain/reward_scoring/api/endpoints.py
raghotham 2232bfa8b5
RFC-0001-The-Llama-Stack (#8)
* RFC-0001-The-Llama-Stack

* Add OpenAPI generation utility, update SPEC to reflect latest types

* First cut at an observability API

* llama3_1 -> llama3

---------

Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
2024-08-20 19:01:18 -07:00

33 lines
976 B
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import List, Protocol, Union
from .datatypes import * # noqa: F403
from llama_models.schema_utils import webmethod
@json_schema_type
class RewardScoringRequest(BaseModel):
"""Request to score a reward function. A list of prompts and a list of responses per prompt."""
dialog_generations: List[DialogGenerations]
model: str
@json_schema_type
class RewardScoringResponse(BaseModel):
"""Response from the reward scoring. Batch of (prompt, response, score) tuples that pass the threshold."""
scored_generations: List[ScoredDialogGenerations]
class RewardScoring(Protocol):
@webmethod(route="/reward_scoring/score")
def reward_score(
self,
request: RewardScoringRequest,
) -> Union[RewardScoringResponse]: ...