yaicli 0.0.14__py3-none-any.whl → 0.0.15__py3-none-any.whl

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.
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yaicli"
3
- version = "0.0.14"
3
+ version = "0.0.15"
4
4
  description = "A simple CLI tool to interact with LLM"
5
5
  authors = [{ name = "belingud", email = "im.victor@qq.com" }]
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yaicli
3
- Version: 0.0.14
3
+ Version: 0.0.15
4
4
  Summary: A simple CLI tool to interact with LLM
5
5
  Project-URL: Homepage, https://github.com/belingud/yaicli
6
6
  Project-URL: Repository, https://github.com/belingud/yaicli
@@ -233,7 +233,7 @@ YAICLI is a compact yet potent command-line AI assistant, allowing you to engage
233
233
 
234
234
  Support regular and deep thinking models.
235
235
 
236
- > [!WARNING]
236
+ > [!WARNING]
237
237
  > This is a work in progress, some features could change or be removed in the future.
238
238
 
239
239
  ## Features
@@ -319,6 +319,7 @@ ANSWER_PATH=choices[0].message.content
319
319
  # true: streaming response
320
320
  # false: non-streaming response
321
321
  STREAM=true
322
+ CODE_THEME=monokia
322
323
 
323
324
  TEMPERATURE=0.7
324
325
  TOP_P=1.0
@@ -337,6 +338,7 @@ Below are the available configuration options and override environment variables
337
338
  - **COMPLETION_PATH**: Path for completions endpoint, default: /chat/completions, env: YAI_COMPLETION_PATH
338
339
  - **ANSWER_PATH**: Json path expression to extract answer from response, default: choices[0].message.content, env: YAI_ANSWER_PATH
339
340
  - **STREAM**: Enable/disable streaming responses, default: true, env: YAI_STREAM
341
+ - **CODE_THEME**: Theme for code blocks, default: monokia, env: YAI_CODE_THEME
340
342
  - **TEMPERATURE**: Temperature for response generation (default: 0.7), env: YAI_TEMPERATURE
341
343
  - **TOP_P**: Top-p sampling for response generation (default: 1.0), env: YAI_TOP_P
342
344
  - **MAX_TOKENS**: Maximum number of tokens for response generation (default: 1024), env: YAI_MAX_TOKENS
@@ -392,6 +394,12 @@ If you not sure how to config `COMPLETION_PATH` and `ANSWER_PATH`, here is a gui
392
394
  ```
393
395
  We are looking for the `text` field, so the path should be 1.Key `content`, 2.First obj `[0]`, 3.Key `text`. So it should be `content.[0].text`.
394
396
 
397
+ **CODE_THEME**
398
+
399
+ You can find the list of code theme here: https://pygments.org/styles/
400
+
401
+ Default: monokia
402
+ ![alt text](artwork/monokia.png)
395
403
 
396
404
  ## Usage
397
405
 
@@ -430,10 +438,10 @@ Run Options:
430
438
  ```bash
431
439
  ai -h
432
440
 
433
- Usage: ai [OPTIONS] [PROMPT]
434
-
435
- yaicli - Your AI interface in cli.
436
-
441
+ Usage: ai [OPTIONS] [PROMPT]
442
+
443
+ yaicli - Your AI interface in cli.
444
+
437
445
  ╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
438
446
  │ prompt [PROMPT] The prompt send to the LLM │
439
447
  ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -484,9 +492,10 @@ The capital of France is Paris.
484
492
  $ ai -s 'Check the current directory size'
485
493
  Assistant:
486
494
  du -sh .
487
-
488
- Generated command: du -sh .
489
- Execute this command? [y/n/e] (n): e
495
+ ╭─ Command ─╮
496
+ du -sh .
497
+ ╰───────────╯
498
+ Execute command? [e]dit, [y]es, [n]o (n): e
490
499
  Edit command, press enter to execute:
491
500
  du -sh ./
