Skip to content

Commit 09eec74

Browse files
committed
minor improvements
1 parent 94fc3d2 commit 09eec74

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

nbs/metric/decorator.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"from dataclasses import dataclass\n",
3232
"from ragas_annotator.metric import MetricResult\n",
3333
"from ragas_annotator.llm import RagasLLM\n",
34+
"from ragas_annotator.prompt.base import Prompt\n",
3435
"\n",
3536
"\n",
3637
"\n",
@@ -45,7 +46,7 @@
4546
" Returns:\n",
4647
" A decorator factory function for the specified metric type\n",
4748
" \"\"\"\n",
48-
" def decorator_factory(llm:RagasLLM, prompt, name: t.Optional[str] = None, **metric_params):\n",
49+
" def decorator_factory(llm:RagasLLM, prompt: t.Union[str, Prompt], name: t.Optional[str] = None, **metric_params):\n",
4950
" \"\"\"\n",
5051
" Creates a decorator that wraps a function into a metric instance.\n",
5152
" \n",
@@ -64,6 +65,7 @@
6465
" metric_name = name or func.__name__\n",
6566
" is_async = inspect.iscoroutinefunction(func)\n",
6667
" \n",
68+
" #TODO: Move to dataclass type implementation\n",
6769
" @dataclass\n",
6870
" class CustomMetric(metric_class):\n",
6971
" \n",
@@ -150,8 +152,8 @@
150152
"name": "stdout",
151153
"output_type": "stream",
152154
"text": [
153-
"high\n",
154-
"reason\n"
155+
"low\n",
156+
"The context or details of the user's response ('my response') are not provided, making it impossible to evaluate its helpfulness accurately.\n"
155157
]
156158
}
157159
],

ragas_annotator/metric/decorator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from dataclasses import dataclass
1313
from . import MetricResult
1414
from ..llm import RagasLLM
15+
from ..prompt.base import Prompt
1516

1617

1718

@@ -26,7 +27,7 @@ def create_metric_decorator(metric_class):
2627
Returns:
2728
A decorator factory function for the specified metric type
2829
"""
29-
def decorator_factory(llm:RagasLLM, prompt, name: t.Optional[str] = None, **metric_params):
30+
def decorator_factory(llm:RagasLLM, prompt: t.Union[str, Prompt], name: t.Optional[str] = None, **metric_params):
3031
"""
3132
Creates a decorator that wraps a function into a metric instance.
3233
@@ -45,6 +46,7 @@ def decorator(func):
4546
metric_name = name or func.__name__
4647
is_async = inspect.iscoroutinefunction(func)
4748

49+
#TODO: Move to dataclass type implementation
4850
@dataclass
4951
class CustomMetric(metric_class):
5052

0 commit comments

Comments
 (0)