chattermate-cli 0.3.0__tar.gz → 0.3.1__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.
Files changed (29) hide show
  1. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/PKG-INFO +1 -1
  2. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/__init__.py +1 -1
  3. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/client.py +10 -0
  4. chattermate_cli-0.3.1/chattermate_cli/commands/ai.py +86 -0
  5. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/main.py +2 -0
  6. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/PKG-INFO +1 -1
  7. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/SOURCES.txt +2 -0
  8. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/pyproject.toml +1 -1
  9. chattermate_cli-0.3.1/tests/test_ai.py +60 -0
  10. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/LICENSE +0 -0
  11. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/README.md +0 -0
  12. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/__init__.py +0 -0
  13. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/agent.py +0 -0
  14. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/auth.py +0 -0
  15. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/knowledge.py +0 -0
  16. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/widget.py +0 -0
  17. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/commands/workflow.py +0 -0
  18. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/config.py +0 -0
  19. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/context.py +0 -0
  20. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli/mcp_server.py +0 -0
  21. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/dependency_links.txt +0 -0
  22. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/entry_points.txt +0 -0
  23. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/requires.txt +0 -0
  24. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/chattermate_cli.egg-info/top_level.txt +0 -0
  25. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/setup.cfg +0 -0
  26. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/tests/test_client.py +0 -0
  27. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/tests/test_knowledge.py +0 -0
  28. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/tests/test_mcp.py +0 -0
  29. {chattermate_cli-0.3.0 → chattermate_cli-0.3.1}/tests/test_widget.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chattermate-cli
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent.
5
5
  Author: ChatterMate
6
6
  License: AGPL-3.0-or-later
@@ -16,4 +16,4 @@ You should have received a copy of the GNU Affero General Public License
16
16
  along with this program. If not, see <https://www.gnu.org/licenses/>
17
17
  """
18
18
 
19
- __version__ = "0.3.0"
19
+ __version__ = "0.3.1"
@@ -299,3 +299,13 @@ class Client:
299
299
 
300
300
  def list_widgets_for_agent(self, agent_id: str) -> Any:
301
301
  return self.request("GET", f"/widgets/agent/{agent_id}")
302
+
303
+ # -- AI configuration --------------------------------------------------
304
+
305
+ def setup_ai(self, model_type: str, model_name: str, api_key: str) -> Any:
306
+ return self.request("POST", "/ai/setup", json={
307
+ "model_type": model_type, "model_name": model_name, "api_key": api_key,
308
+ })
309
+
310
+ def get_ai_config(self) -> Any:
311
+ return self.request("GET", "/ai/config")
@@ -0,0 +1,86 @@
1
+ """
2
+ ChatterMate - CLI AI Configuration Commands
3
+ Copyright (C) 2024 ChatterMate
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as
7
+ published by the Free Software Foundation, either version 3 of the
8
+ License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>
17
+ """
18
+
19
+ from typing import Optional
20
+
21
+ import typer
22
+
23
+ from ..context import console, get_client, output, print_error, run
24
+
25
+ ai_app = typer.Typer(no_args_is_help=True, help="Configure the organization's AI model.")
26
+
27
+ # The ChatterMate-managed free model: the backend supplies its own key, so no
28
+ # --api-key is required. Any placeholder satisfies the request schema.
29
+ _DEFAULT_MODEL_TYPE = "chattermate"
30
+ _DEFAULT_MODEL_NAME = "chattermate"
31
+
32
+
33
+ @ai_app.command("setup")
34
+ def setup(
35
+ model_type: str = typer.Option(
36
+ _DEFAULT_MODEL_TYPE, "--model-type",
37
+ help="Provider: chattermate (free managed default), openai, google, groq, anthropic, ...",
38
+ ),
39
+ model_name: str = typer.Option(
40
+ _DEFAULT_MODEL_NAME, "--model-name",
41
+ help="Model name (use 'chattermate' with --model-type chattermate).",
42
+ ),
43
+ api_key: Optional[str] = typer.Option(
44
+ None, "--api-key", help="Provider API key (required unless --model-type is chattermate).",
45
+ ),
46
+ as_json: bool = typer.Option(False, "--json", help="Output raw JSON."),
47
+ ):
48
+ """Set the organization's AI model. Defaults to the free ChatterMate model.
49
+
50
+ New organizations already get the ChatterMate model automatically; use this to
51
+ switch to your own provider/key, e.g.:
52
+ chattermate ai setup --model-type openai --model-name gpt-4o --api-key sk-...
53
+ """
54
+ is_managed = model_type.lower() == _DEFAULT_MODEL_TYPE
55
+ if not is_managed and not api_key:
56
+ print_error("--api-key is required when --model-type is not 'chattermate'.")
57
+ raise typer.Exit(code=1)
58
+ # For the managed model the backend uses its own key; send a placeholder to
59
+ # satisfy the schema (it is ignored server-side for the chattermate model).
60
+ key = api_key or "chattermate"
61
+
62
+ client = get_client()
63
+ # The API's model_type is an enum with UPPERCASE values (CHATTERMATE, OPENAI, ...);
64
+ # accept lowercase from the user and normalize. model_name is free-form.
65
+ data = run(lambda: client.setup_ai(model_type=model_type.upper(), model_name=model_name, api_key=key))
66
+ if as_json:
67
+ output(data, True)
68
+ return
69
+ console.print(f"[green]AI configured[/green] — {model_type}/{model_name}.")
70
+
71
+
72
+ @ai_app.command("show")
73
+ def show(as_json: bool = typer.Option(False, "--json", help="Output raw JSON.")):
74
+ """Show the organization's current AI configuration."""
75
+ client = get_client()
76
+ data = run(client.get_ai_config)
77
+
78
+ def render(cfg):
79
+ if not isinstance(cfg, dict):
80
+ console.print(str(cfg))
81
+ return
82
+ console.print(f" model type: {cfg.get('model_type')}")
83
+ console.print(f" model name: {cfg.get('model_name')}")
84
+ console.print(f" active: {cfg.get('is_active')}")
85
+
86
+ output(data, as_json, render)
@@ -23,6 +23,7 @@ import typer
23
23
  from . import __version__, context
