mirror of
https://github.com/MervinPraison/PraisonAIUI.git
synced 2026-11-07 05:56:17 -10:00
* feat: restore demo data seeding in examples 10-12 (fixes #55) - Update seed_demo_data() to delegate to seed_via_api() using TestClient - Replaces no-op stub with working implementation - Ensures examples show populated dashboards on startup - Uses HTTP API as stable integration surface per architectural principle 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Mervin Praison <[email protected]> * feat: restore demo data seeding in examples 10-12 (fixes #55) - Modified seed_demo_data() to call seed_via_api() with TestClient - Preserves cold import performance with lazy imports (167ms < 200ms) - Examples now show populated dashboards instead of empty tables - Maintains backend compatibility via API-based seeding approach Co-authored-by: Mervin Praison <[email protected]> * fix: use TestClient as context manager for proper lifespan handling Co-authored-by: Mervin Praison <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mervin Praison <[email protected]> Co-authored-by: Mervin Praison <[email protected]>
This commit is contained in:
1 file changed
+18
-9
@@ -11,16 +11,25 @@ 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.).
|
||||
|
||||
Seeds data via HTTP API calls to ensure compatibility across
|
||||
different backend implementations (file, DB, etc.).
|
||||
"""
|
||||
pass
|
||||
try:
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
from praisonaiui.server import create_app
|
||||
|
||||
app = create_app()
|
||||
with TestClient(app) as client:
|
||||
seed_via_api(client)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def seed_via_api(client):
|
||||
"""Seed demo data via API calls (recommended approach).
|
||||
|
||||
|
||||
Args:
|
||||
client: Starlette TestClient instance
|
||||
"""
|
||||
@@ -37,7 +46,7 @@ def seed_via_api(client):
|
||||
"name": "Support Email", "platform": "email",
|
||||
"config": {"email_address": "[email protected]"}
|
||||
})
|
||||
|
||||
|
||||
# Agents
|
||||
client.post("/api/agents/definitions", json={
|
||||
"name": "Summarizer",
|
||||
@@ -49,21 +58,21 @@ def seed_via_api(client):
|
||||
"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",
|
||||
|
||||
Reference in new issue
Block a user