deepflow-voicespeed-cli 0.1.2__tar.gz → 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepflow-voicespeed-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Command line client for VoiceSpeed OpenAPI
5
5
  Home-page: https://github.com/DeepFlowAI/voicespeed
6
6
  License: Proprietary
@@ -36,6 +36,9 @@ voicespeed agents update 1 --name "Support Pro"
36
36
  voicespeed agents disable 1
37
37
  voicespeed agents enable 1
38
38
  voicespeed agents basic-settings 1
39
+ voicespeed agents update-basic-settings 1 --prompt "You are a support assistant."
40
+ voicespeed agents update-basic-settings 1 --prompt-file prompt.txt \
41
+ --opening-mode fixed_greeting --greeting "Hello, how can I help?"
39
42
  voicespeed conversation run 1 --message "Hello" --mode text2text \
40
43
  --variables '{"customer_name":"Ada"}'
41
44
  voicespeed calls preset-variables 1 call_42 \
@@ -44,6 +47,8 @@ voicespeed realtime-sessions create 1 --external-id call_42 \
44
47
  --variables '{"customer_name":"Ada"}'
45
48
  ```
46
49
 
50
+ `agents update-basic-settings` changes only the fields passed on the command line. Use `--prompt-file`, `--runtime-context-file`, or `--greeting-file` for long text.
51
+
47
52
  `--variables` is a JSON object of text values. It is optional on `conversation run` and `realtime-sessions create`. `calls preset-variables` stores values for a FlowKit call before it starts; the call id is the same value later sent as `session_id`.
48
53
 
49
54
  All successful commands print formatted JSON.
@@ -26,6 +26,9 @@ voicespeed agents update 1 --name "Support Pro"
26
26
  voicespeed agents disable 1
27
27
  voicespeed agents enable 1
28
28
  voicespeed agents basic-settings 1
29
+ voicespeed agents update-basic-settings 1 --prompt "You are a support assistant."
30
+ voicespeed agents update-basic-settings 1 --prompt-file prompt.txt \
31
+ --opening-mode fixed_greeting --greeting "Hello, how can I help?"
29
32
  voicespeed conversation run 1 --message "Hello" --mode text2text \
30
33
  --variables '{"customer_name":"Ada"}'
31
34
  voicespeed calls preset-variables 1 call_42 \
@@ -34,6 +37,8 @@ voicespeed realtime-sessions create 1 --external-id call_42 \
34
37
  --variables '{"customer_name":"Ada"}'
35
38
  ```
36
39
 
40
+ `agents update-basic-settings` changes only the fields passed on the command line. Use `--prompt-file`, `--runtime-context-file`, or `--greeting-file` for long text.
41
+
37
42
  `--variables` is a JSON object of text values. It is optional on `conversation run` and `realtime-sessions create`. `calls preset-variables` stores values for a FlowKit call before it starts; the call id is the same value later sent as `session_id`.
38
43
 
39
44
  All successful commands print formatted JSON.
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = deepflow-voicespeed-cli
3
- version = 0.1.2
3
+ version = 0.1.3
4
4
  description = Command line client for VoiceSpeed OpenAPI
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
@@ -1,3 +1,3 @@
1
1
  """VoiceSpeed OpenAPI command line client."""
2
2
 
3
- __version__ = "0.1.2"
3
+ __version__ = "0.1.3"
@@ -4,6 +4,7 @@ import argparse
4
4
  import json
5
5
  import os
6
6
  import sys
7
+ from pathlib import Path
7
8
  from typing import Any, Sequence
8
9
 
9
10
  from .client import VoiceSpeedApiError, VoiceSpeedClient, VoiceSpeedRequestError
@@ -73,6 +74,44 @@ def _add_agent_commands(subparsers: argparse._SubParsersAction) -> None:
73
74
  settings_parser.add_argument("agent_id", type=int)
74
75
  settings_parser.set_defaults(handler=_handle_agents_basic_settings)
75
76
 
