how-cli 0.1.0__tar.gz → 0.2.0__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.
- {how_cli-0.1.0 → how_cli-0.2.0}/LICENSE +21 -21
- {how_cli-0.1.0 → how_cli-0.2.0}/MANIFEST.in +1 -1
- {how_cli-0.1.0/how_cli.egg-info → how_cli-0.2.0}/PKG-INFO +116 -103
- {how_cli-0.1.0 → how_cli-0.2.0}/README.md +96 -87
- {how_cli-0.1.0 → how_cli-0.2.0}/how/__init__.py +1 -1
- {how_cli-0.1.0 → how_cli-0.2.0}/how/__main__.py +4 -4
- how_cli-0.2.0/how/core/__init__.py +6 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/chains.py +3 -3
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/config.py +49 -49
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/llm.py +8 -8
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/parser.py +3 -3
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/prompts.py +50 -50
- how_cli-0.2.0/how/core/providers.py +17 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/schema.py +6 -6
- {how_cli-0.1.0 → how_cli-0.2.0}/how/core/template.py +18 -18
- {how_cli-0.1.0 → how_cli-0.2.0}/how/formatting.py +36 -36
- {how_cli-0.1.0 → how_cli-0.2.0}/how/how.py +82 -82
- {how_cli-0.1.0 → how_cli-0.2.0}/how/infer.py +27 -27
- {how_cli-0.1.0 → how_cli-0.2.0/how_cli.egg-info}/PKG-INFO +116 -103
- how_cli-0.2.0/how_cli.egg-info/requires.txt +7 -0
- how_cli-0.2.0/requirements.txt +7 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/setup.cfg +4 -4
- {how_cli-0.1.0 → how_cli-0.2.0}/setup.py +30 -30
- how_cli-0.1.0/how/core/__init__.py +0 -6
- how_cli-0.1.0/how/core/providers.py +0 -8
- how_cli-0.1.0/how_cli.egg-info/requires.txt +0 -3
- how_cli-0.1.0/requirements.txt +0 -3
- {how_cli-0.1.0 → how_cli-0.2.0}/how_cli.egg-info/SOURCES.txt +0 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/how_cli.egg-info/dependency_links.txt +0 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/how_cli.egg-info/entry_points.txt +0 -0
- {how_cli-0.1.0 → how_cli-0.2.0}/how_cli.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Rudransh Joshi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Rudransh Joshi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
include requirements.txt
|
|
1
|
+
include requirements.txt
|
|
2
2
|
include README.md
|
|
@@ -1,103 +1,116 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: how-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: An AI-based CLI assistant to help you with command line & shell.
|
|
5
|
-
Home-page: https://github.com/FireHead90544/how-cli
|
|
6
|
-
Author: Rudransh Joshi (FireHead90544)
|
|
7
|
-
Author-email: rudranshjoshi1806@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Issue Tracker, https://github.com/FireHead90544/how-cli/issues
|
|
10
|
-
Platform: any
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: typer
|
|
14
|
-
Requires-Dist: langchain
|
|
15
|
-
Requires-Dist: langchain-google-genai
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* `--
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* `--
|
|
77
|
-
* `--
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: how-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: An AI-based CLI assistant to help you with command line & shell.
|
|
5
|
+
Home-page: https://github.com/FireHead90544/how-cli
|
|
6
|
+
Author: Rudransh Joshi (FireHead90544)
|
|
7
|
+
Author-email: rudranshjoshi1806@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/FireHead90544/how-cli/issues
|
|
10
|
+
Platform: any
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: typer
|
|
14
|
+
Requires-Dist: langchain
|
|
15
|
+
Requires-Dist: langchain-google-genai
|
|
16
|
+
Requires-Dist: langchain-google-vertexai
|
|
17
|
+
Requires-Dist: langchain-groq
|
|
18
|
+
Requires-Dist: langchain-openai
|
|
19
|
+
Requires-Dist: langchain-anthropic
|
|
20
|
+
|
|
21
|
+
# how-cli
|
|
22
|
+
An AI-based CLI assistant to help you with command line & shell.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Demo
|
|
26
|
+
https://github.com/user-attachments/assets/effefe1a-c0ed-4b60-838c-98f992f6c25f
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
**1. Using `pip`**
|
|
31
|
+
- Ensure python is installed on your system. (Tested against Python 3.11+)
|
|
32
|
+
- Install the package using pip.
|
|
33
|
+
```bash
|
|
34
|
+
pip install -U how-cli
|
|
35
|
+
```
|
|
36
|
+
**2. Manual Installation**
|
|
37
|
+
- Clone the repository & cd into it
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/FireHead90544/how-cli && cd how-cli
|
|
40
|
+
```
|
|
41
|
+
- Ensure you're in a virtual environment.
|
|
42
|
+
- Install the application.
|
|
43
|
+
```bash
|
|
44
|
+
pip install -e .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
```console
|
|
50
|
+
$ how [OPTIONS] COMMAND [ARGS]...
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Options**:
|
|
54
|
+
* `-v, --version`: Shows the version of the application
|
|
55
|
+
* `--install-completion`: Install completion for the current shell.
|
|
56
|
+
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
|
|
57
|
+
* `--help`: Show this message and exit.
|
|
58
|
+
|
|
59
|
+
**Commands**:
|
|
60
|
+
* `setup`: Sets up the configuration required to run...
|
|
61
|
+
* `to`: Sends the task to the LLM for analysis.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## `how setup`
|
|
65
|
+
Sets up the configuration required to run the application.
|
|
66
|
+
Set the LLM Provider & the corresponding API Key.
|
|
67
|
+
|
|
68
|
+
**Usage**:
|
|
69
|
+
```console
|
|
70
|
+
$ how setup [OPTIONS]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Options**:
|
|
74
|
+
* `--interactive / --no-interactive`: Whether to use interactive mode for setting up configuration? [default: interactive]
|
|
75
|
+
* `--provider TEXT`: The LLM Provider, needs to be passed explicitly if using --no-interactive mode.
|
|
76
|
+
* `--api-key TEXT`: The API Key for the LLM provider, needs to be passed explicitly if using --no-interactive mode.
|
|
77
|
+
* `--help`: Show this message and exit.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## `how to`
|
|
81
|
+
Sends the task to the LLM for analysis.
|
|
82
|
+
Returns the commands to be executed in order to achieve that.
|
|
83
|
+
|
|
84
|
+
**Usage**:
|
|
85
|
+
```console
|
|
86
|
+
$ how to [OPTIONS] TASK
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Arguments**:
|
|
90
|
+
* `TASK`: The command line task to perform. [required]
|
|
91
|
+
|
|
92
|
+
**Options**:
|
|
93
|
+
* `--help`: Show this message and exit.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Providers
|
|
97
|
+
`how-cli` uses ChatModels as they support chat messages as opposed to TextModels and below model providers and their corresponding models are available to use. If you could test the models that are marked as ❌, please create an issue or pull request along with the test results.
|
|
98
|
+
|
|
99
|
+
| Provider | Model | Package | Tested |
|
|
100
|
+
|:--------:|:-----:|:-------:|:------:|
|
|
101
|
+
| GoogleGenAI | `gemini-1.5-flash` | `langchain-google-genai` | ✅ |
|
|
102
|
+
| GoogleVertexAI | `gemini-1.5-flash` | `langchain-google-vertexai` | ❌ |
|
|
103
|
+
| GroqMistralAI | `mixtral-8x7b-32768` | `langchain-groq` | ✅ |
|
|
104
|
+
| GroqLLaMa | `llama3-70b-8192` | `langchain-groq` | ✅ |
|
|
105
|
+
| OpenAI | `gpt-4o` | `langchain-openai` | ❌ |
|
|
106
|
+
| Anthropic | `claude-3-5-sonnet-20240620` | `langchain-anthropic` | ❌ |
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# License
|
|
110
|
+
`how-cil` is licensed under the MIT License, it can be found [here](https://github.com/FireHead90544/how-cli/blob/main/LICENSE).
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# Honourable Mentions
|
|
114
|
+
This project is greatly inspired by [kynnyhsap's](https://github.com/kynnyhsap) [how](https://github.com/kynnyhsap/how). Though my implementation is completely different (refer to the below image for architectural details), but at the core both the projects aims to do the same thing. Also, check out LangChain & Typer using which this project was built.
|
|
115
|
+
|
|
116
|
+

|
|
@@ -1,87 +1,96 @@
|
|
|
1
|
-
# how-cli
|
|
2
|
-
An AI-based CLI assistant to help you with command line & shell.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Demo
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
**
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
|
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
# how-cli
|
|
2
|
+
An AI-based CLI assistant to help you with command line & shell.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Demo
|
|
6
|
+
https://github.com/user-attachments/assets/effefe1a-c0ed-4b60-838c-98f992f6c25f
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
**1. Using `pip`**
|
|
11
|
+
- Ensure python is installed on your system. (Tested against Python 3.11+)
|
|
12
|
+
- Install the package using pip.
|
|
13
|
+
```bash
|
|
14
|
+
pip install -U how-cli
|
|
15
|
+
```
|
|
16
|
+
**2. Manual Installation**
|
|
17
|
+
- Clone the repository & cd into it
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/FireHead90544/how-cli && cd how-cli
|
|
20
|
+
```
|
|
21
|
+
- Ensure you're in a virtual environment.
|
|
22
|
+
- Install the application.
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
```console
|
|
30
|
+
$ how [OPTIONS] COMMAND [ARGS]...
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Options**:
|
|
34
|
+
* `-v, --version`: Shows the version of the application
|
|
35
|
+
* `--install-completion`: Install completion for the current shell.
|
|
36
|
+
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
|
|
37
|
+
* `--help`: Show this message and exit.
|
|
38
|
+
|
|
39
|
+
**Commands**:
|
|
40
|
+
* `setup`: Sets up the configuration required to run...
|
|
41
|
+
* `to`: Sends the task to the LLM for analysis.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## `how setup`
|
|
45
|
+
Sets up the configuration required to run the application.
|
|
46
|
+
Set the LLM Provider & the corresponding API Key.
|
|
47
|
+
|
|
48
|
+
**Usage**:
|
|
49
|
+
```console
|
|
50
|
+
$ how setup [OPTIONS]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Options**:
|
|
54
|
+
* `--interactive / --no-interactive`: Whether to use interactive mode for setting up configuration? [default: interactive]
|
|
55
|
+
* `--provider TEXT`: The LLM Provider, needs to be passed explicitly if using --no-interactive mode.
|
|
56
|
+
* `--api-key TEXT`: The API Key for the LLM provider, needs to be passed explicitly if using --no-interactive mode.
|
|
57
|
+
* `--help`: Show this message and exit.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## `how to`
|
|
61
|
+
Sends the task to the LLM for analysis.
|
|
62
|
+
Returns the commands to be executed in order to achieve that.
|
|
63
|
+
|
|
64
|
+
**Usage**:
|
|
65
|
+
```console
|
|
66
|
+
$ how to [OPTIONS] TASK
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Arguments**:
|
|
70
|
+
* `TASK`: The command line task to perform. [required]
|
|
71
|
+
|
|
72
|
+
**Options**:
|
|
73
|
+
* `--help`: Show this message and exit.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Providers
|
|
77
|
+
`how-cli` uses ChatModels as they support chat messages as opposed to TextModels and below model providers and their corresponding models are available to use. If you could test the models that are marked as ❌, please create an issue or pull request along with the test results.
|
|
78
|
+
|
|
79
|
+
| Provider | Model | Package | Tested |
|
|
80
|
+
|:--------:|:-----:|:-------:|:------:|
|
|
81
|
+
| GoogleGenAI | `gemini-1.5-flash` | `langchain-google-genai` | ✅ |
|
|
82
|
+
| GoogleVertexAI | `gemini-1.5-flash` | `langchain-google-vertexai` | ❌ |
|
|
83
|
+
| GroqMistralAI | `mixtral-8x7b-32768` | `langchain-groq` | ✅ |
|
|
84
|
+
| GroqLLaMa | `llama3-70b-8192` | `langchain-groq` | ✅ |
|
|
85
|
+
| OpenAI | `gpt-4o` | `langchain-openai` | ❌ |
|
|
86
|
+
| Anthropic | `claude-3-5-sonnet-20240620` | `langchain-anthropic` | ❌ |
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# License
|
|
90
|
+
`how-cil` is licensed under the MIT License, it can be found [here](https://github.com/FireHead90544/how-cli/blob/main/LICENSE).
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# Honourable Mentions
|
|
94
|
+
This project is greatly inspired by [kynnyhsap's](https://github.com/kynnyhsap) [how](https://github.com/kynnyhsap/how). Though my implementation is completely different (refer to the below image for architectural details), but at the core both the projects aims to do the same thing. Also, check out LangChain & Typer using which this project was built.
|
|
95
|
+
|
|
96
|
+

|
|
@@ -1 +1 @@
|
|
|
1
|
-
from how.core import __version__, __author__
|
|
1
|
+
from how.core import __version__, __author__
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from how.how import app
|
|
2
|
-
|
|
3
|
-
if __name__ == "__main__":
|
|
4
|
-
app()
|
|
1
|
+
from how.how import app
|
|
2
|
+
|
|
3
|
+
if __name__ == "__main__":
|
|
4
|
+
app()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from how.core.template import PROMPT_TEMPLATE
|
|
2
|
-
from how.core.llm import LLM
|
|
3
|
-
|
|
1
|
+
from how.core.template import PROMPT_TEMPLATE
|
|
2
|
+
from how.core.llm import LLM
|
|
3
|
+
|
|
4
4
|
HOW_CLI_CHAIN = PROMPT_TEMPLATE | LLM
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
class Config:
|
|
5
|
-
"""
|
|
6
|
-
Manages the configuration of the application.
|
|
7
|
-
Config file is stored in the user's home directory.
|
|
8
|
-
"""
|
|
9
|
-
def __init__(self):
|
|
10
|
-
self.config_dir = Path.home() / ".how"
|
|
11
|
-
self.config_file = self.config_dir / "config.json"
|
|
12
|
-
self.__init_config()
|
|
13
|
-
|
|
14
|
-
def __init_config(self):
|
|
15
|
-
"""
|
|
16
|
-
Initialize the configuration directory & file if they don't exist.
|
|
17
|
-
"""
|
|
18
|
-
if not self.config_dir.exists():
|
|
19
|
-
self.config_dir.mkdir()
|
|
20
|
-
|
|
21
|
-
if not self.config_file.exists():
|
|
22
|
-
with open(self.config_file, "w") as f:
|
|
23
|
-
json.dump({"provider": "", "api_key": ""}, f, indent=4)
|
|
24
|
-
|
|
25
|
-
def setup(self, provider: str, api_key: str):
|
|
26
|
-
"""
|
|
27
|
-
Set the LLM Provider & the corresponding API Key.
|
|
28
|
-
"""
|
|
29
|
-
with open(self.config_file, "w") as f:
|
|
30
|
-
json.dump({"provider": provider, "api_key": api_key}, f, indent=4)
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def values(self):
|
|
34
|
-
"""
|
|
35
|
-
Get the configuration values.
|
|
36
|
-
"""
|
|
37
|
-
with open(self.config_file) as f:
|
|
38
|
-
return json.load(f)
|
|
39
|
-
|
|
40
|
-
def is_ready(self):
|
|
41
|
-
"""
|
|
42
|
-
Check if the configuration file is ready to use.
|
|
43
|
-
"""
|
|
44
|
-
try:
|
|
45
|
-
assert self.values.get("provider")
|
|
46
|
-
assert self.values.get("api_key")
|
|
47
|
-
except:
|
|
48
|
-
return False
|
|
49
|
-
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
class Config:
|
|
5
|
+
"""
|
|
6
|
+
Manages the configuration of the application.
|
|
7
|
+
Config file is stored in the user's home directory.
|
|
8
|
+
"""
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.config_dir = Path.home() / ".how"
|
|
11
|
+
self.config_file = self.config_dir / "config.json"
|
|
12
|
+
self.__init_config()
|
|
13
|
+
|
|
14
|
+
def __init_config(self):
|
|
15
|
+
"""
|
|
16
|
+
Initialize the configuration directory & file if they don't exist.
|
|
17
|
+
"""
|
|
18
|
+
if not self.config_dir.exists():
|
|
19
|
+
self.config_dir.mkdir()
|
|
20
|
+
|
|
21
|
+
if not self.config_file.exists():
|
|
22
|
+
with open(self.config_file, "w") as f:
|
|
23
|
+
json.dump({"provider": "", "api_key": ""}, f, indent=4)
|
|
24
|
+
|
|
25
|
+
def setup(self, provider: str, api_key: str):
|
|
26
|
+
"""
|
|
27
|
+
Set the LLM Provider & the corresponding API Key.
|
|
28
|
+
"""
|
|
29
|
+
with open(self.config_file, "w") as f:
|
|
30
|
+
json.dump({"provider": provider, "api_key": api_key}, f, indent=4)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def values(self):
|
|
34
|
+
"""
|
|
35
|
+
Get the configuration values.
|
|
36
|
+
"""
|
|
37
|
+
with open(self.config_file) as f:
|
|
38
|
+
return json.load(f)
|
|
39
|
+
|
|
40
|
+
def is_ready(self):
|
|
41
|
+
"""
|
|
42
|
+
Check if the configuration file is ready to use.
|
|
43
|
+
"""
|
|
44
|
+
try:
|
|
45
|
+
assert self.values.get("provider")
|
|
46
|
+
assert self.values.get("api_key")
|
|
47
|
+
except:
|
|
48
|
+
return False
|
|
49
|
+
|
|
50
50
|
return True
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from how.core.config import Config
|
|
2
|
-
from how.core.providers import LLM_PROVIDERS
|
|
3
|
-
|
|
4
|
-
llm_config = Config().values
|
|
5
|
-
|
|
6
|
-
LLM = LLM_PROVIDERS.get(llm_config.get("provider"))['provider'](
|
|
7
|
-
model = LLM_PROVIDERS.get(llm_config.get("provider"))['model'],
|
|
8
|
-
api_key = llm_config.get("api_key")
|
|
1
|
+
from how.core.config import Config
|
|
2
|
+
from how.core.providers import LLM_PROVIDERS
|
|
3
|
+
|
|
4
|
+
llm_config = Config().values
|
|
5
|
+
|
|
6
|
+
LLM = LLM_PROVIDERS.get(llm_config.get("provider"))['provider'](
|
|
7
|
+
model = LLM_PROVIDERS.get(llm_config.get("provider"))['model'],
|
|
8
|
+
api_key = llm_config.get("api_key")
|
|
9
9
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from how.core.schema import Result
|
|
2
|
-
from langchain_core.output_parsers import JsonOutputParser
|
|
3
|
-
|
|
1
|
+
from how.core.schema import Result
|
|
2
|
+
from langchain_core.output_parsers import JsonOutputParser
|
|
3
|
+
|
|
4
4
|
PARSER = JsonOutputParser(pydantic_object=Result)
|