sference-cli 0.0.5__tar.gz → 0.0.7__tar.gz
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.
- {sference_cli-0.0.5 → sference_cli-0.0.7}/PKG-INFO +2 -2
- {sference_cli-0.0.5 → sference_cli-0.0.7}/pyproject.toml +2 -2
- sference_cli-0.0.7/sference_cli/__init__.py +14 -0
- {sference_cli-0.0.5 → sference_cli-0.0.7}/sference_cli/main.py +48 -1
- sference_cli-0.0.5/sference_cli/__init__.py +0 -1
- {sference_cli-0.0.5 → sference_cli-0.0.7}/.gitignore +0 -0
- {sference_cli-0.0.5 → sference_cli-0.0.7}/README.md +0 -0
- {sference_cli-0.0.5 → sference_cli-0.0.7}/sference_cli/stream_cache.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sference-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
4
4
|
Summary: sference command-line interface
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
|
-
Requires-Dist: sference-sdk>=0.0.
|
|
6
|
+
Requires-Dist: sference-sdk>=0.0.7
|
|
7
7
|
Requires-Dist: typer>=0.24.1
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sference-cli"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.7"
|
|
4
4
|
description = "sference command-line interface"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"typer>=0.24.1",
|
|
9
|
-
"sference-sdk>=0.0.
|
|
9
|
+
"sference-sdk>=0.0.7",
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
[project.scripts]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version as _distribution_version
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _package_version(distribution_name: str) -> str:
|
|
5
|
+
"""Installed distribution version (matches ``pyproject.toml`` / release tag)."""
|
|
6
|
+
try:
|
|
7
|
+
return _distribution_version(distribution_name)
|
|
8
|
+
except PackageNotFoundError:
|
|
9
|
+
return "0.0.0-dev"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__version__ = _package_version("sference-cli")
|
|
13
|
+
|
|
14
|
+
__all__ = ["__version__"]
|
|
@@ -12,7 +12,10 @@ from typing import Any, Optional, TypeVar
|
|
|
12
12
|
|
|
13
13
|
import typer
|
|
14
14
|
|
|
15
|
+
import sference_sdk
|
|
15
16
|
from sference_sdk import ApiError, SferenceClient
|
|
17
|
+
|
|
18
|
+
from sference_cli import __version__ as _CLI_VERSION
|
|
16
19
|
from sference_sdk.checkpoint import clear_checkpoint, load_checkpoint, save_checkpoint
|
|
17
20
|
|
|
18
21
|
from . import stream_cache as stream_cache_mod
|
|
@@ -27,10 +30,12 @@ auth_app = typer.Typer(help="Auth commands", invoke_without_command=True)
|
|
|
27
30
|
batch_app = typer.Typer(help="Batch commands", invoke_without_command=True)
|
|
28
31
|
stream_app = typer.Typer(help="Stream commands", invoke_without_command=True)
|
|
29
32
|
responses_app = typer.Typer(help="Responses commands", invoke_without_command=True)
|
|
33
|
+
models_app = typer.Typer(help="List models (GET /v1/models)", invoke_without_command=True)
|
|
30
34
|
app.add_typer(auth_app, name="auth")
|
|
31
35
|
app.add_typer(batch_app, name="batch")
|
|
32
36
|
app.add_typer(stream_app, name="stream")
|
|
33
37
|
app.add_typer(responses_app, name="responses")
|
|
38
|
+
app.add_typer(models_app, name="models")
|
|
34
39
|
|
|
35
40
|
CREDENTIALS_PATH = Path.home() / ".sference" / "credentials.json"
|
|
36
41
|
|
|
@@ -132,6 +137,11 @@ def _print(value: object, as_json: bool) -> None:
|
|
|
132
137
|
typer.echo(value)
|
|
133
138
|
|
|
134
139
|
|
|
140
|
+
def _list_models(*, client: SferenceClient, as_json: bool) -> None:
|
|
141
|
+
payload = _call_api(client.list_models)
|
|
142
|
+
typer.echo(json.dumps(payload, indent=None if as_json else 2))
|
|
143
|
+
|
|
144
|
+
|
|
135
145
|
def _wait_for_response(
|
|
136
146
|
client: SferenceClient, response_id: str, *, poll_ms: int, timeout_s: int
|
|
137
147
|
) -> Any:
|
|
@@ -165,8 +175,20 @@ def _stream_window_only(value: str) -> str:
|
|
|
165
175
|
|
|
166
176
|
|
|
167
177
|
@app.callback()
|
|
168
|
-
def _root(
|
|
178
|
+
def _root(
|
|
179
|
+
ctx: typer.Context,
|
|
180
|
+
version: bool = typer.Option(
|
|
181
|
+
False,
|
|
182
|
+
"--version",
|
|
183
|
+
"-V",
|
|
184
|
+
help="Print version (from package metadata; same as the release tag on PyPI).",
|
|
185
|
+
is_eager=True,
|
|
186
|
+
),
|
|
187
|
+
) -> None:
|
|
169
188
|
"""Print help when invoked without a command."""
|
|
189
|
+
if version:
|
|
190
|
+
typer.echo(f"sference-cli {_CLI_VERSION} (sference-sdk {sference_sdk.__version__})")
|
|
191
|
+
raise typer.Exit(code=0)
|
|
170
192
|
if ctx.invoked_subcommand is None:
|
|
171
193
|
typer.echo(ctx.get_help())
|
|
172
194
|
raise typer.Exit(code=0)
|
|
@@ -204,6 +226,31 @@ def _responses_root(ctx: typer.Context) -> None:
|
|
|
204
226
|
raise typer.Exit(code=0)
|
|
205
227
|
|
|
206
228
|
|
|
229
|
+
@models_app.callback()
|
|
230
|
+
def _models_root(
|
|
231
|
+
ctx: typer.Context,
|
|
232
|
+
as_json: bool = typer.Option(False, "--json", help="Print GET /v1/models JSON."),
|
|
233
|
+
base_url: str = typer.Option("https://api.sference.com"),
|
|
234
|
+
) -> None:
|
|
235
|
+
"""List models (OpenAI-compatible GET /v1/models)."""
|
|
236
|
+
if ctx.invoked_subcommand is not None:
|
|
237
|
+
return
|
|
238
|
+
_ensure_api_credential()
|
|
239
|
+
client = _client(base_url)
|
|
240
|
+
_list_models(client=client, as_json=as_json)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@models_app.command("list")
|
|
244
|
+
def models_list(
|
|
245
|
+
as_json: bool = typer.Option(False, "--json", help="Print GET /v1/models JSON."),
|
|
246
|
+
base_url: str = typer.Option("https://api.sference.com"),
|
|
247
|
+
) -> None:
|
|
248
|
+
"""List models (OpenAI-compatible GET /v1/models)."""
|
|
249
|
+
_ensure_api_credential()
|
|
250
|
+
client = _client(base_url)
|
|
251
|
+
_list_models(client=client, as_json=as_json)
|
|
252
|
+
|
|
253
|
+
|
|
207
254
|
@auth_app.command("login")
|
|
208
255
|
def auth_login(
|
|
209
256
|
api_key: Optional[str] = typer.Option(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__all__ = []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|