Skip to main content

A Python SDK for agent storage

Project description

Aliyun Tablestore Agent Storage Python SDK

A Python SDK for agent storage with support for Aliyun OSS and OTS, featuring knowledge base and document management capabilities.

Installation

pip install -e .

Quick Start

from tablestore_agent_storage import AgentStorageClient

# Initialize client with unified credentials
client = AgentStorageClient(
    access_key_id='your_access_key_id',
    access_key_secret='your_access_key_secret',
    oss_endpoint='https://oss-cn-hangzhou.aliyuncs.com',
    oss_bucket_name='your_bucket_name',
    ots_endpoint='https://your_instance.cn-hangzhou.ots.aliyuncs.com',
    ots_instance_name='your_instance_name'
)

# Create a knowledge base
response = client.create_knowledge_base({
    'name': 'my_knowledge_base',
    'description': 'My first knowledge base'
})

# Add a document with OSS key
client.add_documents({
    'knowledgeBaseName': 'my_knowledge_base',
    'documents': [{
        'ossKey': 'oss://your-bucket/path/to/file.pdf',
        'metadata': {'author': 'aliyun'}
    }]
})

# Or add a document by uploading a local file
client.upload_documents({
    'knowledgeBaseName': 'my_knowledge_base',
    'documents': [{
        'filePath': '/path/to/local/file.pdf',
        'metadata': {'author': 'aliyun'}
    }]
})

# Search/Retrieve
results = client.retrieve({
    'knowledgeBaseName': 'knowledgeBaseName',
    "retrievalQuery": {
        "text": "text to search",
        "type": "TEXT"
    }
})

API Reference

Knowledge Base Operations

  • create_knowledge_base(request) - Create new knowledge base
  • list_knowledge_base(request) - List all knowledge bases
  • describe_knowledge_base(request) - Get knowledge base details
  • delete_knowledge_base(request) - Delete knowledge base

Document Operations

  • add_documents(request) - Add a document to a knowledge base (requires OSS key)
  • upload_documents(request) - Add a document by uploading a local file (automatically uploads to OSS)
  • list_documents(request) - List documents in knowledge base
  • get_document(request) - Get document details
  • delete_documents(request) - Delete a document

Retrieval Operations

  • retrieve(request) - Perform vector search/retrieval

Configuration

The SDK requires the following configuration parameters:

  • access_key_id: Your Aliyun access key ID (shared by OSS and OTS)
  • access_key_secret: Your Aliyun access key secret (shared by OSS and OTS)
  • oss_endpoint: OSS service endpoint
  • oss_bucket_name: OSS bucket name
  • ots_endpoint: OTS service endpoint (optional)
  • ots_instance_name: OTS instance name (optional)

Examples

See the examples/ directory for more detailed usage examples.

Dependencies

  • oss2 >= 2.18.0
  • tablestore >=6.3.9

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tablestore_agent_storage-1.0.4.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tablestore_agent_storage-1.0.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file tablestore_agent_storage-1.0.4.tar.gz.

File metadata

  • Download URL: tablestore_agent_storage-1.0.4.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.19 Linux/5.10.112-005.ali5000.al8.x86_64

File hashes

Hashes for tablestore_agent_storage-1.0.4.tar.gz
Algorithm Hash digest
SHA256 0c9bd817c74e0c68befd539b5d1a8a72f56a8ffbb9b6bbc173bf313bd8c9be60
MD5 1419626afc107696694f25d858ee8a0c
BLAKE2b-256 4f0a687c8dbc6acfceb6a5fee26e5b7f11dab559b97700e212da0bb992d4af91

See more details on using hashes here.

File details

Details for the file tablestore_agent_storage-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: tablestore_agent_storage-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.19 Linux/5.10.112-005.ali5000.al8.x86_64

File hashes

Hashes for tablestore_agent_storage-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 67392320821d5fc040ff0905093d81d0c7ec1cd1d1caa5ed1933b82e51e9f34b
MD5 4f0ea0fe2002205df4b51099c0a384c2
BLAKE2b-256 15e59bfb1e2f7fd17083d90ea2a330eb6de9f87df1007e5c8d1b05ec87187a97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page