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.12.tar.gz (22.9 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.12-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tboxsdk-0.0.12.tar.gz
  • Upload date:
  • Size: 22.9 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.12.tar.gz
Algorithm Hash digest
SHA256 ba48f8805839593072ac21d22e3a97ba1a2fcb86b241f703b50c8dd904c5bc80
MD5 993c6626a50aa2ae198a5f69fb57f387
BLAKE2b-256 d8ea4817347580d3aa4a919a899f49061119d82d632ed2d6b1000e36d40af34e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tboxsdk-0.0.12-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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 c53e8a34b42a97cb1661bd33a154524d8ca87a599f445d08d2dd407d764cd3f7
MD5 e543634631b7314c43ac93f2e4bb4201
BLAKE2b-256 e8bc861e77774d57c3211630bf130cbe6ebd0c533f856b0b11c16d03c4f8a42d

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