77
+ update_settings_parser = actions.add_parser(
78
+ "update-basic-settings",
79
+ help="Update agent basic engine settings",
80
+ )
81
+ update_settings_parser.add_argument("agent_id", type=int)
82
+ update_settings_parser.add_argument("--prompt")
83
+ update_settings_parser.add_argument("--prompt-file", help="Read the prompt from a text file")
84
+ update_settings_parser.add_argument("--runtime-context")
85
+ update_settings_parser.add_argument(
86
+ "--runtime-context-file",
87
+ help="Read the runtime context from a text file",
88
+ )
89
+ update_settings_parser.add_argument("--voice-llm")
90
+ update_settings_parser.add_argument("--text-llm")
91
+ update_settings_parser.add_argument(
92
+ "--text-think-mode",
93
+ action=argparse.BooleanOptionalAction,
94
+ default=None,
95
+ )
96
+ update_settings_parser.add_argument("--temperature", type=float)
97
+ update_settings_parser.add_argument("--diversity", type=float)
98
+ update_settings_parser.add_argument("--max-tokens", type=int)
99
+ update_settings_parser.add_argument("--context-turns", type=int)
100
+ update_settings_parser.add_argument(
101
+ "--call-direction",
102
+ choices=["inbound", "outbound"],
103
+ )
104
+ update_settings_parser.add_argument(
105
+ "--opening-mode",
106
+ choices=["none", "fixed_greeting", "model"],
107
+ )
108
+ update_settings_parser.add_argument("--greeting")
109
+ update_settings_parser.add_argument(
110
+ "--greeting-file",
111
+ help="Read the greeting from a text file",
112
+ )
113
+ update_settings_parser.set_defaults(handler=_handle_agents_update_basic_settings)
114
+
76
115
 
77
116
  def _add_conversation_commands(subparsers: argparse._SubParsersAction) -> None:
78
117
  conversation = subparsers.add_parser("conversation", help="Run OpenAPI chat")
