Managing Chatbots
List, update, and organize your chatbots.
List Chatbots
View all your created chatbots.
Via Web Interface
- Navigate to Chatbots in the sidebar
- View all chatbots with:
- Name and type
- Model used
- RAG status
- Creation date
- Last activity
Via API
import requests
response = requests.get(
"http://localhost/api/v1/chatbot/list",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
chatbots = response.json()["chatbots"]
for bot in chatbots:
print(f"ID: {bot['id']}")
print(f"Name: {bot['name']}")
print(f"Model: {bot['model']}")
print(f"RAG Enabled: {bot.get('use_rag', False)}")
print(f"Created: {bot['created_at']}")
print("-" * 40)
Get Chatbot Details
Retrieve full configuration for a specific chatbot.
chatbot_id = "your-chatbot-id"
response = requests.get(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
chatbot = response.json()
print(f"Name: {chatbot['name']}")
print(f"System Prompt: {chatbot['system_prompt']}")
print(f"Temperature: {chatbot['temperature']}")
print(f"RAG Collection: {chatbot.get('rag_collection', 'N/A')}")
Update Chatbot
Modify an existing chatbot's configuration.
Update Personality
chatbot_id = "your-chatbot-id"
response = requests.put(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"system_prompt": "You are now a senior customer support agent. Provide detailed, technical solutions.",
"temperature": 0.2, # Lower temperature for more focused responses
"fallback_responses": [
"Let me research that for you.",
"I'll connect you with our technical team."
]
}
)
print(f"Updated chatbot: {response.json()['name']}")
Update RAG Settings
response = requests.put(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"use_rag": True,
"rag_collection": "updated_docs_collection",
"rag_top_k": 7, # Increase for more context
"similarity_threshold": 0.6
}
)
Change Model
response = requests.put(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "gpt-4" # Upgrade to more capable model
}
)
Advanced Updates
response = requests.put(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"max_tokens": 2000,
"memory_length": 30
}
)
Delete Chatbot
Remove a chatbot you no longer need.
Via Web Interface
- Navigate to Chatbots
- Find the chatbot to delete
- Click Delete
- Confirm deletion
Via API
chatbot_id = "your-chatbot-id"
response = requests.delete(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
if response.status_code == 204:
print("Chatbot deleted successfully")
else:
print(f"Error: {response.json()}")
Clone Chatbot
Create a new chatbot based on an existing one.
# Get original chatbot
original_id = "original-chatbot-id"
get_response = requests.get(
f"http://localhost/api/v1/chatbot/{original_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
original = get_response.json()
# Create new chatbot with same config
create_response = requests.post(
"http://localhost/api/v1/chatbot/create",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"name": f"{original['name']} - Copy",
"model": original["model"],
"system_prompt": original["system_prompt"],
"use_rag": original.get("use_rag", False),
"rag_collection": original.get("rag_collection"),
"temperature": original["temperature"]
}
)
new_chatbot = create_response.json()
print(f"Created copy: {new_chatbot['id']}")
Batch Operations
Manage multiple chatbots efficiently.
List and Filter
response = requests.get(
"http://localhost/api/v1/chatbot/list",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={
"model": "gpt-3.5-turbo", # Filter by model
"use_rag": True # Only chatbots with RAG enabled
}
)
rag_chatbots = response.json()["chatbots"]
print(f"Found {len(rag_chatbots)} RAG-enabled chatbots")
Update Multiple
import requests
chatbot_ids = ["chatbot-1", "chatbot-2", "chatbot-3"]
for chatbot_id in chatbot_ids:
response = requests.put(
f"http://localhost/api/v1/chatbot/{chatbot_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"temperature": 0.4, # Update all to be more focused
"memory_length": 15
}
)
print(f"Updated {chatbot_id}: {response.status_code}")
Monitoring
Track chatbot performance and usage.
Check Usage
chatbot_id = "your-chatbot-id"
response = requests.get(
f"http://localhost/api/v1/chatbot/{chatbot_id}/stats",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
stats = response.json()
print(f"Total Messages: {stats['total_messages']}")
print(f"Total Tokens: {stats['total_tokens']}")
print(f"RAG Queries: {stats['rag_queries']}")
print(f"Average Response Time: {stats['avg_response_time']}ms")
Check Performance
response = requests.get(
"http://localhost/api/v1/analytics/chatbot-performance",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={
"chatbot_id": chatbot_id,
"period": "7d"
}
)
performance = response.json()
print(f"Success Rate: {performance['success_rate']:.2%}")
print(f"Average Response: {performance['avg_response_time']}ms")
print(f"RAG Hit Rate: {performance['rag_hit_rate']:.2%}")
Best Practices
Organization
- Use Descriptive Names - Make chatbots easy to identify
- Version Your Chatbots - Include version in names (e.g., "Support Bot v2")
- Document Changes - Keep track of configuration changes
- Test Changes - Test chatbots after major updates
- Monitor Performance - Check usage metrics regularly
Lifecycle Management
| Stage | Action |
|---|---|
| Development | Create and test extensively |
| Staging | Deploy to test environment |
| Production | Monitor and optimize |
| Deprecation | Mark as deprecated, plan migration |
Security
- Use Separate API Keys - Different keys for different chatbots
- Set Appropriate Permissions - Limit access per chatbot
- Regular Review - Review and clean up unused chatbots
- Audit Usage - Monitor which chatbots are used most
Troubleshooting
Chatbot Not Responding
Problem: Chatbot returns errors or no response
Check:
- Chatbot ID is correct
- Chatbot is enabled
- API key has chatbot permissions
- Model is available
RAG Not Working
Problem: Chatbot doesn't use RAG documents
Check:
use_ragis true in configuration- RAG collection exists
- Documents are uploaded to collection
- Collection name matches configuration
Update Failing
Problem: Update request returns error
Check:
- You have permission to update the chatbot
- JSON payload is valid
- All required fields are included
Next Steps
- Chatting - Test your chatbots
- Examples - See how to use chatbots in applications
- Create Chatbots - Create new chatbots