mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-07 19:12:09 +00:00
params -> fn
This commit is contained in:
parent
bb86aaf787
commit
124040af77
3 changed files with 16 additions and 54 deletions
27
docs/_static/llama-stack-spec.html
vendored
27
docs/_static/llama-stack-spec.html
vendored
|
@ -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"
|
||||
},
|
||||
|
|
27
docs/_static/llama-stack-spec.yaml
vendored
27
docs/_static/llama-stack-spec.yaml
vendored
|
@ -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
|
||||
|
|
|
@ -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 ..."}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue