zettcode-commands 0.4.3__tar.gz → 0.4.5__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.5
2
2
  Name: zettcode-commands
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Summary: The slash commands that act on ZettCode's terminal application, offered to it as a plugin
5
5
  Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
6
6
  Author: Chang-LeHung
@@ -31,10 +31,17 @@ class ContextPagePlugin(TuiPlugin):
31
31
  """Open the context page, or say why there is nothing to measure yet."""
32
32
  host = context.require_host()
33
33
  if host.client.active_model is None:
34
- return CommandResult(
35
- message="No model is configured yet \u2014 `/config` adds one; `/context` has something to "
36
- "measure after the first request."
37
- )
34
+ if host.client.models:
35
+ message = (
36
+ "No model is chosen yet \u2014 `/model` picks one; `/context` has something to "
37
+ "measure after the first request."
38
+ )
39
+ else:
40
+ message = (
41
+ "No model is configured yet \u2014 `/config` adds one; `/context` has something to "
42
+ "measure after the first request."
43
+ )
44
+ return CommandResult(message=message)
38
45
  service = ctx.agent.context_report_service()
39
46
  if service is None:
40
47
  report = await host.client.session.context()
@@ -183,14 +183,19 @@ def model_words(host: CommandHost | None) -> tuple[Subcommand, ...]:
183
183
  """Offer the configured models by the name ``/model`` accepts.
184
184
 
185
185
  A name two entries share is left out (``/model`` refuses it as ambiguous), and so is one with a space in it,
186
- which would not stay one word. Before there is a shell there is nothing to offer.
186
+ which would not stay one word. The line beside it says where the model came from and which protocol it speaks,
187
+ because two entries can share a model id and the name alone tells neither. Before there is a shell there is
188
+ nothing to offer.
187
189
  """
188
190
  if host is None:
189
191
  return ()
190
192
  models = host.client.models
191
193
  shown = [model.display_model or model.model for model in models]
192
194
  return tuple(
193
- Subcommand(name, model.model)
195
+ Subcommand(
196
+ name,
197
+ f"{'plugin ' + model.provider if model.provider is not None else 'file'} · {model.api} · {model.model}",
198
+ )
194
199
  for name, model in zip(shown, models, strict=True)
195
200
  if shown.count(name) == 1 and not any(character.isspace() for character in name)
196
201
  )
@@ -228,11 +233,11 @@ class ModelCommands(TuiPlugin):
228
233
  """Open the model picker, or switch directly to a named model.
229
234
 
230
235
  The picker is a widget, so the command needs the shell: the agent owns the models, the shell owns the
231
- widget that chooses between them. A machine with no model has nothing to pick, so the command points at
232
- the one that adds the first entry instead of opening an empty list.
236
+ widget that chooses between them. A machine with nothing to pick has no model at all, so the command points
237
+ at the one that adds the first entry instead of opening an empty list.
233
238
  """
234
239
  host = context.require_host()
235
- if host.client.active_model is None:
240
+ if host.client.active_model is None and not host.client.models:
236
241
  return CommandResult(message="No model is configured yet \u2014 `/config` adds the first one.")
237
242
  if context.argument:
238
243
  host.change_model(context.argument)
@@ -253,9 +258,13 @@ class ModelCommands(TuiPlugin):
253
258
  """
254
259
  host = context.require_host()
255
260
  if host.client.active_model is None:
256
- return CommandResult(
257
- message="No model is configured yet \u2014 `/config` adds one; `/effort` sets the level it reasons at."
258
- )
261
+ if host.client.models:
262
+ message = "No model is chosen yet \u2014 `/model` picks one; `/effort` sets the level it reasons at."
263
+ else:
264
+ message = (
265
+ "No model is configured yet \u2014 `/config` adds one; `/effort` sets the level it reasons at."
266
+ )
267
+ return CommandResult(message=message)
259
268
  if context.argument:
260
269
  try:
261
270
  host.change_effort(context.argument)