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