clai 0.1.0__py3-none-any.whl → 0.1.12__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.
Potentially problematic release.
This version of clai might be problematic. Click here for more details.
- clai/__init__.py +10 -5
- clai/__main__.py +6 -0
- clai-0.1.12.dist-info/METADATA +106 -0
- clai-0.1.12.dist-info/RECORD +6 -0
- {clai-0.1.0.dist-info → clai-0.1.12.dist-info}/WHEEL +1 -1
- clai-0.1.12.dist-info/entry_points.txt +2 -0
- clai/api.py +0 -17
- clai/invoke.py +0 -103
- clai-0.1.0.dist-info/METADATA +0 -80
- clai-0.1.0.dist-info/RECORD +0 -7
- clai-0.1.0.dist-info/entry_points.txt +0 -4
clai/__init__.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
from importlib.metadata import version as _metadata_version
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
from pydantic_ai import _cli
|
|
4
|
+
|
|
5
|
+
__all__ = '__version__', 'cli'
|
|
6
|
+
__version__ = _metadata_version('clai')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def cli():
|
|
10
|
+
"""Run the clai CLI and exit."""
|
|
11
|
+
_cli.cli_exit('clai')
|
clai/__main__.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clai
|
|
3
|
+
Version: 0.1.12
|
|
4
|
+
Summary: PydanticAI CLI: command line interface to chat to LLMs
|
|
5
|
+
Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Environment :: MacOS X
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Information Technology
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Internet
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: pydantic-ai==0.1.12
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# clai
|
|
31
|
+
|
|
32
|
+
[](https://github.com/pydantic/pydantic-ai/actions/workflows/ci.yml?query=branch%3Amain)
|
|
33
|
+
[](https://coverage-badge.samuelcolvin.workers.dev/redirect/pydantic/pydantic-ai)
|
|
34
|
+
[](https://pypi.python.org/pypi/clai)
|
|
35
|
+
[](https://github.com/pydantic/pydantic-ai)
|
|
36
|
+
[](https://github.com/pydantic/pydantic-ai/blob/main/LICENSE)
|
|
37
|
+
|
|
38
|
+
(pronounced "clay")
|
|
39
|
+
|
|
40
|
+
Command line interface to chat to LLMs, part of the [PydanticAI project](https://github.com/pydantic/pydantic-ai).
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
<!-- Keep this in sync with docs/cli.md -->
|
|
45
|
+
|
|
46
|
+
You'll need to set an environment variable depending on the provider you intend to use.
|
|
47
|
+
|
|
48
|
+
E.g. if you're using OpenAI, set the `OPENAI_API_KEY` environment variable:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
export OPENAI_API_KEY='your-api-key-here'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then with [`uvx`](https://docs.astral.sh/uv/guides/tools/), run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
uvx clai
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or to install `clai` globally [with `uv`](https://docs.astral.sh/uv/guides/tools/#installing-tools), run:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
uv tool install clai
|
|
64
|
+
...
|
|
65
|
+
clai
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or with `pip`, run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install clai
|
|
72
|
+
...
|
|
73
|
+
clai
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Either way, running `clai` will start an interactive session where you can chat with the AI model. Special commands available in interactive mode:
|
|
77
|
+
|
|
78
|
+
- `/exit`: Exit the session
|
|
79
|
+
- `/markdown`: Show the last response in markdown format
|
|
80
|
+
- `/multiline`: Toggle multiline input mode (use Ctrl+D to submit)
|
|
81
|
+
|
|
82
|
+
## Help
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
usage: clai [-h] [-m [MODEL]] [-l] [-t [CODE_THEME]] [--no-stream] [--version] [prompt]
|
|
86
|
+
|
|
87
|
+
PydanticAI CLI v...
|
|
88
|
+
|
|
89
|
+
Special prompts:
|
|
90
|
+
* `/exit` - exit the interactive mode (ctrl-c and ctrl-d also work)
|
|
91
|
+
* `/markdown` - show the last markdown output of the last question
|
|
92
|
+
* `/multiline` - toggle multiline mode
|
|
93
|
+
|
|
94
|
+
positional arguments:
|
|
95
|
+
prompt AI Prompt, if omitted fall into interactive mode
|
|
96
|
+
|
|
97
|
+
options:
|
|
98
|
+
-h, --help show this help message and exit
|
|
99
|
+
-m [MODEL], --model [MODEL]
|
|
100
|
+
Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4o" or "anthropic:claude-3-7-sonnet-latest". Defaults to "openai:gpt-4o".
|
|
101
|
+
-l, --list-models List all available models and exit
|
|
102
|
+
-t [CODE_THEME], --code-theme [CODE_THEME]
|
|
103
|
+
Which colors to use for code, can be "dark", "light" or any theme from pygments.org/styles/. Defaults to "dark" which works well on dark terminals.
|
|
104
|
+
--no-stream Disable streaming from the model
|
|
105
|
+
--version Show version and exit
|
|
106
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
clai/__init__.py,sha256=N6cw-oEjoIAPwaEqBRCHf3j9Y4tNDUp1YS-tplkvyfA,238
|
|
2
|
+
clai/__main__.py,sha256=1ClP9aMManzEL8lbRtet7dGW87KZmQRB92aRcmlCeMs,138
|
|
3
|
+
clai-0.1.12.dist-info/METADATA,sha256=jqlSwSw99KQOjr5wdHmO15j9sc-ExMCYmbplZL2cJv8,4052
|
|
4
|
+
clai-0.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
clai-0.1.12.dist-info/entry_points.txt,sha256=DyHzt1YJ1DwtFNsrFOoUGwKkmk8mHJ-iiZLairTUq5E,34
|
|
6
|
+
clai-0.1.12.dist-info/RECORD,,
|
clai/api.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from types import ModuleType
|
|
3
|
-
|
|
4
|
-
import openai
|
|
5
|
-
|
|
6
|
-
API_TOKEN_VAR = "OPENAI_API_TOKEN"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def initialize_api() -> ModuleType:
|
|
10
|
-
try:
|
|
11
|
-
api_key = os.environ[API_TOKEN_VAR]
|
|
12
|
-
except KeyError:
|
|
13
|
-
print(f"You must set the`{API_TOKEN_VAR}` variable in your environment!")
|
|
14
|
-
exit(1)
|
|
15
|
-
|
|
16
|
-
openai.api_key = api_key
|
|
17
|
-
return openai
|
clai/invoke.py
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
from argparse import ArgumentParser
|
|
2
|
-
|
|
3
|
-
from .api import initialize_api
|
|
4
|
-
|
|
5
|
-
DEFAULT_ASSISTANT_ROLE = """
|
|
6
|
-
You are an assistant that is capable of being called anywhere on a desktop computer. You
|
|
7
|
-
may be called within the context of an email, a URL box, commandline, a text editor, or
|
|
8
|
-
even word documents!
|
|
9
|
-
|
|
10
|
-
Your role is to answer the users request as shortly and succinctly as possible. You
|
|
11
|
-
will follow the following rules:
|
|
12
|
-
|
|
13
|
-
When asked to write a command:
|
|
14
|
-
1) Assume a linux desktop environment in a bash shell
|
|
15
|
-
2) Feel free to use commonly installed unix tools
|
|
16
|
-
|
|
17
|
-
When asked to write a command, code, formulas, or any one-line response task:
|
|
18
|
-
1) NEVER WRITE EXPLANATIONS. Only include the command/code/etc, ready to be run
|
|
19
|
-
2) NEVER WRITE USAGE INSTRUCTIONS.
|
|
20
|
-
3) Remember, the text that you write will immediately be run, do not include code blocks
|
|
21
|
-
4) If there is something that requires user input, such as a cell in a sheet or a
|
|
22
|
-
variable from the user, write it inside of brackets, like this: <INPUT DESCRIBER>,
|
|
23
|
-
where the insides of the bracket have an example of what is needed to be filled in.
|
|
24
|
-
|
|
25
|
-
When asked to write long-form text content:
|
|
26
|
-
1) Never ask for more information. If something is to be guessed, write it in template
|
|
27
|
-
format. For example, if asked to write an email use <Insert time here> when writing
|
|
28
|
-
the portion of an email that specifies something that was not included in the users
|
|
29
|
-
question.
|
|
30
|
-
2) Only assume the content is long form if the user mentions email, or 'long message'.
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
EXAMPLE_EMAIL = """
|
|
34
|
-
Dear <Recipient's Name>,
|
|
35
|
-
|
|
36
|
-
I hope this email finds you well. I am writing to request a meeting with you on <Date and Time>, and I would appreciate it if you could confirm your availability at your earliest convenience.
|
|
37
|
-
|
|
38
|
-
The purpose of this meeting is to discuss <Purpose of the Meeting> with you. Specifically, I would like to <Agenda Item 1>, <Agenda Item 2>, and <Agenda Item 3>. The meeting will last approximately <Meeting Duration> and will take place at <Meeting Location>.
|
|
39
|
-
|
|
40
|
-
Please let me know if this date and time work for you. If not, please suggest an alternative time that is convenient for you. Additionally, if there are any documents or information you would like me to review before the meeting, please let me know, and I will make sure to review them.
|
|
41
|
-
|
|
42
|
-
I look forward to hearing from you soon.
|
|
43
|
-
|
|
44
|
-
Best regards,
|
|
45
|
-
|
|
46
|
-
<Your Name>
|
|
47
|
-
""" # noqa: E501
|
|
48
|
-
|
|
49
|
-
EXAMPLE_REGEX = '=IFERROR(REGEXEXTRACT(<INPUT CELL HERE>, "[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}");"")' # noqa
|
|
50
|
-
|
|
51
|
-
EXAMPLE_PYTHON = """
|
|
52
|
-
def fibonacci(n: int) -> Generator[int, None, None]:
|
|
53
|
-
a, b = 0, 1
|
|
54
|
-
for _ in range(n):
|
|
55
|
-
yield a
|
|
56
|
-
a, b = b, a + b
|
|
57
|
-
"""
|
|
58
|
-
CONTEXT = [
|
|
59
|
-
{"role": "system", "content": DEFAULT_ASSISTANT_ROLE},
|
|
60
|
-
{
|
|
61
|
-
"role": "user",
|
|
62
|
-
"content": "commandline search for files with the name 'bruh' in them",
|
|
63
|
-
},
|
|
64
|
-
{"role": "assistant", "content": "grep -rnw . -e 'bruh'"},
|
|
65
|
-
{
|
|
66
|
-
"role": "user",
|
|
67
|
-
"content": "email set up a meeting next week",
|
|
68
|
-
},
|
|
69
|
-
{"role": "assistant", "content": EXAMPLE_EMAIL},
|
|
70
|
-
{
|
|
71
|
-
"role": "user",
|
|
72
|
-
"content": "google sheets formula extracts an email from string of text",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"role": "assistant",
|
|
76
|
-
"content": EXAMPLE_REGEX,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"role": "user",
|
|
80
|
-
"content": "python fibonacci function in form of a generator",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"role": "assistant",
|
|
84
|
-
"content": EXAMPLE_PYTHON,
|
|
85
|
-
},
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def invoke() -> None:
|
|
90
|
-
parser = ArgumentParser("CLAI- your own command line AI!")
|
|
91
|
-
parser.add_argument("prompt", type=str, nargs="+")
|
|
92
|
-
parser.add_argument("-e", "--engine", default="")
|
|
93
|
-
args = parser.parse_args()
|
|
94
|
-
|
|
95
|
-
openai = initialize_api()
|
|
96
|
-
|
|
97
|
-
prompt = " ".join(args.prompt)
|
|
98
|
-
response = openai.ChatCompletion.create(
|
|
99
|
-
model="gpt-3.5-turbo", messages=[*CONTEXT, {"role": "user", "content": prompt}]
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
best_response = response["choices"][0]["message"]["content"]
|
|
103
|
-
print(best_response.strip())
|
clai-0.1.0.dist-info/METADATA
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: clai
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Command Line AI- this tool lets you call ChatGPT from a CLI
|
|
5
|
-
License: Proprietary
|
|
6
|
-
Author: apockill
|
|
7
|
-
Author-email: apocthiel@gmail.com
|
|
8
|
-
Requires-Python: >=3.8,<4.0
|
|
9
|
-
Classifier: License :: Other/Proprietary License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Requires-Dist: openai (>=0.27.0,<0.28.0)
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
|
|
17
|
-
# clai
|
|
18
|
-
Command Line AI- this tool lets you call ChatGPT from a CLI.
|
|
19
|
-
|
|
20
|
-
I'm designing this to be used in conjunction with a fork of [shin][shin], which will allow you
|
|
21
|
-
to call `clai` from any textbox in your computer. Finally, chatGPT everywhere!
|
|
22
|
-
|
|
23
|
-
[shin]: https://github.com/apockill/shin
|
|
24
|
-
_________________
|
|
25
|
-
|
|
26
|
-
[](http://badge.fury.io/py/clai)
|
|
27
|
-
[](https://github.com/apockill/clai/actions?query=workflow%3ATest)
|
|
28
|
-
[](https://github.com/apockill/clai/actions?query=workflow%3ALint)
|
|
29
|
-
[](https://codecov.io/gh/apockill/clai)
|
|
30
|
-
[](https://github.com/psf/black)
|
|
31
|
-
[](https://timothycrosley.github.io/isort/)
|
|
32
|
-
_________________
|
|
33
|
-
|
|
34
|
-
[Read Latest Documentation](https://apockill.github.io/clai/) - [Browse GitHub Code Repository](https://github.com/apockill/clai/)
|
|
35
|
-
_________________
|
|
36
|
-
|
|
37
|
-
## Installation
|
|
38
|
-
1. The recommended installation method is to use `pipx`, via
|
|
39
|
-
```
|
|
40
|
-
pipx install clai
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
1. Then go to [OpenAI] and create an API Key. Once it's generated, add the following to
|
|
44
|
-
your `.bashrc`:
|
|
45
|
-
```bash
|
|
46
|
-
export OPENAI_API_TOKEN=<paste here>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
[OpenAI]: https://platform.openai.com/account/api-keys
|
|
50
|
-
|
|
51
|
-
## Usage
|
|
52
|
-
Invoke the assistant with the format `clai <your prompt>`. For example:
|
|
53
|
-
```
|
|
54
|
-
clai Write an email saying I'll be late to work because I'm working on commandline AIs
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Development
|
|
58
|
-
|
|
59
|
-
### Installing python dependencies
|
|
60
|
-
```shell
|
|
61
|
-
poetry install
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Running Tests
|
|
65
|
-
```shell
|
|
66
|
-
pytest .
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Formatting Code
|
|
70
|
-
```shell
|
|
71
|
-
bash .github/format.sh
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Linting
|
|
75
|
-
```shell
|
|
76
|
-
bash .github/check_lint.sh
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
# TODO: remove references to tests?
|
|
80
|
-
|
clai-0.1.0.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
clai/__init__.py,sha256=HhEUgp8tO9dj0U9BVJXEc_m2fFqCEQl5_2SWIibEoHc,126
|
|
2
|
-
clai/api.py,sha256=vG4EduZzTaE0aQJ7XH-OaihPNSbN3LVN0lSoxoXDYNQ,348
|
|
3
|
-
clai/invoke.py,sha256=qzVNs3Ow-5JttQqMfvvONFIcNddSGInFVn3UagxE958,3958
|
|
4
|
-
clai-0.1.0.dist-info/entry_points.txt,sha256=DykWVwXNmaefQkuCJ5k5fKBjottMVlYF2goUhKScjlY,51
|
|
5
|
-
clai-0.1.0.dist-info/WHEEL,sha256=bbU3AyvhQ312rVm7zzRQjs6axI1UYWC3nmFA2E6FFSI,88
|
|
6
|
-
clai-0.1.0.dist-info/METADATA,sha256=_or3tpaFKcTLEYZm-2KtRj6yqYwX4Ko5hD_4-rT2h5k,2567
|
|
7
|
-
clai-0.1.0.dist-info/RECORD,,
|