mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-02 01:27:14 +00:00
feat(core): Support i18n (#1327)
This commit is contained in:
@@ -4,6 +4,8 @@ from abc import ABC, abstractmethod
|
||||
from typing import Callable, List, Optional
|
||||
|
||||
from dbgpt.core import Chunk
|
||||
from dbgpt.core.awel.flow import Parameter, ResourceCategory, register_resource
|
||||
from dbgpt.util.i18n_utils import _
|
||||
|
||||
RANK_FUNC = Callable[[List[Chunk]], List[Chunk]]
|
||||
|
||||
@@ -50,6 +52,28 @@ class Ranker(ABC):
|
||||
return new_candidates
|
||||
|
||||
|
||||
@register_resource(
|
||||
_("Default Ranker"),
|
||||
"default_ranker",
|
||||
category=ResourceCategory.RAG,
|
||||
description=_("Default ranker(Rank by score)."),
|
||||
parameters=[
|
||||
Parameter.build_from(
|
||||
_("Top k"),
|
||||
"topk",
|
||||
int,
|
||||
description=_("The number of top k documents."),
|
||||
),
|
||||
# Parameter.build_from(
|
||||
# _("Rank Function"),
|
||||
# "rank_fn",
|
||||
# RANK_FUNC,
|
||||
# description=_("The rank function."),
|
||||
# optional=True,
|
||||
# default=None,
|
||||
# ),
|
||||
],
|
||||
)
|
||||
class DefaultRanker(Ranker):
|
||||
"""Default Ranker."""
|
||||
|
||||
|
Reference in New Issue
Block a user