TBox SDK Python
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 examplesdatasets_basic_example.py- Knowledge base basic operationsdatasets_documents_example.py- Document management examplesmessages_example.py- Message processing examplesplugins_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
Metadata
Release files for tboxsdk 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tboxsdk-0.0.12.tar.gz | 22.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tboxsdk-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.8 kB
Release files / tboxsdk-0.0.12.tar.gz
| Download URL | tboxsdk-0.0.12.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba48f8805839593072ac21d22e3a97ba1a2fcb86b241f703b50c8dd904c5bc80
|
|
BLAKE2b-256 checksum How to use checksums |
d8ea4817347580d3aa4a919a899f49061119d82d632ed2d6b1000e36d40af34e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / tboxsdk-0.0.12-py3-none-any.whl
| Download URL | tboxsdk-0.0.12-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c53e8a34b42a97cb1661bd33a154524d8ca87a599f445d08d2dd407d764cd3f7
|
|
BLAKE2b-256 checksum How to use checksums |
e8bc861e77774d57c3211630bf130cbe6ebd0c533f856b0b11c16d03c4f8a42d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|