diff --git a/docs/_static/llama-stack-spec.html b/docs/_static/llama-stack-spec.html
index 575abb51c..7ba26acb7 100644
--- a/docs/_static/llama-stack-spec.html
+++ b/docs/_static/llama-stack-spec.html
@@ -9602,29 +9602,9 @@
"RegisterScoringFunctionRequest": {
"type": "object",
"properties": {
- "scoring_fn_type": {
- "type": "string",
- "enum": [
- "custom_llm_as_judge",
- "regex_parser",
- "regex_parser_math_response",
- "equality",
- "subset_of",
- "factuality",
- "faithfulness",
- "answer_correctness",
- "answer_relevancy",
- "answer_similarity",
- "context_entity_recall",
- "context_precision",
- "context_recall",
- "context_relevancy"
- ],
- "description": "The type of scoring function to register."
- },
- "params": {
+ "fn": {
"$ref": "#/components/schemas/ScoringFnParams",
- "description": "The parameters for the scoring function."
+ "description": "The type and parameters for the scoring function."
},
"scoring_fn_id": {
"type": "string",
@@ -9659,8 +9639,7 @@
},
"additionalProperties": false,
"required": [
- "scoring_fn_type",
- "params"
+ "fn"
],
"title": "RegisterScoringFunctionRequest"
},
diff --git a/docs/_static/llama-stack-spec.yaml b/docs/_static/llama-stack-spec.yaml
index 3936a0726..e37c49100 100644
--- a/docs/_static/llama-stack-spec.yaml
+++ b/docs/_static/llama-stack-spec.yaml
@@ -6534,28 +6534,10 @@ components:
RegisterScoringFunctionRequest:
type: object
properties:
- scoring_fn_type:
- type: string
- enum:
- - custom_llm_as_judge
- - regex_parser
- - regex_parser_math_response
- - equality
- - subset_of
- - factuality
- - faithfulness
- - answer_correctness
- - answer_relevancy
- - answer_similarity
- - context_entity_recall
- - context_precision
- - context_recall
- - context_relevancy
- description: >-
- The type of scoring function to register.
- params:
+ fn:
$ref: '#/components/schemas/ScoringFnParams'
- description: The parameters for the scoring function.
+ description: >-
+ The type and parameters for the scoring function.
scoring_fn_id:
type: string
description: >-
@@ -6576,8 +6558,7 @@ components:
- E.g. {"description": "This scoring function is used for ..."}
additionalProperties: false
required:
- - scoring_fn_type
- - params
+ - fn
title: RegisterScoringFunctionRequest
RegisterShieldRequest:
type: object
diff --git a/llama_stack/apis/scoring_functions/scoring_functions.py b/llama_stack/apis/scoring_functions/scoring_functions.py
index 37c2fae84..243dc37e9 100644
--- a/llama_stack/apis/scoring_functions/scoring_functions.py
+++ b/llama_stack/apis/scoring_functions/scoring_functions.py
@@ -12,8 +12,8 @@ from typing import (
Literal,
Optional,
Protocol,
- Union,
runtime_checkable,
+ Union,
)
from pydantic import BaseModel, Field
@@ -218,7 +218,9 @@ class CommonScoringFnFields(BaseModel):
@json_schema_type
class ScoringFn(CommonScoringFnFields, Resource):
- type: Literal[ResourceType.scoring_function.value] = ResourceType.scoring_function.value
+ type: Literal[ResourceType.scoring_function.value] = (
+ ResourceType.scoring_function.value
+ )
@property
def scoring_fn_id(self) -> str:
@@ -245,13 +247,14 @@ class ScoringFunctions(Protocol):
async def list_scoring_functions(self) -> ListScoringFunctionsResponse: ...
@webmethod(route="/scoring-functions/{scoring_fn_id:path}", method="GET")
- async def get_scoring_function(self, scoring_fn_id: str, /) -> Optional[ScoringFn]: ...
+ async def get_scoring_function(
+ self, scoring_fn_id: str, /
+ ) -> Optional[ScoringFn]: ...
@webmethod(route="/scoring-functions", method="POST")
async def register_scoring_function(
self,
- scoring_fn_type: ScoringFunctionType,
- params: ScoringFnParams = None,
+ fn: ScoringFnParams,
scoring_fn_id: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
) -> ScoringFn:
@@ -259,8 +262,7 @@ class ScoringFunctions(Protocol):
Register a new scoring function with given parameters.
Only valid scoring function type that can be parameterized can be registered.
- :param scoring_fn_type: The type of scoring function to register.
- :param params: The parameters for the scoring function.
+ :param fn: The type and parameters for the scoring function.
:param scoring_fn_id: (Optional) The ID of the scoring function to register. If not provided, a random ID will be generated.
:param metadata: (Optional) Any additional metadata to be associated with the scoring function.
- E.g. {"description": "This scoring function is used for ..."}