chore: 添加虚拟环境到仓库

- 添加 backend_service/venv 虚拟环境
- 包含所有Python依赖包
- 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
2025-12-03 10:19:25 +08:00
parent a6c2027caa
commit c4f851d387
12655 changed files with 3009376 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
from typing import List
from dashscope.api_entities.dashscope_response import ReRankResponse
from dashscope.client.base_api import BaseApi
from dashscope.common.error import InputRequired, ModelRequired
from dashscope.common.utils import _get_task_group_and_task
class TextReRank(BaseApi):
task = 'text-rerank'
"""API for rerank models.
"""
class Models:
gte_rerank = 'gte-rerank'
@classmethod
def call(cls,
model: str,
query: str,
documents: List[str],
return_documents: bool = None,
top_n: int = None,
api_key: str = None,
**kwargs) -> ReRankResponse:
"""Calling rerank service.
Args:
model (str): The model to use.
query (str): The query string.
documents (List[str]): The documents to rank.
return_documents(bool, `optional`): enable return origin documents,
system default is false.
top_n(int, `optional`): how many documents to return, default return
all the documents.
api_key (str, optional): The DashScope api key. Defaults to None.
Raises:
InputRequired: The query and documents are required.
ModelRequired: The model is required.
Returns:
RerankResponse: The rerank result.
"""
if query is None or documents is None or not documents:
raise InputRequired('query and documents are required!')
if model is None or not model:
raise ModelRequired('Model is required!')
task_group, function = _get_task_group_and_task(__name__)
input = {'query': query, 'documents': documents}
parameters = {}
if return_documents is not None:
parameters['return_documents'] = return_documents
if top_n is not None:
parameters['top_n'] = top_n
parameters = {**parameters, **kwargs}
response = super().call(model=model,
task_group=task_group,
task=TextReRank.task,
function=function,
api_key=api_key,
input=input,
**parameters)
return ReRankResponse.from_api_response(response)