kalibr 1.0.15__py3-none-any.whl → 1.0.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kalibr/__main__.py CHANGED
@@ -1,4 +1,31 @@
1
- from kalibr.kalibr_app import run
1
+ import typer
2
+ from kalibr.kalibr_app import serve_app, deploy_app
3
+
4
+ cli = typer.Typer(help="Kalibr Connect CLI")
5
+
6
+ @cli.command("serve")
7
+ def serve(file: str):
8
+ """Run a Kalibr app locally."""
9
+ serve_app(file)
10
+
11
+ @cli.command("deploy")
12
+ def deploy(file: str):
13
+ """Deploy a Kalibr app."""
14
+ deploy_app(file)
15
+
16
+ @cli.command("usage")
17
+ def usage():
18
+ """Show usage guide."""
19
+ print("""
20
+ Kalibr Connect Commands:
21
+ kalibr-connect serve <file> Run a Kalibr app locally.
22
+ kalibr-connect deploy <file> Deploy your Kalibr app.
23
+ kalibr-connect usage Show this usage guide.
24
+ """)
25
+
26
+ def main():
27
+ """Entry point for console_scripts."""
28
+ cli()
2
29
 
3
30
  if __name__ == "__main__":
4
- run()
31
+ main()
kalibr/kalibr_app.py CHANGED
@@ -1,71 +1,38 @@
1
+ import importlib.util
1
2
  import os
2
- import sys
3
- import typer
4
3
  import uvicorn
5
- import importlib.util
6
4
  from fastapi import FastAPI
7
- from rich.console import Console
8
-
9
- console = Console()
10
-
11
5
 
12
6
  class KalibrApp(FastAPI):
13
- """Lightweight FastAPI wrapper with a .tool() decorator."""
14
- def tool(self):
15
- def decorator(func):
16
- self.get(f"/{func.__name__}")(func)
17
- return func
18
- return decorator
7
+ def __init__(self):
8
+ super().__init__()
9
+ print("🚀 KalibrApp initialized. Ready to serve AI tools.")
19
10
 
11
+ def run(self, host="127.0.0.1", port=8000):
12
+ print(f"🚀 Starting Kalibr server on http://{host}:{port}")
13
+ uvicorn.run(self, host=host, port=port)
20
14
 
21
- app = typer.Typer(help="Kalibr Connect CLI")
15
+ # --- CLI helper functions ---
22
16
 
17
+ def serve_app(file_path: str):
18
+ """Run a Kalibr app file (e.g. demo_app.py) locally."""
19
+ if not os.path.exists(file_path):
20
+ print(f"❌ File not found: {file_path}")
21
+ return
23
22
 
24
- def load_app_from_file(file_path: str):
25
- abs_path = os.path.abspath(file_path)
26
- if not os.path.exists(abs_path):
27
- raise FileNotFoundError(f"File not found: {abs_path}")
28
-
29
- spec = importlib.util.spec_from_file_location("user_app", abs_path)
23
+ module_name = os.path.splitext(os.path.basename(file_path))[0]
24
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
30
25
  module = importlib.util.module_from_spec(spec)
31
- sys.modules["user_app"] = module
32
26
  spec.loader.exec_module(module)
33
27
 
34
- if not hasattr(module, "app"):
35
- raise AttributeError("No FastAPI app instance named 'app' found in the file.")
36
- return module.app
37
-
38
-
39
- @app.command("serve")
40
- def serve(file: str):
41
- """Run a Kalibr app locally from a .py file."""
42
- console.print(f"[cyan]🚀 Serving {file} locally...[/cyan]")
43
- try:
44
- app_instance = load_app_from_file(file)
45
- console.print("[green]✅ App loaded successfully. Starting server...[/green]")
46
- uvicorn.run(app_instance, host="127.0.0.1", port=8000, reload=False)
47
- except Exception as e:
48
- console.print(f"[red]❌ Failed to start app:[/red] {e}")
49
-
50
-
51
- @app.command("deploy")
52
- def deploy(file: str):
53
- console.print(f"[yellow]🚀 Deploying {file} (stub)...[/yellow]")
54
-
55
-
56
- @app.command("usage")
57
- def usage():
58
- console.print(
59
- "\n[bold cyan]Kalibr Connect Commands:[/bold cyan]\n"
60
- " kalibr-connect serve <file> Run a Kalibr app locally.\n"
61
- " kalibr-connect deploy <file> Deploy your Kalibr app.\n"
62
- " kalibr-connect usage Show this usage guide.\n"
63
- )
64
-
65
-
66
- def run():
67
- app()
28
+ app = getattr(module, "app", None)
29
+ if not app:
30
+ print("❌ No `app` instance found in the provided file.")
31
+ return
68
32
 
