文档

排序服务

更新时间:

AI搜索开放平台支持通过SDK的方式调用排序服务。

前提条件

已开通AI搜索开放平台服务,具体操作请参见开通服务

已通过API-KEY完成身份鉴权,获取鉴权信息请参见获取API-KEY

参数说明

  • 请求体body最大不能超过8MB。

  • 更多参数说明请参见排序服务

from alibabacloud_tea_openapi.models import Config
from alibabacloud_searchplat20240529.client import Client
from alibabacloud_searchplat20240529.models import GetDocumentRankRequest

if __name__ == '__main__':
    # token配置,endpoint配置
    config = Config(bearer_token="替换为您的API-KEY",
                    # endpoint: 配置统一的请求入口 需要去掉http://
                    endpoint="替换API访问地址",
                    # 支持 protocol 配置 HTTPS/HTTP
                    protocol="http")
    client = Client(config=config)

    # --------------- 请求体参数 ---------------
    request = GetDocumentRankRequest(docs=["test", "text"], query="test")

    # default:替换工作空间名称, ops-bge-reranker-larger: 服务id
    response = client.get_document_rank("default", "ops-bge-reranker-larger", request)
    print(response)