yaicli 0.3.0__py3-none-any.whl → 0.3.1__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.3.0"
3
+ version = "0.3.1"
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"
yaicli/api.py CHANGED
@@ -93,7 +93,11 @@ class ApiClient:
93
93
 
94
94
  def get_headers(self) -> Dict[str, str]:
95
95
  """Get the request headers."""
96
- return {"Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json"}
96
+ return {
97
+ "Authorization": f"Bearer {self.api_key}",
98
+ "Content-Type": "application/json",
99
+ "X-Title": "Yaicli",
100
+ }
97
101
 
98
102
  def _process_completion_response(self, response_json: Dict[str, Any]) -> Tuple[Optional[str], Optional[str]]:
99
103
  """Process the JSON response from a non-streamed completion request."""
yaicli/entry.py CHANGED
@@ -130,7 +130,7 @@ def main(
130
130
  code: bool = typer.Option(
131
131
  False,
132
132
  "--code",
133
- help="Generate and optionally execute a code block (non-interactive).",
133
+ help="Generate code in plaintext (non-interactive).",
134
134
  rich_help_panel="Code Options",
135
135
  ),
136
136
  # ------------------- Chat Options -------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yaicli
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -465,6 +465,9 @@ ai --chat
465
465
  # Generate and execute shell commands
466
466
  ai --shell "Create a backup of my Documents folder"
467
467
 
468
+ # Generate code snippets, default in Python
469
+ ai --code "Write a Python function to sort a list"
470
+
468
471
  # Analyze code from a file
469
472
  cat app.py | ai "Explain what this code does"
470
473
 
@@ -475,17 +478,50 @@ ai --verbose "Explain quantum computing"
475
478
  ### Command Line Reference
476
479
 
477
480
  ```
478
- Usage: ai [OPTIONS] [PROMPT]
481
+ Usage: ai [OPTIONS] [PROMPT]
482
+
483
+ YAICLI: Your AI assistant in the command line.
484
+ Call with a PROMPT to get a direct answer, use --shell to execute as command, or use --chat for an interactive session.
485
+
486
+ ╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
487
+ │ prompt [PROMPT] The prompt to send to the LLM. Reads from stdin if available. [default: None] │
488
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
489
+ ╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
490
+ │ --install-completion Install completion for the current shell. │
491
+ │ --show-completion Show completion for the current shell, to copy it or customize the installation. │
492
+ │ --help -h Show this message and exit. │
493
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
494
+ ╭─ LLM Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
495
+ │ --model -M TEXT Specify the model to use. │
496
+ │ --temperature -T FLOAT RANGE [0.0<=x<=2.0] Specify the temperature to use. [default: 0.7] │
497
+ │ --top-p -P FLOAT RANGE [0.0<=x<=1.0] Specify the top-p to use. [default: 1.0] │
498
+ │ --max-tokens -M INTEGER RANGE [x>=1] Specify the max tokens to use. [default: 1024] │
499
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
500
+ ╭─ Role Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
501
+ │ --role -r TEXT Specify the assistant role to use. [default: DEFAULT] │
502
+ │ --create-role TEXT Create a new role with the specified name. │
503
+ │ --delete-role TEXT Delete a role with the specified name. │
504
+ │ --list-roles List all available roles. │
505
+ │ --show-role TEXT Show the role with the specified name. │
506
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
507
+ ╭─ Chat Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
508
+ │ --chat -c Start in interactive chat mode. │
509
+ │ --list-chats List saved chat sessions. │
510
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
511
+ ╭─ Shell Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
512
+ │ --shell -s Generate and optionally execute a shell command (non-interactive). │
513
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
514
+ ╭─ Code Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
515
+ │ --code Generate code in plaintext (non-interactive). │
516
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
517
+ ╭─ Other Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
518
+ │ --verbose -V Show verbose output (e.g., loaded config). │
519
+ │ --template Show the default config file template and exit. │
520
+ │ --show-reasoning --no-show-reasoning Show reasoning content from the LLM. (default: True) │
521
+ │ --justify -j [default|left|center|right|full] Specify the justify to use. [default: default] │
522
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
479
523
  ```
480
524
 
481
- | Option | Short | Description |
482
- |--------------|-------|-------------------------------------|
483
- | `--chat` | `-c` | Start in interactive chat mode |
484
- | `--shell` | `-s` | Generate and execute shell commands |
485
- | `--help` | `-h` | Show help message and exit |
486
- | `--verbose` | `-V` | Show detailed debug information |
487
- | `--template` | | Display the config template |
488
-
489
525
  ### Interactive Mode Features
490
526
 
491
527
  <table>
@@ -640,6 +676,32 @@ cat demo.py | ai "Explain this code"
640
676
  cat error.log | ai "Why am I getting these errors in my Python app?"
641
677
  ```
642
678
 
679
+ ### Role Management
680
+
681
+ ```bash
682
+ # Create a new role, you need to input the role description
683
+ ai --create-role "Philosopher Master"
684
+
685
+ # List all roles
686
+ ai --list-roles
687
+
688
+ # Show a role
689
+ ai --show-role "Philosopher Master"
690
+
691
+ # Delete a role
692
+ ai --delete-role "Philosopher Master"
693
+ ```
694
+
695
+ Once you create a role, you can use it in the `--role` option.
696
+
697
+ ```bash
698
+ # Use a specific role
699
+ ai --role "Philosopher Master" "What is the meaning of life?"
700
+
701
+ # Use a role in chat
702
+ ai --chat --role "Philosopher Master"
703
+ ```
704
+
643
705
  ### History Management
644
706
 
645
707
  YAICLI maintains a history of your interactions (default: 500 entries) stored in `~/.yaicli_history`. You can:
@@ -674,6 +736,23 @@ Output:
674
736
  109M ./
675
737
  ```
676
738
 
739
+ ### Code Generation
740
+
741
+ In code mode, select the language for code generation. If none is specified, Python is the default.
742
+
743
+ The `--code` mode outputs plain text, making it easy to copy, paste, or redirect to a file, especially when using the standard model.
744
+
745
+ When using a deep reasoning model, the thinking content is displayed with syntax highlighting. To disable this, use the `--no-show-reasoning` option or set `SHOW_REASONING` to `false` in the configuration.
746
+
747
+ ```bash
748
+ $ ai --code 'Write a fib generator'
749
+ def fib_generator():
750
+ a, b = 0, 1
751
+ while True:
752
+ yield a
753
+ a, b = b, a + b
754
+ ```
755
+
677
756
  ### Chat Mode Example
678
757
 
679
758
  ```bash
@@ -747,6 +826,14 @@ Output:
747
826
  ...
748
827
  ```
749
828
 
829
+ ### Code Mode Example
830
+
831
+ ```bash
832
+ $ ai --code "write a fib generator" --model deepseek-r1
833
+ ```
834
+
835
+ ![fib code example](artwork/reasoning_code_example.png)
836
+
750
837
  ## 💻 Technical Details
751
838
 
752
839
  ### Architecture
@@ -1,20 +1,20 @@
1
- pyproject.toml,sha256=aRTnC0bBuX6dPMSLTCZOAB0M5AnpW_eVvLfmc0nZZNg,1519
1
+ pyproject.toml,sha256=C4r3nsve6z4u7vKI2eIKvQ4YWoiGwAYL72w_YcjTkcc,1519
2
2
  yaicli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- yaicli/api.py,sha256=mRb86Ej1MVR1AbJimX7VWYd0D1pNarqylK4rbAYLSIA,13598
3
+ yaicli/api.py,sha256=9kRozzxBKduQsda3acnxzvOD9wRLL0cH182L4ddHY8E,13666
4
4
  yaicli/chat_manager.py,sha256=I7BAMz91FLYT6x69wbomtAGLx0WsoTwS4Wo0MgP6P9I,10644
5
5
  yaicli/cli.py,sha256=HnfmD-7mLsaUCJqQYehsfxonuyJ11B5zi3lbKbQxrH0,22684
6
6
  yaicli/config.py,sha256=xtzgXApM93zCqSUxmVSBdph0co_NKfEUU3hWtPe8qvM,6236
7
7
  yaicli/console.py,sha256=291F4hGksJtxYpg_mehepCIJ-eB2MaDNIyv1JAMgJ1Y,1985
8
8
  yaicli/const.py,sha256=iOQNG6M4EBmKgbwZdNqRsHrcQ7Od1nKOyLAqUhfMEBM,7020
9
- yaicli/entry.py,sha256=z59Ojr_fuj6ykEdgusWzedKO3VA1ytW6OlMFdUuyj4A,7478
9
+ yaicli/entry.py,sha256=Yp0Z--x-7dowrz-h8hJJ4_BoCzuDjS11NcM8YgFzUoY,7460
10
10
  yaicli/exceptions.py,sha256=ndedSdE0uaxxHrWN944BkbhMfRMSMxGDfmqmCKCGJco,924
11
11
  yaicli/history.py,sha256=s-57X9FMsaQHF7XySq1gGH_jpd_cHHTYafYu2ECuG6M,2472
12
12
  yaicli/printer.py,sha256=nXpralD5qZJQga3OTdEPhj22g7UoF-4mJbZeOtWXojo,12430
13
13
  yaicli/render.py,sha256=mB1OT9859_PTwI9f-KY802lPaeQXKRw6ls_5jN21jWc,511
14
14
  yaicli/roles.py,sha256=bhXpLnGTPRZp3-K1Tt6ppTsuG2v9S0RAXikfMFhDs_U,9144
15
15
  yaicli/utils.py,sha256=MLvb-C5n19AD9Z1nW4Z3Z43ZKNH8STxQmNDnL7mq26E,4490
16
- yaicli-0.3.0.dist-info/METADATA,sha256=4QDEAn4I3sq89qwWQ8e6cQ5ziCu_-HbH03WwS4ssGvE,34744
17
- yaicli-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- yaicli-0.3.0.dist-info/entry_points.txt,sha256=iMhGm3btBaqrknQoF6WCg5sdx69ZyNSC73tRpCcbcLw,63
19
- yaicli-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
- yaicli-0.3.0.dist-info/RECORD,,
16
+ yaicli-0.3.1.dist-info/METADATA,sha256=fAGgZNCTckGuIS8Us6un9AC-60I5ZsEfw6k5RRHK7XU,45320
17
+ yaicli-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ yaicli-0.3.1.dist-info/entry_points.txt,sha256=iMhGm3btBaqrknQoF6WCg5sdx69ZyNSC73tRpCcbcLw,63
19
+ yaicli-0.3.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ yaicli-0.3.1.dist-info/RECORD,,
File without changes