mirror of
https://github.com/MervinPraison/PraisonAIUI.git
synced 2026-11-11 03:31:28 -10:00
- Refactored navigation in `aiui.template.yaml` for improved organization, adding an "API Reference" tab. - Updated `features-api.md` with new endpoints and examples, including enhanced approval management and session handling features. - Improved clarity and consistency in API request/response examples.
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
"""Shared demo data seeding for examples.
|
|
|
|
Used by examples 13, 15, and 16 to avoid copy-pasting the same data.
|
|
Import and call seed_demo_data() once at module load.
|
|
|
|
NOTE: Since PraisonAIUI features now use various backends (FileScheduleStore,
|
|
ApprovalRegistry, etc.), seeding is best done via API calls in tests rather
|
|
than direct store manipulation.
|
|
"""
|
|
|
|
|
|
def seed_demo_data():
|
|
"""Populate feature stores with demo data.
|
|
|
|
This is a no-op placeholder. Use API calls in tests to seed data,
|
|
as feature stores may use different backends (file, DB, etc.).
|
|
"""
|
|
pass
|
|
|
|
|
|
def seed_via_api(client):
|
|
"""Seed demo data via API calls (recommended approach).
|
|
|
|
Args:
|
|
client: Starlette TestClient instance
|
|
"""
|
|
# Channels
|
|
client.post("/api/channels", json={
|
|
"name": "Discord #general", "platform": "discord",
|
|
"config": {"guild_id": "123456789"}
|
|
})
|
|
client.post("/api/channels", json={
|
|
"name": "Telegram Support", "platform": "telegram",
|
|
"config": {"bot_token": "***masked***"}
|
|
})
|
|
|
|
# Agents
|
|
client.post("/api/agents/definitions", json={
|
|
"name": "Summarizer",
|
|
"instructions": "You are an expert summarizer.",
|
|
"model": "gpt-4o-mini"
|
|
})
|
|
client.post("/api/agents/definitions", json={
|
|
"name": "Code Assistant",
|
|
"instructions": "You are an expert programmer.",
|
|
"model": "gpt-4o"
|
|
})
|
|
|
|
# Schedules
|
|
client.post("/api/schedules", json={
|
|
"name": "Daily Report",
|
|
"schedule": {"kind": "every", "every_seconds": 86400},
|
|
"message": "Generate daily summary"
|
|
})
|
|
|
|
# Usage
|
|
client.post("/api/usage/track", json={
|
|
"model": "gpt-4o-mini",
|
|
"input_tokens": 150,
|
|
"output_tokens": 80
|
|
})
|
|
|
|
# Jobs
|
|
client.post("/api/jobs", json={
|
|
"prompt": "Test job",
|
|
"config": {"model": "gpt-4o-mini"}
|
|
})
|