|
10 | 10 | from guardrails_api.clients.postgres_client import postgres_is_enabled
|
11 | 11 | from guardrails_api.otel import otel_is_disabled, initialize
|
12 | 12 | from guardrails_api.clients.cache_client import CacheClient
|
13 |
| - |
| 13 | +from rich.console import Console |
| 14 | +from rich.rule import Rule |
14 | 15 |
|
15 | 16 | # TODO: Move this to a separate file
|
16 | 17 | class OverrideJsonProvider(DefaultJSONProvider):
|
@@ -50,6 +51,9 @@ def register_config(config: Optional[str] = None):
|
50 | 51 | def create_app(
|
51 | 52 | env: Optional[str] = None, config: Optional[str] = None, port: Optional[int] = None
|
52 | 53 | ):
|
| 54 | + # used to print user-facing messages during server startup |
| 55 | + console = Console() |
| 56 | + |
53 | 57 | if os.environ.get("APP_ENVIRONMENT") != "production":
|
54 | 58 | from dotenv import load_dotenv
|
55 | 59 |
|
@@ -96,9 +100,23 @@ def create_app(
|
96 | 100 | cache_client.initialize(app)
|
97 | 101 |
|
98 | 102 | from guardrails_api.blueprints.root import root_bp
|
99 |
| - from guardrails_api.blueprints.guards import guards_bp |
| 103 | + from guardrails_api.blueprints.guards import guards_bp, guard_client |
100 | 104 |
|
101 | 105 | app.register_blueprint(root_bp)
|
102 | 106 | app.register_blueprint(guards_bp)
|
103 | 107 |
|
| 108 | + console.print( |
| 109 | + f"\n:rocket: Guardrails API is available at {self_endpoint}" |
| 110 | + ) |
| 111 | + console.print(f":book: Visit {self_endpoint}/docs to see available API endpoints.\n") |
| 112 | + |
| 113 | + console.print(":green_circle: Active guards and OpenAI compatible endpoints:") |
| 114 | + |
| 115 | + for g in guard_client.get_guards(): |
| 116 | + g = g.to_dict() |
| 117 | + console.print(f"- Guard: [bold white]{g.get('name')}[/bold white] {self_endpoint}/guards/{g.get('name')}/openai/v1") |
| 118 | + |
| 119 | + console.print("") |
| 120 | + console.print(Rule("[bold grey]Server Logs[/bold grey]", characters="=", style="white")) |
| 121 | + |
104 | 122 | return app
|
0 commit comments