Skip to main content

Common functions to interact with Tbox

Project description

TBox SDK Python

Python Version License Version

English | 中文

TBox SDK is an open SDK tool for the TBox platform. It allows you to quickly integrate TBox's intelligent agent conversation and generation, knowledge base management, RAG, plugin invocation, and other capabilities into your code. This project is the Python version of TBox SDK.

✨ Key Features

  • 🤖 Intelligent Agent Chat - Support for both streaming and non-streaming conversations, easy integration of AI chat capabilities
  • 📚 Knowledge Base Management - Complete CRUD operations for knowledge bases with document upload and management
  • 🔍 RAG Retrieval - Powerful Retrieval-Augmented Generation capabilities to improve AI response quality
  • 🔌 Plugin Invocation - Rich official plugin ecosystem to extend AI capabilities
  • 💬 Conversation Management - Complete conversation lifecycle management
  • 📁 File Processing - Support for uploading and processing multiple file formats

🚀 Quick Start

Installation

pip install tboxsdk

Basic Usage

from tboxsdk import TboxClient

# Initialize client
client = TboxClient(authorization="your_auth_token_here")

# Intelligent agent chat
response = client.chat(
    app_id="your_app_id",
    query="Hello, please introduce Python programming",
    user_id="user123"
)

print(response)

📖 Detailed Documentation

Intelligent Agent Chat

Support for both streaming and non-streaming conversation modes:

# Streaming chat
for chunk in client.chat_stream(
    app_id="your_app_id",
    query="Please write a Python function",
    user_id="user123"
):
    print(chunk, end="")

# Non-streaming chat
response = client.chat(
    app_id="your_app_id", 
    query="Please explain machine learning",
    user_id="user123",
    stream=False
)

Knowledge Base Management

# Create knowledge base
result = client.create_datasets(
    name="Python Knowledge Base",
    description="Contains Python programming related documents"
)

# Query knowledge base list
datasets = client.list_datasets()

# Upload document to knowledge base
file_result = client.upload_file(
    file_path="document.pdf",
    dataset_id="your_dataset_id"
)

# Delete knowledge base
client.delete_dataset(dataset_id="your_dataset_id")

Plugin Invocation

# Get official plugin list
plugins = client.get_official_plugins()

# Invoke plugin
result = client.invoke_plugin(
    plugin_tool_id="plugin_tool_id",
    params={"query": "search content"}
)

Conversation Management

# Create conversation
conversation = client.create_conversation(
    app_id="your_app_id",
    user_id="user123"
)

# Query conversation list
conversations = client.get_conversations(
    app_id="your_app_id",
    user_id="user123"
)

# Get conversation messages
messages = client.get_messages(
    conversation_id="conversation_id"
)

📁 Project Structure

tboxsdk/
├── core/           # Core modules
│   ├── httpclient.py    # HTTP client
│   └── exception.py     # Exception handling
├── model/          # Data models
│   ├── conversation.py  # Conversation model
│   ├── file.py         # File model
│   └── message.py      # Message model
└── tbox.py         # Main client class

📚 Example Code

The project provides rich example code in the examples/ directory:

  • conversations_example.py - Conversation management examples
  • datasets_basic_example.py - Knowledge base basic operations
  • datasets_documents_example.py - Document management examples
  • messages_example.py - Message processing examples
  • plugins_example.py - Plugin invocation examples

Run examples:

python examples/conversations_example.py

🛠️ Development Environment

  • Python 3.6+
  • httpx
  • sseclient-py

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

🤝 Contributing

Issues and Pull Requests are welcome to help improve the project.

🔗 Related Links

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

tboxsdk-0.0.11.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

tboxsdk-0.0.11-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file tboxsdk-0.0.11.tar.gz.

File metadata

  • Download URL: tboxsdk-0.0.11.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tboxsdk-0.0.11.tar.gz
Algorithm Hash digest
SHA256 a1565f3ffc2f07a6d64e70b5d154e723a1f010f4272c9d19d6f8d5682c7578cb
MD5 6765606e06aeb1565775384748c0bfa9
BLAKE2b-256 e50dfb1890eba20a82b6812d9076de24d3bb3682e55430b3d59b3eaa6ddd0b11

See more details on using hashes here.

File details

Details for the file tboxsdk-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: tboxsdk-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tboxsdk-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6edf63d3d39d7460051efb50070942d9bc69fc5fcd94cccc816994ccced63d43
MD5 de79e3d805d0d43b82322741515573ca
BLAKE2b-256 f678bf3f888fa41ed4870c9716e9c0facf214222e3ad39aaf21f87ddeb50985b

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