Quick start

更新时间:
复制 MD 格式

Make your first API call using the AI Search Open Platform Python SDK. This guide uses the document split service (ops-document-split-001) as an example.

Prerequisites

Before you begin, make sure you have:

Install the SDK

pip install alibabacloud_tea_openapi alibabacloud_searchplat20240529

Call the document split service

Note

The request body must not exceed 8 MB.

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

if __name__ == '__main__':
    config = Config(
        bearer_token='OS-****',
        endpoint='****.platform-cn-shanghai.opensearch.aliyuncs.com',
        protocol='http'
    )

    client = Client(config=config)
    request = GetDocumentSplitRequest().from_map({
        "document": {
            "content": "test123",
            "content_type": "text"
        },
        "strategy": {
            "max_chunk_size": 300,
            "need_sentence": False
        }
    })
    response = client.get_document_split("default", "ops-document-split-001", request)
    print(response)
Note
  • Replace bearer_token with your API key. For more information, see Obtain an API key.

  • endpoint is the service invocation address of the AI Search Open Platform. For more information, see Obtain a service registration address. Note that you need to remove the http:// prefix.

What's next

  • Explore other available services and operators in the AI Search Open Platform API reference.

  • Learn how to configure chunking strategies using the max_chunk_size and need_sentence parameters.