janito 2.9.0__py3-none-any.whl → 2.12.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.
Files changed (37) hide show
  1. janito/README.md +149 -0
  2. janito/cli/chat_mode/script_runner.py +2 -2
  3. janito/cli/chat_mode/session.py +9 -0
  4. janito/cli/core/model_guesser.py +51 -0
  5. janito/cli/core/runner.py +13 -1
  6. janito/cli/main_cli.py +8 -1
  7. janito/docs/GETTING_STARTED.md +117 -0
  8. janito/drivers/azure_openai/driver.py +7 -0
  9. janito/drivers/openai/driver.py +10 -2
  10. janito/drivers/zai/__init__.py +1 -0
  11. janito/drivers/zai/driver.py +465 -0
  12. janito/mkdocs.yml +40 -0
  13. janito/provider_registry.py +14 -4
  14. janito/providers/__init__.py +2 -1
  15. janito/providers/alibaba/__init__.py +0 -0
  16. janito/providers/alibaba/model_info.py +40 -0
  17. janito/providers/alibaba/provider.py +102 -0
  18. janito/providers/anthropic/provider.py +6 -0
  19. janito/providers/azure_openai/provider.py +6 -0
  20. janito/providers/deepseek/provider.py +6 -0
  21. janito/providers/google/provider.py +6 -0
  22. janito/providers/moonshotai/model_info.py +11 -0
  23. janito/providers/moonshotai/provider.py +7 -1
  24. janito/providers/openai/provider.py +6 -0
  25. janito/providers/zai/__init__.py +1 -0
  26. janito/providers/zai/model_info.py +55 -0
  27. janito/providers/zai/provider.py +128 -0
  28. janito/providers/zai/schema_generator.py +133 -0
  29. {janito-2.9.0.dist-info → janito-2.12.0.dist-info}/METADATA +1 -1
  30. {janito-2.9.0.dist-info → janito-2.12.0.dist-info}/RECORD +34 -24
  31. janito/providers/groq/__init__.py +0 -1
  32. janito/providers/groq/model_info.py +0 -45
  33. janito/providers/groq/provider.py +0 -76
  34. {janito-2.9.0.dist-info → janito-2.12.0.dist-info}/WHEEL +0 -0
  35. {janito-2.9.0.dist-info → janito-2.12.0.dist-info}/entry_points.txt +0 -0
  36. {janito-2.9.0.dist-info → janito-2.12.0.dist-info}/licenses/LICENSE +0 -0
  37. {janito-2.9.0.dist-info → janito-2.12.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 = "openai",
56
- model: str = "gpt-4.1",
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:
@@ -109,6 +109,9 @@ class ChatSession:
109
109
  )
110
110
  self._support = False
111
111
 
112
+ # Check if multi-line mode should be enabled by default
113
+ self.multi_line_mode = getattr(args, "multi", False) if args else False
114
+
112
115
  def _select_profile_and_role(self, args, role):
113
116
  profile = getattr(args, "profile", None) if args is not None else None
114
117
  role_arg = getattr(args, "role", None) if args is not None else None
@@ -213,6 +216,11 @@ class ChatSession:
213
216
  f"[green]Working Dir:[/green] {cwd_display} | {priv_status}"
214
217
  )
215
218
 
219
+ if self.multi_line_mode:
220
+ self.console.print(
221
+ "[blue]Multi-line input mode enabled (Esc+Enter or Ctrl+D to submit)[/blue]"
222
+ )
223
+
216
224
  from janito.cli.chat_mode.shell.commands._priv_check import (
217
225
  user_has_any_privileges,
218
226
  )
@@ -305,6 +313,7 @@ class ChatSession:
305
313
  bottom_toolbar=lambda: get_toolbar_func(
306
314
  self.performance_collector, 0, self.shell_state
307
315
  )(),
316
+ multiline=self.multi_line_mode,
308
317
  )
309
318
 
310
319
  def _handle_input(self, session):
@@ -0,0 +1,51 @@
1
+ """
2
+ Module for guessing the provider based on model names.
3
+ """
4
+
5
+ from janito.providers.registry import LLMProviderRegistry
6
+
7
+
8
+ def guess_provider_from_model(model_name: str) -> str:
9
+ """
10
+ Guess the provider based on the model name.
11
+
12
+ Args:
13
+ model_name: The name of the model to guess the provider for
14
+
15
+ Returns:
16
+ The provider name if a match is found, None otherwise
17
+ """
18
+ if not model_name:
19
+ return None
20
+
21
+ model_name = model_name.lower()
22
+
23
+ # Check each provider's models
24
+ for provider_name in LLMProviderRegistry.list_providers():
25
+ provider_class = LLMProviderRegistry.get(provider_name)
26
+ if not provider_class:
27
+ continue
28
+
29
+ # Get model specs for this provider
30
+ try:
31
+ if hasattr(provider_class, 'MODEL_SPECS'):
32
+ model_specs = provider_class.MODEL_SPECS
33
+ for spec_model_name in model_specs.keys():
34
+ if spec_model_name.lower() == model_name:
35
+ return provider_name
36
+
37
+ # Handle special cases like moonshotai
38
+ if provider_name == "moonshotai":
39
+ try:
40
+ from janito.providers.moonshotai.model_info import MOONSHOTAI_MODEL_SPECS
41
+ for spec_model_name in MOONSHOTAI_MODEL_SPECS.keys():
42
+ if spec_model_name.lower() == model_name:
43
+ return "moonshotai"
44
+ except ImportError:
45
+ pass
46
+
47
+ except Exception:
48
+ # Skip providers that have issues accessing model specs
49
+ continue
50
+
51
+ return None
janito/cli/core/runner.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  from janito.llm.driver_config import LLMDriverConfig
4
4
  from janito.provider_config import get_config_provider
5
+ from janito.cli.core.model_guesser import guess_provider_from_model as _guess_provider_from_model
5
6
  from janito.cli.verbose_output import print_verbose_info
6
7
 
7
8
 
@@ -14,6 +15,17 @@ def _choose_provider(args):
14
15
  "Default provider", provider, style="magenta", align_content=True
15
16
  )
16
17
  elif provider is None:
18
+ # Try to guess provider based on model name if -m is provided
19
+ model = getattr(args, "model", None)
20
+ if model:
21
+ guessed_provider = _guess_provider_from_model(model)
22
+ if guessed_provider:
23
+ if getattr(args, "verbose", False):
24
+ print_verbose_info(
25
+ "Guessed provider", guessed_provider, style="magenta", align_content=True
26
+ )
27
+ return guessed_provider
28
+
17
29
  print(
18
30
  "Error: No provider selected and no provider found in config. Please set a provider using '-p PROVIDER', '--set provider=name', or configure a provider."
19
31
  )
@@ -191,4 +203,4 @@ def handle_runner(
191
203
 
192
204
 
193
205
  def get_prompt_mode(args):
194
- return "single_shot" if getattr(args, "user_prompt", None) else "chat_mode"
206
+ return "single_shot" if getattr(args, "user_prompt", None) else "chat_mode"
janito/cli/main_cli.py CHANGED
@@ -21,6 +21,13 @@ definition = [
21
21
  "help": "Disable path security: allow tool arguments to use any file/directory path (DANGEROUS)",
22
22
  },
23
23
  ),
24
+ (
25
+ ["--multi"],
26
+ {
27
+ "action": "store_true",
28
+ "help": "Start chat mode with multi-line input as default (no need for /multi command)",
29
+ },
30
+ ),
24
31
  (
25
32
  ["--profile"],
26
33
  {
@@ -214,7 +221,7 @@ class JanitoCLI:
214
221
 
215
222
  self.parser = argparse.ArgumentParser(
216
223
  description="Janito CLI - A tool for running LLM-powered workflows from the command line."
217
- "\n\nExample usage: janito -p openai -m gpt-3.5-turbo 'Your prompt here'\n\n"
224
+ "\n\nExample usage: janito -p moonshotai -m kimi-k1-8k 'Your prompt here'\n\n"
218
225
  "Use -m or --model to set the model for the session."
219
226
  )
220
227
  self._define_args()
@@ -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
@@ -63,6 +63,13 @@ class AzureOpenAIModelDriver(OpenAIModelDriver):
63
63
 
64
64
  def _instantiate_openai_client(self, config):
65
65
  try:
66
+ if not config.api_key:
67
+ provider_name = getattr(self, 'provider_name', 'Azure OpenAI')
68
+ print(f"[ERROR] No API key found for provider '{provider_name}'. Please set the API key using:")
69
+ print(f" janito --set-api-key YOUR_API_KEY -p azure-openai")
70
+ print(f"Or set the AZURE_OPENAI_API_KEY environment variable.")
71
+ raise ValueError(f"API key is required for provider '{provider_name}'")
72
+
66
73
  from openai import AzureOpenAI
67
74
 
68
75
  api_key_display = str(config.api_key)
@@ -44,9 +44,10 @@ class OpenAIModelDriver(LLMDriver):
44
44
 
45
45
  tool_classes = self.tools_adapter.get_tool_classes()
46
46
  tool_schemas = generate_tool_schemas(tool_classes)
47
- api_kwargs["tools"] = tool_schemas
47
+ if tool_schemas: # Only add tools if we have actual schemas
48
+ api_kwargs["tools"] = tool_schemas
48
49
  except Exception as e:
49
- api_kwargs["tools"] = []
50
+ # Don't add empty tools array - some providers reject it
50
51
  if hasattr(config, "verbose_api") and config.verbose_api:
51
52
  print(f"[OpenAIModelDriver] Tool schema generation failed: {e}")
52
53
  # OpenAI-specific parameters
@@ -246,6 +247,13 @@ class OpenAIModelDriver(LLMDriver):
246
247
 
247
248
  def _instantiate_openai_client(self, config):
248
249
  try:
250
+ if not config.api_key:
251
+ provider_name = getattr(self, 'provider_name', 'OpenAI-compatible')
252
+ print(f"[ERROR] No API key found for provider '{provider_name}'. Please set the API key using:")
253
+ print(f" janito --set-api-key YOUR_API_KEY -p {provider_name.lower()}")
254
+ print(f"Or set the {provider_name.upper()}_API_KEY environment variable.")
255
+ raise ValueError(f"API key is required for provider '{provider_name}'")
256
+
249
257
  api_key_display = str(config.api_key)
250
258
  if api_key_display and len(api_key_display) > 8:
251
259
  api_key_display = api_key_display[:4] + "..." + api_key_display[-4:]
@@ -0,0 +1 @@
1
+ # Z.AI driver package