janito 2.8.0__py3-none-any.whl → 2.10.0__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.
- janito/README.md +149 -0
- janito/cli/chat_mode/script_runner.py +2 -2
- janito/cli/chat_mode/session.py +24 -6
- janito/cli/chat_mode/shell/commands/_priv_status.py +13 -0
- janito/cli/cli_commands/list_config.py +31 -0
- janito/cli/cli_commands/list_profiles.py +79 -0
- janito/cli/cli_commands/show_config.py +4 -11
- janito/cli/core/getters.py +14 -1
- janito/cli/main_cli.py +52 -3
- janito/config.py +1 -0
- janito/config_manager.py +11 -2
- janito/docs/GETTING_STARTED.md +117 -0
- janito/docs/PROVIDERS.md +224 -0
- janito/drivers/azure_openai/driver.py +7 -0
- janito/drivers/openai/driver.py +10 -2
- janito/llm/provider.py +1 -1
- janito/mkdocs.yml +40 -0
- janito/provider_registry.py +14 -4
- janito/providers/__init__.py +1 -1
- janito/providers/alibaba/__init__.py +0 -0
- janito/providers/alibaba/model_info.py +33 -0
- janito/providers/alibaba/provider.py +102 -0
- janito/providers/anthropic/provider.py +6 -0
- janito/providers/azure_openai/provider.py +8 -2
- janito/providers/deepseek/provider.py +7 -1
- janito/providers/google/provider.py +7 -1
- janito/providers/moonshotai/model_info.py +11 -0
- janito/providers/moonshotai/provider.py +8 -2
- janito/providers/openai/provider.py +7 -1
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/METADATA +8 -8
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/RECORD +35 -28
- janito/providers/groq/__init__.py +0 -1
- janito/providers/groq/model_info.py +0 -46
- janito/providers/groq/provider.py +0 -76
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/WHEEL +0 -0
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/entry_points.txt +0 -0
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/licenses/LICENSE +0 -0
- {janito-2.8.0.dist-info → janito-2.10.0.dist-info}/top_level.txt +0 -0
janito/README.md
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# Janito CLI
|
2
|
+
|
3
|
+
A powerful command-line tool for running LLM-powered workflows with built-in tool execution capabilities.
|
4
|
+
|
5
|
+
## Quick Start
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
|
9
|
+
```bash
|
10
|
+
pip install janito
|
11
|
+
```
|
12
|
+
|
13
|
+
### First-Time Setup
|
14
|
+
|
15
|
+
1. **Get your API key**: Sign up at [Moonshot AI](https://platform.moonshot.cn/) and get your API key
|
16
|
+
2. **Set your API key**:
|
17
|
+
```bash
|
18
|
+
janito --set-api-key YOUR_MOONSHOT_API_KEY -p moonshotai
|
19
|
+
```
|
20
|
+
|
21
|
+
### Basic Usage
|
22
|
+
|
23
|
+
**MoonshotAI (Recommended - Default Provider)**
|
24
|
+
```bash
|
25
|
+
# Using the default provider (moonshotai) and model
|
26
|
+
janito "Create a Python script that reads a CSV file"
|
27
|
+
|
28
|
+
# Using a specific MoonshotAI model
|
29
|
+
janito -m kimi-k1-8k "Explain quantum computing"
|
30
|
+
```
|
31
|
+
|
32
|
+
**Other Providers**
|
33
|
+
```bash
|
34
|
+
# OpenAI
|
35
|
+
janito -p openai -m gpt-4 "Write a React component"
|
36
|
+
|
37
|
+
# Anthropic
|
38
|
+
janito -p anthropic -m claude-3-5-sonnet-20241022 "Analyze this code"
|
39
|
+
|
40
|
+
# Google
|
41
|
+
janito -p google -m gemini-2.0-flash-exp "Generate unit tests"
|
42
|
+
```
|
43
|
+
|
44
|
+
### Interactive Chat Mode
|
45
|
+
|
46
|
+
Start an interactive session:
|
47
|
+
```bash
|
48
|
+
janito --chat
|
49
|
+
```
|
50
|
+
|
51
|
+
In chat mode, you can:
|
52
|
+
|
53
|
+
- Have multi-turn conversations
|
54
|
+
- Execute code and commands
|
55
|
+
- Read and write files
|
56
|
+
- Use built-in tools
|
57
|
+
|
58
|
+
### Available Commands
|
59
|
+
|
60
|
+
- `janito --list-providers` - List all supported providers
|
61
|
+
- `janito --list-models` - List all available models
|
62
|
+
- `janito --list-tools` - List available tools
|
63
|
+
- `janito --show-config` - Show current configuration
|
64
|
+
|
65
|
+
### Configuration
|
66
|
+
|
67
|
+
Set default provider and model:
|
68
|
+
```bash
|
69
|
+
janito --set provider=moonshotai
|
70
|
+
janito --set model=kimi-k1-8k
|
71
|
+
```
|
72
|
+
|
73
|
+
## Providers
|
74
|
+
|
75
|
+
### MoonshotAI (Recommended)
|
76
|
+
|
77
|
+
- **Models**: kimi-k1-8k, kimi-k1-32k, kimi-k1-128k, kimi-k2-turbo-preview
|
78
|
+
- **Strengths**: Excellent Chinese/English support, competitive pricing, fast responses
|
79
|
+
- **Setup**: Get API key from [Moonshot AI Platform](https://platform.moonshot.cn/)
|
80
|
+
|
81
|
+
### OpenAI
|
82
|
+
|
83
|
+
- **Models**: gpt-4, gpt-4-turbo, gpt-3.5-turbo
|
84
|
+
- **Setup**: Get API key from [OpenAI Platform](https://platform.openai.com/)
|
85
|
+
|
86
|
+
### Anthropic
|
87
|
+
|
88
|
+
- **Models**: claude-3-5-sonnet-20241022, claude-3-opus-20240229
|
89
|
+
- **Setup**: Get API key from [Anthropic Console](https://console.anthropic.com/)
|
90
|
+
|
91
|
+
### Google
|
92
|
+
|
93
|
+
- **Models**: gemini-2.0-flash-exp, gemini-1.5-pro
|
94
|
+
- **Setup**: Get API key from [Google AI Studio](https://makersuite.google.com/)
|
95
|
+
|
96
|
+
## Advanced Features
|
97
|
+
|
98
|
+
### Tool Usage
|
99
|
+
|
100
|
+
Janito includes powerful built-in tools for:
|
101
|
+
|
102
|
+
- File operations (read, write, search)
|
103
|
+
- Code execution
|
104
|
+
- Web scraping
|
105
|
+
- System commands
|
106
|
+
- And more...
|
107
|
+
|
108
|
+
### Profiles and Roles
|
109
|
+
Use predefined system prompts:
|
110
|
+
```bash
|
111
|
+
janito --profile developer "Create a REST API"
|
112
|
+
janito --role python-expert "Optimize this algorithm"
|
113
|
+
```
|
114
|
+
|
115
|
+
### Environment Variables
|
116
|
+
You can also configure via environment variables:
|
117
|
+
```bash
|
118
|
+
export MOONSHOTAI_API_KEY=your_key_here
|
119
|
+
export JANITO_PROVIDER=moonshotai
|
120
|
+
export JANITO_MODEL=kimi-k1-8k
|
121
|
+
```
|
122
|
+
|
123
|
+
## Examples
|
124
|
+
|
125
|
+
### Code Generation
|
126
|
+
```bash
|
127
|
+
janito "Create a Python FastAPI application with user authentication"
|
128
|
+
```
|
129
|
+
|
130
|
+
### File Analysis
|
131
|
+
```bash
|
132
|
+
janito "Analyze the performance bottlenecks in my_app.py"
|
133
|
+
```
|
134
|
+
|
135
|
+
### Data Processing
|
136
|
+
```bash
|
137
|
+
janito "Process this CSV file and generate summary statistics"
|
138
|
+
```
|
139
|
+
|
140
|
+
### Web Development
|
141
|
+
```bash
|
142
|
+
janito "Create a responsive landing page with Tailwind CSS"
|
143
|
+
```
|
144
|
+
|
145
|
+
## Support
|
146
|
+
|
147
|
+
- **Documentation**: Check individual provider directories for detailed setup guides
|
148
|
+
- **Issues**: Report bugs and feature requests on GitHub
|
149
|
+
- **Discord**: Join our community for help and discussions
|
@@ -52,8 +52,8 @@ class ChatScriptRunner:
|
|
52
52
|
inputs: List[str],
|
53
53
|
*,
|
54
54
|
console: Optional[Console] = None,
|
55
|
-
provider: str = "
|
56
|
-
model: str = "
|
55
|
+
provider: str = "moonshotai",
|
56
|
+
model: str = "kimi-k1-8k",
|
57
57
|
use_real_agent: bool = True,
|
58
58
|
**chat_session_kwargs,
|
59
59
|
) -> None:
|
janito/cli/chat_mode/session.py
CHANGED
@@ -72,11 +72,13 @@ class ChatSession:
|
|
72
72
|
self.provider_instance = provider_instance
|
73
73
|
self.llm_driver_config = llm_driver_config
|
74
74
|
|
75
|
-
profile, role, profile_system_prompt, no_tools_mode =
|
75
|
+
profile, role, profile_system_prompt, no_tools_mode = (
|
76
|
+
self._select_profile_and_role(args, role)
|
77
|
+
)
|
76
78
|
# Propagate no_tools_mode flag to downstream components via args
|
77
|
-
if args is not None and not hasattr(args,
|
79
|
+
if args is not None and not hasattr(args, "no_tools_mode"):
|
78
80
|
try:
|
79
|
-
setattr(args,
|
81
|
+
setattr(args, "no_tools_mode", no_tools_mode)
|
80
82
|
except Exception:
|
81
83
|
pass
|
82
84
|
conversation_history = self._create_conversation_history()
|
@@ -126,7 +128,9 @@ class ChatSession:
|
|
126
128
|
profile = "Developer with Python Tools"
|
127
129
|
else:
|
128
130
|
profile = (
|
129
|
-
"Developer with Python Tools"
|
131
|
+
"Developer with Python Tools"
|
132
|
+
if result == "Developer"
|
133
|
+
else result
|
130
134
|
)
|
131
135
|
except ImportError:
|
132
136
|
profile = "Raw Model Session (no tools, no context)"
|
@@ -200,13 +204,27 @@ class ChatSession:
|
|
200
204
|
cwd_display = "~" + cwd[len(home) :]
|
201
205
|
else:
|
202
206
|
cwd_display = cwd
|
203
|
-
|
207
|
+
from janito.cli.chat_mode.shell.commands._priv_status import (
|
208
|
+
get_privilege_status_message,
|
209
|
+
)
|
210
|
+
|
211
|
+
priv_status = get_privilege_status_message()
|
212
|
+
self.console.print(
|
213
|
+
f"[green]Working Dir:[/green] {cwd_display} | {priv_status}"
|
214
|
+
)
|
204
215
|
|
205
216
|
from janito.cli.chat_mode.shell.commands._priv_check import (
|
206
217
|
user_has_any_privileges,
|
207
218
|
)
|
208
219
|
|
209
|
-
|
220
|
+
perms = __import__(
|
221
|
+
"janito.tools.permissions", fromlist=["get_global_allowed_permissions"]
|
222
|
+
).get_global_allowed_permissions()
|
223
|
+
if perms.execute:
|
224
|
+
self.console.print(
|
225
|
+
"[bold red]Commands/Code execution is enabled - Be cautious[/bold red]"
|
226
|
+
)
|
227
|
+
if not (perms.read or perms.write or perms.execute):
|
210
228
|
self.console.print(
|
211
229
|
"[yellow]Note: You currently have no privileges enabled. If you need to interact with files or the system, enable permissions using /read on, /write on, or /execute on.[/yellow]"
|
212
230
|
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from janito.tools.permissions import get_global_allowed_permissions
|
2
|
+
|
3
|
+
|
4
|
+
def get_privilege_status_message():
|
5
|
+
perms = get_global_allowed_permissions()
|
6
|
+
if perms.read and perms.write:
|
7
|
+
return "[cyan]Read-Write tools enabled[/cyan]"
|
8
|
+
elif perms.read:
|
9
|
+
return "[cyan]Read-Only tools enabled[/cyan]"
|
10
|
+
elif perms.write:
|
11
|
+
return "[cyan]Write-Only tools enabled[/cyan]"
|
12
|
+
else:
|
13
|
+
return "[yellow]No tool permissions enabled[/yellow]"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from rich.console import Console
|
2
|
+
from pathlib import Path
|
3
|
+
import os
|
4
|
+
|
5
|
+
|
6
|
+
def handle_list_config(args=None):
|
7
|
+
console = Console()
|
8
|
+
home = Path.home()
|
9
|
+
default_config = home / ".janito" / "config.json"
|
10
|
+
custom_dir = home / ".janito" / "configs"
|
11
|
+
console.print("[bold green]Janito configuration files:[/bold green]")
|
12
|
+
if default_config.exists():
|
13
|
+
console.print(f"[bold yellow]Default config:[/bold yellow] {default_config}")
|
14
|
+
else:
|
15
|
+
console.print(
|
16
|
+
f"[bold yellow]Default config:[/bold yellow] {default_config} [red](not found)"
|
17
|
+
)
|
18
|
+
if custom_dir.exists() and custom_dir.is_dir():
|
19
|
+
files = sorted(
|
20
|
+
f for f in custom_dir.iterdir() if f.is_file() and f.suffix == ".json"
|
21
|
+
)
|
22
|
+
if files:
|
23
|
+
console.print("[bold yellow]Custom configs:[/bold yellow]")
|
24
|
+
for f in files:
|
25
|
+
console.print(f" - {f}")
|
26
|
+
else:
|
27
|
+
console.print("[bold yellow]Custom configs:[/bold yellow] (none found)")
|
28
|
+
else:
|
29
|
+
console.print(
|
30
|
+
f"[bold yellow]Custom configs:[/bold yellow] {custom_dir} [red](directory not found)"
|
31
|
+
)
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"""
|
2
|
+
CLI Command: List available system prompt profiles (default and user-specific)
|
3
|
+
"""
|
4
|
+
|
5
|
+
from pathlib import Path
|
6
|
+
import importlib.resources as resources
|
7
|
+
from rich.console import Console
|
8
|
+
from rich.table import Table
|
9
|
+
|
10
|
+
|
11
|
+
_PREFIX = "system_prompt_template_"
|
12
|
+
_SUFFIX = ".txt.j2"
|
13
|
+
|
14
|
+
|
15
|
+
def _extract_profile_name(filename: str) -> str:
|
16
|
+
"""Return the human-readable profile name from template file name."""
|
17
|
+
# Remove prefix & suffix and convert underscores back to spaces
|
18
|
+
if filename.startswith(_PREFIX):
|
19
|
+
filename = filename[len(_PREFIX) :]
|
20
|
+
if filename.endswith(_SUFFIX):
|
21
|
+
filename = filename[: -len(_SUFFIX)]
|
22
|
+
return filename.replace("_", " ")
|
23
|
+
|
24
|
+
|
25
|
+
def _gather_default_profiles():
|
26
|
+
"""Return list of built-in profile names bundled with janito."""
|
27
|
+
profiles = []
|
28
|
+
try:
|
29
|
+
package_files = resources.files("janito.agent.templates.profiles")
|
30
|
+
for path in package_files.iterdir():
|
31
|
+
name = path.name
|
32
|
+
if name.startswith(_PREFIX) and name.endswith(_SUFFIX):
|
33
|
+
profiles.append(_extract_profile_name(name))
|
34
|
+
except Exception:
|
35
|
+
# If for some reason the resources are not available fall back to empty list
|
36
|
+
pass
|
37
|
+
return sorted(profiles, key=str.lower)
|
38
|
+
|
39
|
+
|
40
|
+
def _gather_user_profiles():
|
41
|
+
"""Return list of user-defined profile names from ~/.janito/profiles directory."""
|
42
|
+
user_dir = Path.home() / ".janito" / "profiles"
|
43
|
+
profiles = []
|
44
|
+
if user_dir.exists() and user_dir.is_dir():
|
45
|
+
for path in user_dir.iterdir():
|
46
|
+
if (
|
47
|
+
path.is_file()
|
48
|
+
and path.name.startswith(_PREFIX)
|
49
|
+
and path.name.endswith(_SUFFIX)
|
50
|
+
):
|
51
|
+
profiles.append(_extract_profile_name(path.name))
|
52
|
+
return sorted(profiles, key=str.lower)
|
53
|
+
|
54
|
+
|
55
|
+
def _print_profiles_table(default_profiles, user_profiles):
|
56
|
+
console = Console()
|
57
|
+
table = Table(title="Available System Prompt Profiles", box=None, show_lines=False)
|
58
|
+
table.add_column("Profile Name", style="cyan", no_wrap=False)
|
59
|
+
table.add_column("Source", style="magenta", no_wrap=True)
|
60
|
+
|
61
|
+
for p in default_profiles:
|
62
|
+
table.add_row(p, "default")
|
63
|
+
for p in user_profiles:
|
64
|
+
table.add_row(p, "user")
|
65
|
+
|
66
|
+
console.print(table)
|
67
|
+
|
68
|
+
|
69
|
+
def handle_list_profiles(args=None):
|
70
|
+
"""Entry point for the --list-profiles CLI flag."""
|
71
|
+
default_profiles = _gather_default_profiles()
|
72
|
+
user_profiles = _gather_user_profiles()
|
73
|
+
|
74
|
+
if not default_profiles and not user_profiles:
|
75
|
+
print("No profiles found.")
|
76
|
+
return
|
77
|
+
|
78
|
+
_print_profiles_table(default_profiles, user_profiles)
|
79
|
+
return
|
@@ -34,21 +34,14 @@ def handle_show_config(args):
|
|
34
34
|
provider_names = ProviderRegistry()._get_provider_names()
|
35
35
|
except Exception:
|
36
36
|
pass
|
37
|
+
from janito.provider_config import get_config_path
|
38
|
+
|
39
|
+
config_path = get_config_path()
|
37
40
|
console.print("[bold green]Current configuration:[/bold green]")
|
41
|
+
console.print(f"[bold yellow]Config file:[/bold yellow] {config_path}")
|
38
42
|
console.print(f"[bold yellow]Current provider:[/bold yellow] {provider!r}\n")
|
39
43
|
if model is not None:
|
40
44
|
console.print(f"[bold yellow]Global model:[/bold yellow] {model!r}\n")
|
41
|
-
if provider_names:
|
42
|
-
console.print("[bold cyan]Provider specific default models:[/bold cyan]")
|
43
|
-
for pname in provider_names:
|
44
|
-
eff_model = resolve_effective_model(pname)
|
45
|
-
prov_cfg = config.get_provider_config(pname)
|
46
|
-
prov_model = prov_cfg.get("model") if prov_cfg else None
|
47
|
-
extra = f" (override)" if prov_model else ""
|
48
|
-
sel = "[default]" if pname == provider else ""
|
49
|
-
console.print(
|
50
|
-
f" [bold]{pname}[/bold]{' '+sel if sel else ''}: model = [magenta]{eff_model}[/magenta]{extra}"
|
51
|
-
)
|
52
45
|
|
53
46
|
# Show disabled tools
|
54
47
|
from janito.tools.disabled_tools import load_disabled_tools_from_config
|
janito/cli/core/getters.py
CHANGED
@@ -6,10 +6,18 @@ from janito.cli.cli_commands.list_providers import handle_list_providers
|
|
6
6
|
from janito.cli.cli_commands.list_models import handle_list_models
|
7
7
|
from janito.cli.cli_commands.list_tools import handle_list_tools
|
8
8
|
from janito.cli.cli_commands.show_config import handle_show_config
|
9
|
+
from janito.cli.cli_commands.list_config import handle_list_config
|
9
10
|
from functools import partial
|
10
11
|
from janito.provider_registry import ProviderRegistry
|
11
12
|
|
12
|
-
GETTER_KEYS = [
|
13
|
+
GETTER_KEYS = [
|
14
|
+
"show_config",
|
15
|
+
"list_providers",
|
16
|
+
"list_profiles",
|
17
|
+
"list_models",
|
18
|
+
"list_tools",
|
19
|
+
"list_config",
|
20
|
+
]
|
13
21
|
|
14
22
|
|
15
23
|
def handle_getter(args, config_mgr=None):
|
@@ -24,11 +32,16 @@ def handle_getter(args, config_mgr=None):
|
|
24
32
|
)
|
25
33
|
sys.exit(1)
|
26
34
|
provider_instance = ProviderRegistry().get_instance(provider)
|
35
|
+
# Lazy import to avoid overhead unless needed
|
36
|
+
from janito.cli.cli_commands.list_profiles import handle_list_profiles
|
37
|
+
|
27
38
|
GETTER_DISPATCH = {
|
28
39
|
"list_providers": partial(handle_list_providers, args),
|
29
40
|
"list_models": partial(handle_list_models, args, provider_instance),
|
30
41
|
"list_tools": partial(handle_list_tools, args),
|
42
|
+
"list_profiles": partial(handle_list_profiles, args),
|
31
43
|
"show_config": partial(handle_show_config, args),
|
44
|
+
"list_config": partial(handle_list_config, args),
|
32
45
|
}
|
33
46
|
for arg in GETTER_KEYS:
|
34
47
|
if getattr(args, arg, False) and arg in GETTER_DISPATCH:
|
janito/cli/main_cli.py
CHANGED
@@ -98,6 +98,14 @@ definition = [
|
|
98
98
|
(["--version"], {"action": "version", "version": None}),
|
99
99
|
(["--list-tools"], {"action": "store_true", "help": "List all registered tools"}),
|
100
100
|
(["--show-config"], {"action": "store_true", "help": "Show the current config"}),
|
101
|
+
(
|
102
|
+
["--list-config"],
|
103
|
+
{"action": "store_true", "help": "List all configuration files"},
|
104
|
+
),
|
105
|
+
(
|
106
|
+
["--list-profiles"],
|
107
|
+
{"action": "store_true", "help": "List available system prompt profiles"},
|
108
|
+
),
|
101
109
|
(
|
102
110
|
["--list-providers"],
|
103
111
|
{"action": "store_true", "help": "List supported LLM providers"},
|
@@ -159,6 +167,13 @@ definition = [
|
|
159
167
|
"help": "Print debug info on event subscribe/submit methods",
|
160
168
|
},
|
161
169
|
),
|
170
|
+
(
|
171
|
+
["-c", "--config"],
|
172
|
+
{
|
173
|
+
"metavar": "NAME",
|
174
|
+
"help": "Use custom configuration file ~/.janito/configs/NAME.json instead of default config.json",
|
175
|
+
},
|
176
|
+
),
|
162
177
|
]
|
163
178
|
|
164
179
|
MODIFIER_KEYS = [
|
@@ -177,7 +192,14 @@ MODIFIER_KEYS = [
|
|
177
192
|
"write",
|
178
193
|
]
|
179
194
|
SETTER_KEYS = ["set", "set_provider", "set_api_key", "unset"]
|
180
|
-
GETTER_KEYS = [
|
195
|
+
GETTER_KEYS = [
|
196
|
+
"show_config",
|
197
|
+
"list_providers",
|
198
|
+
"list_profiles",
|
199
|
+
"list_models",
|
200
|
+
"list_tools",
|
201
|
+
"list_config",
|
202
|
+
]
|
181
203
|
|
182
204
|
|
183
205
|
class RunMode(enum.Enum):
|
@@ -192,12 +214,35 @@ class JanitoCLI:
|
|
192
214
|
|
193
215
|
self.parser = argparse.ArgumentParser(
|
194
216
|
description="Janito CLI - A tool for running LLM-powered workflows from the command line."
|
195
|
-
"\n\nExample usage: janito -p
|
217
|
+
"\n\nExample usage: janito -p moonshotai -m kimi-k1-8k 'Your prompt here'\n\n"
|
196
218
|
"Use -m or --model to set the model for the session."
|
197
219
|
)
|
198
220
|
self._define_args()
|
199
221
|
self.args = self.parser.parse_args()
|
200
222
|
self._set_all_arg_defaults()
|
223
|
+
# Support custom config file via -c/--config
|
224
|
+
if getattr(self.args, "config", None):
|
225
|
+
from janito import config as global_config
|
226
|
+
from janito.config_manager import ConfigManager
|
227
|
+
import sys
|
228
|
+
import importlib
|
229
|
+
|
230
|
+
config_name = self.args.config
|
231
|
+
# Re-initialize the global config singleton
|
232
|
+
new_config = ConfigManager(config_name=config_name)
|
233
|
+
# Ensure the config path is updated when the singleton already existed
|
234
|
+
from pathlib import Path
|
235
|
+
|
236
|
+
new_config.config_path = (
|
237
|
+
Path.home() / ".janito" / "configs" / f"{config_name}.json"
|
238
|
+
)
|
239
|
+
# Reload config from the selected file
|
240
|
+
new_config._load_file_config()
|
241
|
+
# Patch the global singleton reference
|
242
|
+
import janito.config as config_module
|
243
|
+
|
244
|
+
config_module.config = new_config
|
245
|
+
sys.modules["janito.config"].config = new_config
|
201
246
|
# Support reading prompt from stdin if no user_prompt is given
|
202
247
|
import sys
|
203
248
|
|
@@ -271,7 +316,11 @@ class JanitoCLI:
|
|
271
316
|
return
|
272
317
|
# Special handling: provider is not required for list_providers, list_tools, show_config
|
273
318
|
if run_mode == RunMode.GET and (
|
274
|
-
self.args.list_providers
|
319
|
+
self.args.list_providers
|
320
|
+
or self.args.list_tools
|
321
|
+
or self.args.list_profiles
|
322
|
+
or self.args.show_config
|
323
|
+
or self.args.list_config
|
275
324
|
):
|
276
325
|
self._maybe_print_verbose_provider_model()
|
277
326
|
handle_getter(self.args)
|
janito/config.py
CHANGED
@@ -2,4 +2,5 @@
|
|
2
2
|
from janito.config_manager import ConfigManager
|
3
3
|
|
4
4
|
# Only one global instance! Used by CLI, provider_config, others:
|
5
|
+
# If you want to use a custom config, re-initialize this singleton with config_name or config_path before use.
|
5
6
|
config = ConfigManager(config_path=None)
|
janito/config_manager.py
CHANGED
@@ -20,13 +20,22 @@ class ConfigManager:
|
|
20
20
|
cls._instance = super(ConfigManager, cls).__new__(cls)
|
21
21
|
return cls._instance
|
22
22
|
|
23
|
-
def __init__(
|
23
|
+
def __init__(
|
24
|
+
self, config_path=None, defaults=None, runtime_overrides=None, config_name=None
|
25
|
+
):
|
24
26
|
# Lazy single-init
|
25
27
|
if hasattr(self, "_initialized") and self._initialized:
|
26
28
|
return
|
27
29
|
self._initialized = True
|
28
30
|
|
29
|
-
|
31
|
+
if config_name:
|
32
|
+
self.config_path = (
|
33
|
+
Path.home() / ".janito" / "configs" / f"{config_name}.json"
|
34
|
+
)
|
35
|
+
else:
|
36
|
+
self.config_path = Path(
|
37
|
+
config_path or Path.home() / ".janito" / "config.json"
|
38
|
+
)
|
30
39
|
self.defaults = dict(defaults) if defaults else {}
|
31
40
|
self.file_config = {}
|
32
41
|
self.runtime_overrides = dict(runtime_overrides) if runtime_overrides else {}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Getting Started with Janito
|
2
|
+
|
3
|
+
This guide will help you set up Janito CLI quickly and start using it with MoonshotAI as your default provider.
|
4
|
+
|
5
|
+
## Quick Setup (2 minutes)
|
6
|
+
|
7
|
+
### 1. Install Janito
|
8
|
+
```bash
|
9
|
+
pip install janito
|
10
|
+
```
|
11
|
+
|
12
|
+
### 2. Get Your MoonshotAI API Key
|
13
|
+
|
14
|
+
1. Go to [Moonshot AI Platform](https://platform.moonshot.cn/)
|
15
|
+
2. Sign up for an account
|
16
|
+
3. Navigate to API Keys section
|
17
|
+
4. Create a new API key
|
18
|
+
|
19
|
+
### 3. Configure Janito
|
20
|
+
```bash
|
21
|
+
# Set MoonshotAI as your default provider
|
22
|
+
janito --set-api-key YOUR_API_KEY -p moonshotai
|
23
|
+
|
24
|
+
# Verify it's working
|
25
|
+
janito "Hello, can you introduce yourself?"
|
26
|
+
```
|
27
|
+
|
28
|
+
## Your First Commands
|
29
|
+
|
30
|
+
### Basic Usage
|
31
|
+
```bash
|
32
|
+
# Simple prompt
|
33
|
+
janito "Create a Python script to calculate fibonacci numbers"
|
34
|
+
|
35
|
+
# With specific model
|
36
|
+
janito -m kimi-k1-8k "Explain machine learning in simple terms"
|
37
|
+
|
38
|
+
# Interactive chat mode
|
39
|
+
janito --chat
|
40
|
+
```
|
41
|
+
|
42
|
+
### Working with Files
|
43
|
+
```bash
|
44
|
+
# Analyze a file
|
45
|
+
janito "Analyze the performance of my_app.py" < my_app.py
|
46
|
+
|
47
|
+
# Generate code in a specific directory
|
48
|
+
janito -W ./my_project "Create a REST API with FastAPI"
|
49
|
+
```
|
50
|
+
|
51
|
+
## Configuration Options
|
52
|
+
|
53
|
+
### Set as Default Provider
|
54
|
+
```bash
|
55
|
+
# Make MoonshotAI your permanent default
|
56
|
+
janito --set provider=moonshotai
|
57
|
+
janito --set model=kimi-k1-8k
|
58
|
+
```
|
59
|
+
|
60
|
+
### Environment Variables
|
61
|
+
You can also use environment variables:
|
62
|
+
```bash
|
63
|
+
export MOONSHOTAI_API_KEY=your_key_here
|
64
|
+
export JANITO_PROVIDER=moonshotai
|
65
|
+
export JANITO_MODEL=kimi-k1-8k
|
66
|
+
```
|
67
|
+
|
68
|
+
## MoonshotAI Models
|
69
|
+
|
70
|
+
Janito supports these MoonshotAI models:
|
71
|
+
|
72
|
+
- **kimi-k1-8k**: Fast responses, good for general tasks
|
73
|
+
- **kimi-k1-32k**: Better for longer contexts
|
74
|
+
- **kimi-k1-128k**: Best for very long documents
|
75
|
+
- **kimi-k2-turbo-preview**: Latest model with enhanced capabilities
|
76
|
+
- **kimi-k2-turbo-preview**: Turbo version of the advanced reasoning model
|
77
|
+
|
78
|
+
## Next Steps
|
79
|
+
|
80
|
+
1. **Explore tools**: Run `janito --list-tools` to see available tools
|
81
|
+
2. **Try chat mode**: Run `janito --chat` for interactive sessions
|
82
|
+
3. **Check examples**: Look at the main README.md for more usage examples
|
83
|
+
4. **Join community**: Get help and share tips with other users
|
84
|
+
|
85
|
+
## Troubleshooting
|
86
|
+
|
87
|
+
### Common Issues
|
88
|
+
|
89
|
+
**"Provider not found" error**
|
90
|
+
```bash
|
91
|
+
# Check available providers
|
92
|
+
janito --list-providers
|
93
|
+
|
94
|
+
# Re-register MoonshotAI
|
95
|
+
janito --set-api-key YOUR_KEY -p moonshotai
|
96
|
+
```
|
97
|
+
|
98
|
+
**"Model not available" error**
|
99
|
+
```bash
|
100
|
+
# List available MoonshotAI models
|
101
|
+
janito -p moonshotai --list-models
|
102
|
+
```
|
103
|
+
|
104
|
+
**API key issues**
|
105
|
+
```bash
|
106
|
+
# Check current configuration
|
107
|
+
janito --show-config
|
108
|
+
|
109
|
+
# Reset API key
|
110
|
+
janito --set-api-key NEW_KEY -p moonshotai
|
111
|
+
```
|
112
|
+
|
113
|
+
### Getting Help
|
114
|
+
|
115
|
+
- Check the main README.md for comprehensive documentation
|
116
|
+
- Use `janito --help` for command-line options
|
117
|
+
- Visit our GitHub repository for issues and discussions
|