@@ -238,6 +277,54 @@ def _handle_agents_basic_settings(
238
277
  return client.get_basic_settings(args.agent_id)
239
278
 
240
279
 
280
+ def _handle_agents_update_basic_settings(
281
+ client: VoiceSpeedClient,
282
+ args: argparse.Namespace,
283
+ ) -> Any:
284
+ settings: dict[str, Any] = {}
285
+ _set_text_setting(settings, "prompt", args.prompt, args.prompt_file)
286
+ _set_text_setting(
287
+ settings,
288
+ "runtime_context",
289
+ args.runtime_context,
290
+ args.runtime_context_file,
291
+ )
292
+ _set_text_setting(settings, "greeting", args.greeting, args.greeting_file)
293
+ for key, value in {
294
+ "voice_llm": args.voice_llm,
295
+ "text_llm": args.text_llm,
296
+ "text_think_mode": args.text_think_mode,
297
+ "temperature": args.temperature,
298
+ "diversity": args.diversity,
299
+ "max_tokens": args.max_tokens,
300
+ "context_turns": args.context_turns,
301
+ "call_direction": args.call_direction,
302
+ "opening_mode": args.opening_mode,
303
+ }.items():
304
+ if value is not None:
305
+ settings[key] = value
306
+ if not settings:
307
+ raise CliError("At least one basic-setting field is required.")
308
+ return client.update_basic_settings(args.agent_id, settings)
309
+
310
+
311
+ def _set_text_setting(
312
+ settings: dict[str, Any],
313
+ key: str,
314
+ value: str | None,
315
+ file_path: str | None,
316
+ ) -> None:
317
+ if value is not None and file_path is not None:
318
+ raise CliError(f"Use only one of --{key.replace('_', '-')} and --{key.replace('_', '-')}-file.")
319
+ if file_path is not None:
320
+ try:
321
+ value = Path(file_path).read_text(encoding="utf-8")
322
+ except OSError as exc:
323
+ raise CliError(f"Cannot read {key} file: {file_path}") from exc
324
+ if value is not None:
325
+ settings[key] = value
326
+
327
+
241
328
  def _handle_conversation_run(
242
329
  client: VoiceSpeedClient,
243
330
  args: argparse.Namespace,
@@ -112,6 +112,13 @@ class VoiceSpeedClient:
112
112
  def get_basic_settings(self, agent_id: int) -> Any:
113
113
  return self.request("GET", f"/agents/{agent_id}/basic-settings")
114
114
 
115
+ def update_basic_settings(self, agent_id: int, settings: dict[str, Any]) -> Any:
116
+ return self.request(
117
+ "PUT",
118
+ f"/agents/{agent_id}/basic-settings",
119
+ payload=settings,
120
+ )
121
+
115
122
  def run_conversation(
116
123
  self,
117
124
  agent_id: int,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepflow-voicespeed-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Command line client for VoiceSpeed OpenAPI
5
5
  Home-page: https://github.com/DeepFlowAI/voicespeed
6
6
  License: Proprietary
@@ -36,6 +36,9 @@ voicespeed agents update 1 --name "Support Pro"
36
36
  voicespeed agents disable 1
37
37
  voicespeed agents enable 1
38
38
  voicespeed agents basic-settings 1
39
+ voicespeed agents update-basic-settings 1 --prompt "You are a support assistant."
40
+ voicespeed agents update-basic-settings 1 --prompt-file prompt.txt \
41
+ --opening-mode fixed_greeting --greeting "Hello, how can I help?"
39
42
  voicespeed conversation run 1 --message "Hello" --mode text2text \
40
43
  --variables '{"customer_name":"Ada"}'
41
44
  voicespeed calls preset-variables 1 call_42 \
@@ -44,6 +47,8 @@ voicespeed realtime-sessions create 1 --external-id call_42 \
44
47
  --variables '{"customer_name":"Ada"}'
45
48
  ```
46
49
 
50
+ `agents update-basic-settings` changes only the fields passed on the command line. Use `--prompt-file`, `--runtime-context-file`, or `--greeting-file` for long text.
51
+
47
52
  `--variables` is a JSON object of text values. It is optional on `conversation run` and `realtime-sessions create`. `calls preset-variables` stores values for a FlowKit call before it starts; the call id is the same value later sent as `session_id`.
48
53
 
49
54
  All successful commands print formatted JSON.
@@ -87,6 +87,85 @@ def test_client_builds_json_request():
87
87
  }
88
88
 
89
89
 
90
+ def test_update_basic_settings_command(tmp_path):
91
+ prompt_file = tmp_path / "prompt.txt"
92
+ prompt_file.write_text("You are support.", encoding="utf-8")
93
+ client = Mock()
94
+ client.update_basic_settings.return_value = {"agent_id": 3, "configured": True}
95
+
96
+ with patch("deepflow_voicespeed_cli.cli.VoiceSpeedClient", return_value=client):
97
+ code = cli.main(
98
+ [
99
+ "--api-key",
100
+ "vsk_test",
101
+ "agents",
102
+ "update-basic-settings",
103
+ "3",
104
+ "--prompt-file",
105
+ str(prompt_file),
106
+ "--text-llm",
107
+ "text-model",
108
+ "--no-text-think-mode",
109
+ "--temperature",
110
+ "0.5",
111
+ "--opening-mode",
112
+ "fixed_greeting",
113
+ "--greeting",
114
+ "Hello.",
115
+ ]
116
+ )
117
+
118
+ assert code == 0
119
+ client.update_basic_settings.assert_called_once_with(
120
+ 3,
121
+ {
122
+ "prompt": "You are support.",
123
+ "greeting": "Hello.",
124
+ "text_llm": "text-model",
125
+ "text_think_mode": False,
126
+ "temperature": 0.5,
127
+ "opening_mode": "fixed_greeting",
128
+ },
129
+ )
130
+
131
+
132
+ def test_update_basic_settings_requires_a_field(capsys):
133
+ code = cli.main(
134
+ ["--api-key", "vsk_test", "agents", "update-basic-settings", "1"]
135
+ )
136
+
137
+ assert code == 1
138
+ assert "At least one basic-setting field" in capsys.readouterr().err
139
+
140
+
141
+ def test_client_update_basic_settings_uses_put():
142
+ captured = {}
143
+
144
+ class FakeResponse:
145
+ def __enter__(self):
146
+ return self
147
+
148
+ def __exit__(self, _exc_type, _exc, _tb):
149
+ return None
150
+
151
+ def read(self):
152
+ return b'{"agent_id": 3, "configured": true}'
153
+
154
+ def fake_urlopen(req, timeout):
155
+ captured["req"] = req
156
+ return FakeResponse()
157
+
158
+ with patch("deepflow_voicespeed_cli.client.urlopen", fake_urlopen):
159
+ client = VoiceSpeedClient("http://example.com/", "vsk_test")
160
+ result = client.update_basic_settings(3, {"prompt": "You are support."})
161
+
162
+ req = captured["req"]
163
+ assert result["agent_id"] == 3
164
+ assert req.get_method() == "PUT"
165
+ assert req.full_url == "http://example.com/api/v1/openapi/agents/3/basic-settings"
166
+ assert json.loads(req.data.decode("utf-8")) == {"prompt": "You are support."}
167
+
168
+
90
169
  def test_conversation_run_command():
91
170
  client = Mock()
92
171
  client.run_conversation.return_value = {"reply": "hi"}