Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A command-line tool for GLM chat completions via [AceDataCloud](https://platform
## Installation

```bash
pip install glm-cli
pip install glm-pro-cli
```

## Quick Start
Expand Down
10 changes: 5 additions & 5 deletions glm/glm_cli/commands/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@
default=False,
help="Enable parallel function calling during tool use.",
)
@click.option("--stream", is_flag=True, default=False, help="Stream partial chat completion events.")
@click.option(
"--stream", is_flag=True, default=False, help="Stream partial chat completion events."
)
@click.option(
"--response-format",
default=None,
Expand All @@ -149,7 +151,7 @@
@click.option(
"--stream-options",
default=None,
help='Streaming options as a JSON object (e.g. \'{"include_usage": true}\').',
help="Streaming options as a JSON object (e.g. '{\"include_usage\": true}').",
)
@click.option("--metadata", default=None, help="Metadata as a JSON object.")
@click.option("--logit-bias", default=None, help="Logit bias map as a JSON object.")
Expand Down Expand Up @@ -220,9 +222,7 @@ def chat(
parsed_modalities = parse_json_array(modalities, "--modalities")
parsed_audio = parse_json_object(audio, "--audio")
parsed_prediction = parse_json_object(prediction, "--prediction")
parsed_web_search_options = parse_json_object(
web_search_options, "--web-search-options"
)
parsed_web_search_options = parse_json_object(web_search_options, "--web-search-options")
except click.BadParameter as e:
print_error(e.format_message())
raise SystemExit(1) from None
Expand Down
3 changes: 1 addition & 2 deletions glm/glm_cli/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def _get_headers(self) -> dict[str, str]:
"""Get request headers with authentication."""
if not self.api_token:
raise GLMAuthError(
"API token not configured. "
"Set ACEDATACLOUD_API_TOKEN or use --token option."
"API token not configured. Set ACEDATACLOUD_API_TOKEN or use --token option."
)
return {
"accept": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion glm/glm_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def get_version() -> str:
"""Get the package version."""
try:
return metadata.version("glm-cli")
return metadata.version("glm-pro-cli")
except metadata.PackageNotFoundError:
return "dev"

Expand Down
4 changes: 2 additions & 2 deletions glm/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "glm-cli"
name = "glm-pro-cli"
version = "0.1.0"
description = "CLI tool for GLM Chat Completions via AceDataCloud"
readme = "README.md"
Expand Down Expand Up @@ -56,7 +56,7 @@ release = [
"twine>=6.1.0",
]
all = [
"glm-cli[dev,test,release]",
"glm-pro-cli[dev,test,release]",
]

[project.scripts]
Expand Down
23 changes: 17 additions & 6 deletions glm/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from click.testing import CliRunner
from httpx import Response

from glm_cli.main import cli
from glm_cli.main import cli, get_version


@pytest.fixture
Expand All @@ -23,6 +23,14 @@ def test_version(self, runner):
assert result.exit_code == 0
assert "glm-cli" in result.output

def test_version_uses_distribution_name(self, monkeypatch):
monkeypatch.setattr(
"glm_cli.main.metadata.version",
lambda name: "1.2.3" if name == "glm-pro-cli" else None,
)

assert get_version() == "1.2.3"

def test_help(self, runner):
result = runner.invoke(cli, ["--help"])
assert result.exit_code == 0
Expand Down Expand Up @@ -55,9 +63,7 @@ def test_chat_rich_output(self, runner, mock_chat_response):
respx.post("https://api.acedata.cloud/glm/chat/completions").mock(
return_value=Response(200, json=mock_chat_response)
)
result = runner.invoke(
cli, ["--token", "test-token", "chat", "Hello"]
)
result = runner.invoke(cli, ["--token", "test-token", "chat", "Hello"])
assert result.exit_code == 0
assert "Paris" in result.output

Expand All @@ -81,8 +87,13 @@ def test_chat_with_system_prompt(self, runner, mock_chat_response):
result = runner.invoke(
cli,
[
"--token", "test-token", "chat", "Hello",
"-s", "You are a helpful assistant", "--json",
"--token",
"test-token",
"chat",
"Hello",
"-s",
"You are a helpful assistant",
"--json",
],
)
assert result.exit_code == 0
Expand Down