24
24
  from .commands import auth as auth_cmd
25
25
  from .commands.agent import agent_app
26
+ from .commands.ai import ai_app
26
27
  from .commands.knowledge import knowledge_app
27
28
  from .commands.widget import widget_app
28
29
  from .commands.workflow import workflow_app
@@ -63,6 +64,7 @@ app.command("whoami")(auth_cmd.whoami)
63
64
  # Sub-command groups
64
65
  app.add_typer(auth_cmd.token_app, name="token")
65
66
  app.add_typer(agent_app, name="agent")
67
+ app.add_typer(ai_app, name="ai")
66
68
  app.add_typer(widget_app, name="widget")
67
69
  app.add_typer(workflow_app, name="workflow")
68
70
  app.add_typer(knowledge_app, name="knowledge")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chattermate-cli
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent.
5
5
  Author: ChatterMate
6
6
  License: AGPL-3.0-or-later
@@ -15,10 +15,12 @@ chattermate_cli.egg-info/requires.txt
15
15
  chattermate_cli.egg-info/top_level.txt
16
16
  chattermate_cli/commands/__init__.py
17
17
  chattermate_cli/commands/agent.py
18
+ chattermate_cli/commands/ai.py
18
19
  chattermate_cli/commands/auth.py
19
20
  chattermate_cli/commands/knowledge.py
20
21
  chattermate_cli/commands/widget.py
21
22
  chattermate_cli/commands/workflow.py
23
+ tests/test_ai.py
22
24
  tests/test_client.py
23
25
  tests/test_knowledge.py
24
26
  tests/test_mcp.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chattermate-cli"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "ChatterMate CLI and MCP server — sign up, authenticate, and configure agents, workflows and knowledge from the terminal or an AI agent."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,60 @@
1
+ """
2
+ ChatterMate - CLI AI Config Command Tests
3
+ Copyright (C) 2024 ChatterMate
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as
7
+ published by the Free Software Foundation, either version 3 of the
8
+ License, or (at your option) any later version.
9
+ """
10
+
11
+ import json
12
+
13
+ import httpx
14
+ from typer.testing import CliRunner
15
+
16
+ from chattermate_cli.client import Client
17
+ from chattermate_cli.commands.ai import ai_app
18
+
19
+ runner = CliRunner()
20
+
21
+
22
+ def make_client(handler, token="cmat_x"):
23
+ client = Client(api_url="http://test", token=token)
24
+ client._http = httpx.Client(transport=httpx.MockTransport(handler))
25
+ return client
26
+
27
+
28
+ def test_setup_ai_posts_to_ai_setup():
29
+ seen = {}
30
+
31
+ def handler(request):
32
+ seen["path"] = request.url.path
33
+ seen["json"] = json.loads(request.content)
34
+ return httpx.Response(200, json={"message": "ok"})
35
+
36
+ client = make_client(handler)
37
+ client.setup_ai(model_type="openai", model_name="gpt-4o", api_key="sk-1")
38
+
39
+ assert seen["path"] == "/api/v1/ai/setup"
40
+ assert seen["json"] == {"model_type": "openai", "model_name": "gpt-4o", "api_key": "sk-1"}
41
+
42
+
43
+ def test_get_ai_config_path():
44
+ seen = {}
45
+
46
+ def handler(request):
47
+ seen["path"] = request.url.path
48
+ return httpx.Response(200, json={"model_type": "CHATTERMATE", "model_name": "gpt-4o-mini", "is_active": True})
49
+
50
+ client = make_client(handler)
51
+ cfg = client.get_ai_config()
52
+ assert seen["path"] == "/api/v1/ai/config"
53
+ assert cfg["model_type"] == "CHATTERMATE"
54
+
55
+
56
+ def test_ai_setup_requires_key_for_custom_provider():
57
+ # Non-chattermate provider without --api-key must fail before any HTTP call.
58
+ result = runner.invoke(ai_app, ["setup", "--model-type", "openai", "--model-name", "gpt-4o"])
59
+ assert result.exit_code == 1
60
+ assert "api-key" in result.output
File without changes