🐍 Ask Sage Python Client
A powerful, easy-to-use Python library for seamless Ask Sage API integration
📦 Quick Install:
pip install asksageclient The Ask Sage Python Client provides a comprehensive, Pythonic interface to the Ask Sage API. Build AI-powered applications with minimal code while maintaining full control over advanced features.
📚 Available Methods
| Method | Description |
|---|---|
get_models() Popular | Retrieve all available AI models |
query() Popular | Send queries to AI models with full customization |
query_with_file() | Query with file attachments for context |
train() | Add content to your knowledge base |
train_with_file() | Train using file uploads |
file() | Upload and process files |
add_dataset() | Create new datasets |
delete_dataset() | Remove datasets |
assign_dataset() | Assign datasets to users |
get_datasets() | List all available datasets |
get_personas() | Retrieve available AI personas |
get_plugins() | List available plugins/agents |
query_plugin() | Execute queries using specific plugins |
execute_plugin() | Run plugins with custom content |
follow_up_questions() | Generate contextual follow-up questions |
tokenizer() | Calculate token counts for content |
get_user_logs() | Retrieve user activity logs |
get_user_logins() | Get user login history |
count_monthly_tokens() | Track monthly token usage |
count_monthly_teach_tokens() | Monitor training token consumption |
🎓 Example Notebook
📓 Interactive Tutorial
Explore a comprehensive Jupyter notebook with examples and best practices
📖 Open Example Notebook🚀 Quick Start Guide
Installation
Install the Ask Sage Python Client using pip:
pip install asksageclient 📖 Documentation: Full API reference available at PyPI
Setup & Authentication
1Create Credentials File
Create a JSON file with your API credentials:
{
"credentials": {
"api_key": "YOUR_API_KEY",
"Ask_sage_user_info": {
"username": "your.email@example.com"
}
}
} 🔒 Security: Never commit credentials to version control. Add
credentials.json to your .gitignore file. 2Initialize the Client
Load credentials and create an Ask Sage client instance:
import json
from asksageclient import AskSageClient
# Load credentials from file
def load_credentials(filename):
"""Load API credentials from JSON file."""
try:
with open(filename) as file:
return json.load(file)
except FileNotFoundError:
raise FileNotFoundError(f"Credentials file '{filename}' not found.")
except json.JSONDecodeError:
raise ValueError("Invalid JSON in credentials file.")
# Initialize credentials
credentials = load_credentials('credentials.json')
api_key = credentials['credentials']['api_key']
email = credentials['credentials']['Ask_sage_user_info']['username']
# Create Ask Sage client
client = AskSageClient(
email=email,
api_key=api_key,
user_base_url='https://api.asksage.ai/user', # Optional: User API base URL
server_base_url='https://api.asksage.ai/server' # Optional: Server API base URL
)
print("✅ Ask Sage client initialized successfully!")📚 Additional Resources
💡 Pro Tip: Join our community to stay updated on new features, best practices, and get help from other developers!