33
+ print(f"🚀 Serving {file_path} locally...")
34
+ uvicorn.run(app, host="127.0.0.1", port=8000)
69
35
 
70
- if __name__ == "__main__":
71
- run()
36
+ def deploy_app(file_path: str):
37
+ """Stub for future deploy command."""
38
+ print(f"🚀 Deploying {file_path} (stub). Future versions will handle cloud deploys.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kalibr
3
- Version: 1.0.15
3
+ Version: 1.0.17
4
4
  Summary: Kalibr SDK — Integrate your SaaS with every major AI model using a single SDK.
5
5
  Home-page: https://github.com/devon/kalibr-sdk
6
6
  Author: Devon
@@ -0,0 +1,10 @@
1
+ kalibr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ kalibr/__main__.py,sha256=oSEVIA6G1F6DVJjq4hcV_cX1_RYJkIJjdC4yc0HzTpI,693
3
+ kalibr/kalibr_app.py,sha256=UX80reWShHXkHiDu8HgNAzoR3NBIE1YEiYWs1azahn4,1252
4
+ kalibr/schema_generators.py,sha256=1CFc0mCI0KVM48gEeGKK91I42WYyPYfEk2Yx2uZh478,286
5
+ kalibr-1.0.17.dist-info/licenses/LICENSE.txt,sha256=1WLJDkrueNpHCROy9zANrK2Ar2weqZ_z88hw90UKDoc,451
6
+ kalibr-1.0.17.dist-info/METADATA,sha256=cBJH3QYbOumvh0OKX-monN17-qIxSVYuH8o4yW85rUw,2632
7
+ kalibr-1.0.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ kalibr-1.0.17.dist-info/entry_points.txt,sha256=T-DOrFEZb0fZxA9H8sSCh-2zKxdjnmpzIRmm5TY_f6s,56
9
+ kalibr-1.0.17.dist-info/top_level.txt,sha256=OkloC5_IfpE4-QwI30aLIYbFZk_-ChABWF7aBGddy28,7
10
+ kalibr-1.0.17.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- kalibr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- kalibr/__main__.py,sha256=H37BckvtKe9moXhxFKTTtcyYB2SKiCy3B8l6BOkve3Q,72
3
- kalibr/kalibr_app.py,sha256=pqzsPaZbAAe9aBJ-bfJBfce-wZgaFj7iVKz7Nz823S4,1953
4
- kalibr/schema_generators.py,sha256=1CFc0mCI0KVM48gEeGKK91I42WYyPYfEk2Yx2uZh478,286
5
- kalibr-1.0.15.dist-info/licenses/LICENSE.txt,sha256=1WLJDkrueNpHCROy9zANrK2Ar2weqZ_z88hw90UKDoc,451
6
- kalibr-1.0.15.dist-info/METADATA,sha256=Et5WpmFrVU2Dziw-ETNYUTsaBqtRaodj8bhpHuTs-iA,2632
7
- kalibr-1.0.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- kalibr-1.0.15.dist-info/entry_points.txt,sha256=T-DOrFEZb0fZxA9H8sSCh-2zKxdjnmpzIRmm5TY_f6s,56
9
- kalibr-1.0.15.dist-info/top_level.txt,sha256=OkloC5_IfpE4-QwI30aLIYbFZk_-ChABWF7aBGddy28,7
10
- kalibr-1.0.15.dist-info/RECORD,,