Skip to content

Commit babccc9

Browse files
committed
end to end tlm
1 parent 04ae389 commit babccc9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tlm/core/types.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import abc
34
from typing import Protocol
45

56
from pydantic import BaseModel
@@ -49,25 +50,29 @@ class Scorable(Protocol):
4950
Encapsulates scores and score groups.
5051
"""
5152

53+
@abc.abstractmethod
5254
async def acalculate(self, messages: Messages, reference_answer: Completion) -> float | None:
5355
"""Calculate the score."""
5456
...
5557

58+
@abc.abstractmethod
5659
async def acost(self, messages: Messages, reference_answer_token_cost: TokenCost) -> TokenCost:
5760
"""Get the token cost of the score."""
5861
...
5962

6063

61-
class Score(Protocol, Scorable):
64+
class Score(Scorable):
6265
"""A score."""
6366

6467
config: BaseModel
6568

69+
@abc.abstractmethod
6670
def __init__(self, config: BaseModel, reference_index: int, **kwargs):
6771
"""Initialize a score."""
6872
...
6973

7074
@classmethod
75+
@abc.abstractmethod
7176
def from_config(cls, config: BaseModel, reference_index: int, **kwargs) -> Score:
7277
"""Create a score from a config."""
7378
...
@@ -78,19 +83,23 @@ class Reference(Protocol):
7883

7984
config: BaseModel
8085

86+
@abc.abstractmethod
8187
def __init__(self, config: BaseModel, reference_index: int, **kwargs):
8288
"""Initialize a reference."""
8389
...
8490

8591
@classmethod
92+
@abc.abstractmethod
8693
def from_config(cls, config: BaseModel, reference_index: int, **kwargs) -> Reference:
8794
"""Create a reference from a config."""
8895
...
8996

97+
@abc.abstractmethod
9098
async def agenerate(self, messages: Messages) -> Completion:
9199
"""Generate a reference answer."""
92100
...
93101

102+
@abc.abstractmethod
94103
async def acost(self, messages: Messages) -> TokenCost:
95104
"""Get the token cost of the reference answer."""
96105
...

0 commit comments

Comments
 (0)