492
501
  Output:
@@ -530,9 +539,10 @@ Certainly! Here’s a brief overview of the solar system:
530
539
  🚀 > Check the current directory size
531
540
  Assistant:
532
541
  du -sh .
533
-
534
- Generated command: du -sh .
535
- Execute this command? [y/n/e] (n): e
542
+ ╭─ Command ─╮
543
+ du -sh .
544
+ ╰───────────╯
545
+ Execute command? [e]dit, [y]es, [n]o (n): e
536
546
  Edit command, press enter to execute:
537
547
  du -sh ./
538
548
  Output:
@@ -544,11 +554,13 @@ Output:
544
554
 
545
555
  ```bash
546
556
  $ ai --shell "Find all PDF files in my Downloads folder"
547
-
548
- Generated command: find ~/Downloads -type f -name "*.pdf"
549
- Execute this command? [y/n]: y
550
-
551
- Executing command: find ~/Downloads -type f -name "*.pdf"
557
+ Assistant:
558
+ find ~/Downloads -type f -name "*.pdf"
559
+ ╭─ Command ──────────────────────────────╮
560
+ │ find ~/Downloads -type f -name "*.pdf" │
561
+ ╰────────────────────────────────────────╯
562
+ Execute command? [e]dit, [y]es, [n]o (n): y
563
+ Output:
552
564
 
553
565
  /Users/username/Downloads/document1.pdf
554
566
  /Users/username/Downloads/report.pdf
@@ -0,0 +1,7 @@
1
+ pyproject.toml,sha256=NQ2sC5Y_yR0RhPagRF8RaLK5geBVmvMxphi_PmlTw2w,1452
2
+ yaicli.py,sha256=Vmawy7vedI8DXkTFARhi938UyzFeosQ0hoTrBaiERtA,21575
3
+ yaicli-0.0.15.dist-info/METADATA,sha256=6YEwUIKK4eUS4EzCvRxBdx5nx0Euj2IBq73Z9_agtok,29412
4
+ yaicli-0.0.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ yaicli-0.0.15.dist-info/entry_points.txt,sha256=gdduQwAuu_LeDqnDU81Fv3NPmD2tRQ1FffvolIP3S1Q,34
6
+ yaicli-0.0.15.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
+ yaicli-0.0.15.dist-info/RECORD,,
yaicli.py CHANGED
@@ -56,6 +56,7 @@ DEFAULT_CONFIG_MAP = {
56
56
  "COMPLETION_PATH": {"value": "chat/completions", "env_key": "YAI_COMPLETION_PATH"},
57
57
  "ANSWER_PATH": {"value": "choices[0].message.content", "env_key": "YAI_ANSWER_PATH"},
58
58
  "STREAM": {"value": "true", "env_key": "YAI_STREAM"},
59
+ "CODE_THEME": {"value": "monokia", "env_key": "YAI_CODE_THEME"},
59
60
  "TEMPERATURE": {"value": "0.7", "env_key": "YAI_TEMPERATURE"},
60
61
  "TOP_P": {"value": "1.0", "env_key": "YAI_TOP_P"},
61
62
  "MAX_TOKENS": {"value": "1024", "env_key": "YAI_MAX_TOKENS"},
@@ -79,6 +80,7 @@ ANSWER_PATH=choices[0].message.content
79
80
  # true: streaming response
80
81
  # false: non-streaming response
81
82
  STREAM=true
83
+ CODE_THEME=monokia
82
84
 
83
85
  TEMPERATURE=0.7
84
86
  TOP_P=1.0
@@ -194,7 +196,7 @@ class CLI:
194
196
  if current_platform in ("Windows", "nt"):
195
197
  is_powershell = len(getenv("PSModulePath", "").split(pathsep)) >= 3
196
198
  return "powershell.exe" if is_powershell else "cmd.exe"
197
- return basename(getenv("SHELL", "/bin/sh"))
199
+ return basename(getenv("SHELL", None) or "/bin/sh")
198
200
 
199
201
  def _filter_command(self, command: str) -> Optional[str]:
200
202
  """Filter out unwanted characters from command
@@ -325,12 +327,12 @@ class CLI:
325
327
  def _print_stream(self, response: httpx.Response) -> str:
326
328
  """Print response from LLM in streaming mode"""
327
329
  self.console.print("Assistant:", style="bold green")
328
- full_completion = ""
330
+ full_content = ""
329
331
  in_reasoning = False
330
332
  cursor_chars = ["_", " "]
331
333
  cursor_index = 0
332
334
 
333
- with Live() as live:
335
+ with Live(console=self.console) as live:
334
336
  for line in response.iter_lines():
335
337
  json_data = self._parse_stream_line(line)
336
338
  if not json_data:
@@ -340,26 +342,25 @@ class CLI:
340
342
  reason = self.get_reasoning_content(delta)
341
343
 
342
344
  if reason is not None:
343
- full_completion, in_reasoning = self._process_reasoning_content(
344
- reason, full_completion, in_reasoning
345
- )
345
+ full_content, in_reasoning = self._process_reasoning_content(reason, full_content, in_reasoning)
346
346
  else:
347
- full_completion, in_reasoning = self._process_regular_content(
348
- delta.get("content", "") or "", full_completion, in_reasoning
347
+ full_content, in_reasoning = self._process_regular_content(
348
+ delta.get("content", "") or "", full_content, in_reasoning
349
349
  )
350
350
 
351
- live.update(Markdown(markup=full_completion + cursor_chars[cursor_index]), refresh=True)
351
+ cursor = cursor_chars[cursor_index]
352
+ live.update(Markdown(markup=full_content + cursor, code_theme=self.config["CODE_THEME"]), refresh=True)
352
353
  cursor_index = (cursor_index + 1) % 2
353
354
  time.sleep(0.005) # Slow down the printing speed, avoiding screen flickering
354
- live.update(Markdown(markup=full_completion), refresh=True)
355
- return full_completion
355
+ live.update(Markdown(markup=full_content, code_theme=self.config["CODE_THEME"]), refresh=True)
356
+ return full_content
356
357
 
357
358
  def _print_normal(self, response: httpx.Response) -> str:
358
359
  """Print response from LLM in non-streaming mode"""
359
360
  self.console.print("Assistant:", style="bold green")
360
- full_completion = jmespath.search(self.config.get("ANSWER_PATH", "choices[0].message.content"), response.json())
361
- self.console.print(Markdown(full_completion + "\n"))
362
- return full_completion
361
+ full_content = jmespath.search(self.config.get("ANSWER_PATH", "choices[0].message.content"), response.json())
362
+ self.console.print(Markdown(full_content + "\n", code_theme=self.config["CODE_THEME"]))
363
+ return full_content
363
364
 
364
365
  def get_prompt_tokens(self) -> list[tuple[str, str]]:
365
366
  """Return prompt tokens for current mode"""
@@ -1,7 +0,0 @@
1
- pyproject.toml,sha256=D0K1CAn3p9Tf-E9VMq82Ml0jX44Eh6gYRzn5qKQD5xs,1452
2
- yaicli.py,sha256=5tQBYifI2CFJj_7BpRfRox7yeEYhDu9T9rDkKBppKzE,21392
3
- yaicli-0.0.14.dist-info/METADATA,sha256=738uxK3JVEOXwcR3m_KZqni9CRSSnj9RLbEOVIzXgCQ,29445
4
- yaicli-0.0.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- yaicli-0.0.14.dist-info/entry_points.txt,sha256=gdduQwAuu_LeDqnDU81Fv3NPmD2tRQ1FffvolIP3S1Q,34
6
- yaicli-0.0.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
- yaicli-0.0.14.dist-info/RECORD,,