janito 2.1.1__py3-none-any.whl → 2.3.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/__init__.py +6 -6
- janito/agent/setup_agent.py +14 -5
- janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +3 -1
- janito/cli/chat_mode/bindings.py +6 -0
- janito/cli/chat_mode/session.py +16 -0
- janito/cli/chat_mode/shell/autocomplete.py +21 -21
- janito/cli/chat_mode/shell/commands/__init__.py +3 -2
- janito/cli/chat_mode/shell/commands/clear.py +12 -12
- janito/cli/chat_mode/shell/commands/exec.py +27 -0
- janito/cli/chat_mode/shell/commands/multi.py +51 -51
- janito/cli/chat_mode/shell/commands/tools.py +17 -6
- janito/cli/chat_mode/shell/input_history.py +62 -62
- janito/cli/chat_mode/shell/session/manager.py +1 -0
- janito/cli/chat_mode/toolbar.py +3 -1
- janito/cli/cli_commands/list_models.py +35 -35
- janito/cli/cli_commands/list_providers.py +9 -9
- janito/cli/cli_commands/list_tools.py +53 -53
- janito/cli/cli_commands/model_selection.py +50 -50
- janito/cli/cli_commands/model_utils.py +13 -2
- janito/cli/cli_commands/set_api_key.py +19 -19
- janito/cli/cli_commands/show_config.py +51 -51
- janito/cli/cli_commands/show_system_prompt.py +62 -62
- janito/cli/config.py +2 -1
- janito/cli/core/__init__.py +4 -4
- janito/cli/core/event_logger.py +59 -59
- janito/cli/core/getters.py +3 -1
- janito/cli/core/runner.py +27 -6
- janito/cli/core/setters.py +5 -1
- janito/cli/core/unsetters.py +54 -54
- janito/cli/main_cli.py +12 -1
- janito/cli/prompt_core.py +5 -2
- janito/cli/rich_terminal_reporter.py +22 -3
- janito/cli/single_shot_mode/__init__.py +6 -6
- janito/cli/single_shot_mode/handler.py +11 -1
- janito/cli/verbose_output.py +1 -1
- janito/config.py +5 -5
- janito/config_manager.py +2 -0
- janito/driver_events.py +14 -0
- janito/drivers/anthropic/driver.py +113 -113
- janito/drivers/azure_openai/driver.py +38 -3
- janito/drivers/driver_registry.py +0 -2
- janito/drivers/openai/driver.py +196 -36
- janito/formatting_token.py +54 -54
- janito/i18n/__init__.py +35 -35
- janito/i18n/messages.py +23 -23
- janito/i18n/pt.py +47 -47
- janito/llm/__init__.py +5 -5
- janito/llm/agent.py +443 -443
- janito/llm/auth.py +1 -0
- janito/llm/driver.py +7 -1
- janito/llm/driver_config.py +1 -0
- janito/llm/driver_config_builder.py +34 -34
- janito/llm/driver_input.py +12 -12
- janito/llm/message_parts.py +60 -60
- janito/llm/model.py +38 -38
- janito/llm/provider.py +196 -196
- janito/provider_config.py +7 -3
- janito/provider_registry.py +29 -5
- janito/providers/__init__.py +1 -0
- janito/providers/anthropic/model_info.py +22 -22
- janito/providers/anthropic/provider.py +2 -2
- janito/providers/azure_openai/model_info.py +7 -6
- janito/providers/azure_openai/provider.py +44 -2
- janito/providers/deepseek/__init__.py +1 -1
- janito/providers/deepseek/model_info.py +16 -16
- janito/providers/deepseek/provider.py +91 -91
- janito/providers/google/model_info.py +21 -29
- janito/providers/google/provider.py +49 -38
- janito/providers/mistralai/provider.py +2 -2
- janito/providers/openai/model_info.py +0 -11
- janito/providers/openai/provider.py +1 -1
- janito/providers/provider_static_info.py +2 -3
- janito/providers/registry.py +26 -26
- janito/tools/adapters/__init__.py +1 -1
- janito/tools/adapters/local/__init__.py +62 -62
- janito/tools/adapters/local/adapter.py +33 -11
- janito/tools/adapters/local/ask_user.py +102 -102
- janito/tools/adapters/local/copy_file.py +84 -84
- janito/tools/adapters/local/create_directory.py +69 -69
- janito/tools/adapters/local/create_file.py +82 -82
- janito/tools/adapters/local/delete_text_in_file.py +4 -7
- janito/tools/adapters/local/fetch_url.py +97 -97
- janito/tools/adapters/local/find_files.py +138 -140
- janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
- janito/tools/adapters/local/get_file_outline/core.py +117 -151
- janito/tools/adapters/local/get_file_outline/java_outline.py +40 -0
- janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
- janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
- janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
- janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
- janito/tools/adapters/local/move_file.py +3 -13
- janito/tools/adapters/local/open_html_in_browser.py +24 -29
- janito/tools/adapters/local/open_url.py +3 -2
- janito/tools/adapters/local/python_code_run.py +166 -166
- janito/tools/adapters/local/python_command_run.py +164 -164
- janito/tools/adapters/local/python_file_run.py +163 -163
- janito/tools/adapters/local/remove_directory.py +6 -17
- janito/tools/adapters/local/remove_file.py +9 -15
- janito/tools/adapters/local/replace_text_in_file.py +6 -9
- janito/tools/adapters/local/run_bash_command.py +176 -176
- janito/tools/adapters/local/run_powershell_command.py +219 -219
- janito/tools/adapters/local/search_text/__init__.py +1 -1
- janito/tools/adapters/local/search_text/core.py +201 -201
- janito/tools/adapters/local/search_text/match_lines.py +1 -1
- janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
- janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
- janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
- janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
- janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
- janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
- janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
- janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
- janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
- janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
- janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
- janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
- janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
- janito/tools/adapters/local/view_file.py +167 -167
- janito/tools/inspect_registry.py +17 -17
- janito/tools/tool_base.py +105 -105
- janito/tools/tool_events.py +58 -58
- janito/tools/tool_run_exception.py +12 -12
- janito/tools/tool_use_tracker.py +81 -81
- janito/tools/tool_utils.py +45 -45
- janito/tools/tools_adapter.py +78 -6
- janito/tools/tools_schema.py +104 -104
- janito/version.py +4 -4
- {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/METADATA +388 -232
- janito-2.3.0.dist-info/RECORD +181 -0
- janito-2.3.0.dist-info/licenses/LICENSE +21 -0
- janito/cli/chat_mode/shell/commands/last.py +0 -137
- janito/drivers/google_genai/driver.py +0 -54
- janito/drivers/google_genai/schema_generator.py +0 -67
- janito-2.1.1.dist-info/RECORD +0 -181
- {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
- {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
- {janito-2.1.1.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -1,16 +1,16 @@
|
|
1
|
-
MODEL_SPECS = {
|
2
|
-
"deepseek-chat": {
|
3
|
-
"description": "DeepSeek Chat Model (OpenAI-compatible)",
|
4
|
-
"context_window": 8192,
|
5
|
-
"max_tokens": 4096,
|
6
|
-
"family": "deepseek",
|
7
|
-
"default": True,
|
8
|
-
},
|
9
|
-
"deepseek-reasoner": {
|
10
|
-
"description": "DeepSeek Reasoner Model (OpenAI-compatible)",
|
11
|
-
"context_window": 8192,
|
12
|
-
"max_tokens": 4096,
|
13
|
-
"family": "deepseek",
|
14
|
-
"default": False,
|
15
|
-
},
|
16
|
-
}
|
1
|
+
MODEL_SPECS = {
|
2
|
+
"deepseek-chat": {
|
3
|
+
"description": "DeepSeek Chat Model (OpenAI-compatible)",
|
4
|
+
"context_window": 8192,
|
5
|
+
"max_tokens": 4096,
|
6
|
+
"family": "deepseek",
|
7
|
+
"default": True,
|
8
|
+
},
|
9
|
+
"deepseek-reasoner": {
|
10
|
+
"description": "DeepSeek Reasoner Model (OpenAI-compatible)",
|
11
|
+
"context_window": 8192,
|
12
|
+
"max_tokens": 4096,
|
13
|
+
"family": "deepseek",
|
14
|
+
"default": False,
|
15
|
+
},
|
16
|
+
}
|
@@ -1,91 +1,91 @@
|
|
1
|
-
from janito.llm.provider import LLMProvider
|
2
|
-
from janito.llm.model import LLMModelInfo
|
3
|
-
from janito.llm.auth import LLMAuthManager
|
4
|
-
from janito.llm.driver_config import LLMDriverConfig
|
5
|
-
from janito.drivers.openai.driver import OpenAIModelDriver
|
6
|
-
from janito.tools import get_local_tools_adapter
|
7
|
-
from janito.providers.registry import LLMProviderRegistry
|
8
|
-
from .model_info import MODEL_SPECS
|
9
|
-
from queue import Queue
|
10
|
-
|
11
|
-
available = OpenAIModelDriver.available
|
12
|
-
unavailable_reason = OpenAIModelDriver.unavailable_reason
|
13
|
-
|
14
|
-
|
15
|
-
class DeepseekProvider(LLMProvider):
|
16
|
-
name = "deepseek"
|
17
|
-
maintainer = "Needs maintainer"
|
18
|
-
MODEL_SPECS = MODEL_SPECS
|
19
|
-
DEFAULT_MODEL = "deepseek-chat" # Options: deepseek-chat, deepseek-reasoner
|
20
|
-
|
21
|
-
def __init__(
|
22
|
-
self, auth_manager: LLMAuthManager = None, config: LLMDriverConfig = None
|
23
|
-
):
|
24
|
-
if not self.available:
|
25
|
-
self._driver = None
|
26
|
-
else:
|
27
|
-
self.auth_manager = auth_manager or LLMAuthManager()
|
28
|
-
self._api_key = self.auth_manager.get_credentials(type(self).name)
|
29
|
-
self._tools_adapter = get_local_tools_adapter()
|
30
|
-
self._driver_config = config or LLMDriverConfig(model=None)
|
31
|
-
if not self._driver_config.model:
|
32
|
-
self._driver_config.model = self.DEFAULT_MODEL
|
33
|
-
if not self._driver_config.api_key:
|
34
|
-
self._driver_config.api_key = self._api_key
|
35
|
-
# Set DeepSeek public endpoint as default base_url if not provided
|
36
|
-
if not getattr(self._driver_config, "base_url", None):
|
37
|
-
self._driver_config.base_url = "https://api.deepseek.com/v1"
|
38
|
-
self.fill_missing_device_info(self._driver_config)
|
39
|
-
self._driver = None # to be provided by factory/agent
|
40
|
-
|
41
|
-
@property
|
42
|
-
def driver(self) -> OpenAIModelDriver:
|
43
|
-
if not self.available:
|
44
|
-
raise ImportError(f"OpenAIProvider unavailable: {self.unavailable_reason}")
|
45
|
-
return self._driver
|
46
|
-
|
47
|
-
@property
|
48
|
-
def available(self):
|
49
|
-
return available
|
50
|
-
|
51
|
-
@property
|
52
|
-
def unavailable_reason(self):
|
53
|
-
return unavailable_reason
|
54
|
-
|
55
|
-
def create_driver(self):
|
56
|
-
"""
|
57
|
-
Creates and returns a new OpenAIModelDriver instance with input/output queues.
|
58
|
-
"""
|
59
|
-
driver = OpenAIModelDriver(
|
60
|
-
tools_adapter=self._tools_adapter, provider_name=self.name
|
61
|
-
)
|
62
|
-
driver.config = self._driver_config
|
63
|
-
# NOTE: The caller is responsible for calling driver.start() if background processing is needed.
|
64
|
-
return driver
|
65
|
-
|
66
|
-
def create_agent(self, tools_adapter=None, agent_name: str = None, **kwargs):
|
67
|
-
from janito.llm.agent import LLMAgent
|
68
|
-
|
69
|
-
# Always create a new driver with the passed-in tools_adapter
|
70
|
-
if tools_adapter is None:
|
71
|
-
tools_adapter = get_local_tools_adapter()
|
72
|
-
# Should use new-style driver construction via queues/factory (handled elsewhere)
|
73
|
-
raise NotImplementedError(
|
74
|
-
"create_agent must be constructed via new factory using input/output queues and config."
|
75
|
-
)
|
76
|
-
|
77
|
-
@property
|
78
|
-
def model_name(self):
|
79
|
-
return self._driver_config.model
|
80
|
-
|
81
|
-
@property
|
82
|
-
def driver_config(self):
|
83
|
-
"""Public, read-only access to the provider's LLMDriverConfig object."""
|
84
|
-
return self._driver_config
|
85
|
-
|
86
|
-
def execute_tool(self, tool_name: str, event_bus, *args, **kwargs):
|
87
|
-
self._tools_adapter.event_bus = event_bus
|
88
|
-
return self._tools_adapter.execute_by_name(tool_name, *args, **kwargs)
|
89
|
-
|
90
|
-
|
91
|
-
LLMProviderRegistry.register(DeepseekProvider.name, DeepseekProvider)
|
1
|
+
from janito.llm.provider import LLMProvider
|
2
|
+
from janito.llm.model import LLMModelInfo
|
3
|
+
from janito.llm.auth import LLMAuthManager
|
4
|
+
from janito.llm.driver_config import LLMDriverConfig
|
5
|
+
from janito.drivers.openai.driver import OpenAIModelDriver
|
6
|
+
from janito.tools import get_local_tools_adapter
|
7
|
+
from janito.providers.registry import LLMProviderRegistry
|
8
|
+
from .model_info import MODEL_SPECS
|
9
|
+
from queue import Queue
|
10
|
+
|
11
|
+
available = OpenAIModelDriver.available
|
12
|
+
unavailable_reason = OpenAIModelDriver.unavailable_reason
|
13
|
+
|
14
|
+
|
15
|
+
class DeepseekProvider(LLMProvider):
|
16
|
+
name = "deepseek"
|
17
|
+
maintainer = "Needs maintainer"
|
18
|
+
MODEL_SPECS = MODEL_SPECS
|
19
|
+
DEFAULT_MODEL = "deepseek-chat" # Options: deepseek-chat, deepseek-reasoner
|
20
|
+
|
21
|
+
def __init__(
|
22
|
+
self, auth_manager: LLMAuthManager = None, config: LLMDriverConfig = None
|
23
|
+
):
|
24
|
+
if not self.available:
|
25
|
+
self._driver = None
|
26
|
+
else:
|
27
|
+
self.auth_manager = auth_manager or LLMAuthManager()
|
28
|
+
self._api_key = self.auth_manager.get_credentials(type(self).name)
|
29
|
+
self._tools_adapter = get_local_tools_adapter()
|
30
|
+
self._driver_config = config or LLMDriverConfig(model=None)
|
31
|
+
if not self._driver_config.model:
|
32
|
+
self._driver_config.model = self.DEFAULT_MODEL
|
33
|
+
if not self._driver_config.api_key:
|
34
|
+
self._driver_config.api_key = self._api_key
|
35
|
+
# Set DeepSeek public endpoint as default base_url if not provided
|
36
|
+
if not getattr(self._driver_config, "base_url", None):
|
37
|
+
self._driver_config.base_url = "https://api.deepseek.com/v1"
|
38
|
+
self.fill_missing_device_info(self._driver_config)
|
39
|
+
self._driver = None # to be provided by factory/agent
|
40
|
+
|
41
|
+
@property
|
42
|
+
def driver(self) -> OpenAIModelDriver:
|
43
|
+
if not self.available:
|
44
|
+
raise ImportError(f"OpenAIProvider unavailable: {self.unavailable_reason}")
|
45
|
+
return self._driver
|
46
|
+
|
47
|
+
@property
|
48
|
+
def available(self):
|
49
|
+
return available
|
50
|
+
|
51
|
+
@property
|
52
|
+
def unavailable_reason(self):
|
53
|
+
return unavailable_reason
|
54
|
+
|
55
|
+
def create_driver(self):
|
56
|
+
"""
|
57
|
+
Creates and returns a new OpenAIModelDriver instance with input/output queues.
|
58
|
+
"""
|
59
|
+
driver = OpenAIModelDriver(
|
60
|
+
tools_adapter=self._tools_adapter, provider_name=self.name
|
61
|
+
)
|
62
|
+
driver.config = self._driver_config
|
63
|
+
# NOTE: The caller is responsible for calling driver.start() if background processing is needed.
|
64
|
+
return driver
|
65
|
+
|
66
|
+
def create_agent(self, tools_adapter=None, agent_name: str = None, **kwargs):
|
67
|
+
from janito.llm.agent import LLMAgent
|
68
|
+
|
69
|
+
# Always create a new driver with the passed-in tools_adapter
|
70
|
+
if tools_adapter is None:
|
71
|
+
tools_adapter = get_local_tools_adapter()
|
72
|
+
# Should use new-style driver construction via queues/factory (handled elsewhere)
|
73
|
+
raise NotImplementedError(
|
74
|
+
"create_agent must be constructed via new factory using input/output queues and config."
|
75
|
+
)
|
76
|
+
|
77
|
+
@property
|
78
|
+
def model_name(self):
|
79
|
+
return self._driver_config.model
|
80
|
+
|
81
|
+
@property
|
82
|
+
def driver_config(self):
|
83
|
+
"""Public, read-only access to the provider's LLMDriverConfig object."""
|
84
|
+
return self._driver_config
|
85
|
+
|
86
|
+
def execute_tool(self, tool_name: str, event_bus, *args, **kwargs):
|
87
|
+
self._tools_adapter.event_bus = event_bus
|
88
|
+
return self._tools_adapter.execute_by_name(tool_name, *args, **kwargs)
|
89
|
+
|
90
|
+
|
91
|
+
LLMProviderRegistry.register(DeepseekProvider.name, DeepseekProvider)
|
@@ -1,40 +1,32 @@
|
|
1
1
|
from janito.llm.model import LLMModelInfo
|
2
2
|
|
3
3
|
MODEL_SPECS = {
|
4
|
-
"gemini-2.5-
|
5
|
-
name="gemini-2.5-
|
6
|
-
|
7
|
-
max_input=131072,
|
8
|
-
max_cot="N/A",
|
9
|
-
max_response=32768,
|
10
|
-
thinking_supported=True,
|
11
|
-
default_temp=0.2,
|
4
|
+
"gemini-2.5-flash": LLMModelInfo(
|
5
|
+
name="gemini-2.5-flash",
|
6
|
+
other={"description": "Google Gemini 2.5 Flash (OpenAI-compatible endpoint)"},
|
12
7
|
open="google",
|
13
|
-
driver="
|
14
|
-
|
15
|
-
|
16
|
-
"gemini-2.5-flash-preview-05-20": LLMModelInfo(
|
17
|
-
name="gemini-2.5-flash-preview-05-20",
|
18
|
-
context=1000000,
|
19
|
-
max_input=1000000,
|
20
|
-
max_cot="N/A",
|
21
|
-
max_response=65536,
|
8
|
+
driver="OpenAIModelDriver",
|
9
|
+
max_response=8192,
|
10
|
+
max_cot=24576,
|
22
11
|
thinking_supported=True,
|
23
|
-
default_temp=0.2,
|
24
|
-
open="google",
|
25
|
-
driver="GoogleGenaiModelDriver",
|
26
|
-
other={"preview": True, "flash": True},
|
27
12
|
),
|
28
|
-
|
29
|
-
name="gemini-2.5-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
"gemini-2.5-pro": LLMModelInfo(
|
14
|
+
name="gemini-2.5-pro",
|
15
|
+
other={"description": "Google Gemini 2.5 Pro (OpenAI-compatible endpoint)"},
|
16
|
+
open="google",
|
17
|
+
driver="OpenAIModelDriver",
|
33
18
|
max_response=65536,
|
19
|
+
max_cot=196608,
|
34
20
|
thinking_supported=True,
|
35
|
-
|
21
|
+
),
|
22
|
+
"gemini-2.5-flash-lite-preview-06-17": LLMModelInfo(
|
23
|
+
name="gemini-2.5-flash-lite-preview-06-17",
|
24
|
+
other={"description": "Google Gemini 2.5 Flash-Lite Preview (OpenAI-compatible endpoint)"},
|
36
25
|
open="google",
|
37
|
-
driver="
|
38
|
-
|
26
|
+
driver="OpenAIModelDriver",
|
27
|
+
max_response=64000,
|
28
|
+
max_cot=192000,
|
29
|
+
thinking_supported=True,
|
39
30
|
),
|
31
|
+
# Add more Gemini models as needed
|
40
32
|
}
|
@@ -2,64 +2,75 @@ from janito.llm.provider import LLMProvider
|
|
2
2
|
from janito.llm.model import LLMModelInfo
|
3
3
|
from janito.llm.auth import LLMAuthManager
|
4
4
|
from janito.llm.driver_config import LLMDriverConfig
|
5
|
-
from janito.drivers.
|
6
|
-
from janito.tools
|
5
|
+
from janito.drivers.openai.driver import OpenAIModelDriver
|
6
|
+
from janito.tools import get_local_tools_adapter
|
7
7
|
from janito.providers.registry import LLMProviderRegistry
|
8
|
+
from queue import Queue
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
from
|
12
|
-
|
13
|
-
|
14
|
-
unavailable_reason = GoogleGenaiModelDriver.unavailable_reason
|
15
|
-
maintainer = "Needs maintainer"
|
16
|
-
|
10
|
+
# Import Google Gemini model specs (to be created or imported as needed)
|
11
|
+
try:
|
12
|
+
from .model_info import MODEL_SPECS
|
13
|
+
except ImportError:
|
14
|
+
MODEL_SPECS = {}
|
17
15
|
|
18
16
|
class GoogleProvider(LLMProvider):
|
19
|
-
MODEL_SPECS = MODEL_SPECS
|
20
|
-
maintainer = "Needs maintainer"
|
21
|
-
"""
|
22
|
-
Provider for Google LLMs via google-google.
|
23
|
-
Default model: 'gemini-2.5-pro-preview-05-06'.
|
24
|
-
"""
|
25
17
|
name = "google"
|
26
|
-
|
18
|
+
maintainer = "João Pinto <lamego.pinto@gmail.com>"
|
19
|
+
MODEL_SPECS = MODEL_SPECS
|
20
|
+
DEFAULT_MODEL = "gemini-2.5-flash" # Default Gemini model
|
27
21
|
|
28
|
-
def __init__(
|
22
|
+
def __init__(
|
23
|
+
self, auth_manager: LLMAuthManager = None, config: LLMDriverConfig = None
|
24
|
+
):
|
29
25
|
if not self.available:
|
30
26
|
self._driver = None
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
self.
|
38
|
-
|
39
|
-
self.
|
40
|
-
|
41
|
-
|
27
|
+
else:
|
28
|
+
self.auth_manager = auth_manager or LLMAuthManager()
|
29
|
+
self._api_key = self.auth_manager.get_credentials(type(self).name)
|
30
|
+
self._tools_adapter = get_local_tools_adapter()
|
31
|
+
self._driver_config = config or LLMDriverConfig(model=None)
|
32
|
+
# Only set default if model is not set by CLI/config
|
33
|
+
if not getattr(self._driver_config, 'model', None):
|
34
|
+
self._driver_config.model = self.DEFAULT_MODEL
|
35
|
+
if not self._driver_config.api_key:
|
36
|
+
self._driver_config.api_key = self._api_key
|
37
|
+
# Set the Gemini API endpoint for OpenAI compatibility
|
38
|
+
self._driver_config.base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
|
39
|
+
self.fill_missing_device_info(self._driver_config)
|
40
|
+
self._driver = None # to be provided by factory/agent
|
42
41
|
|
43
42
|
@property
|
44
|
-
def driver(self) ->
|
43
|
+
def driver(self) -> OpenAIModelDriver:
|
45
44
|
if not self.available:
|
46
|
-
raise ImportError(f"
|
45
|
+
raise ImportError(f"GoogleOpenAIProvider unavailable: {self.unavailable_reason}")
|
47
46
|
return self._driver
|
48
47
|
|
49
48
|
@property
|
50
49
|
def available(self):
|
51
|
-
return available
|
50
|
+
return OpenAIModelDriver.available
|
52
51
|
|
53
52
|
@property
|
54
53
|
def unavailable_reason(self):
|
55
|
-
return unavailable_reason
|
54
|
+
return OpenAIModelDriver.unavailable_reason
|
55
|
+
|
56
|
+
def create_driver(self):
|
57
|
+
"""
|
58
|
+
Creates and returns a new OpenAIModelDriver instance configured for Gemini API.
|
59
|
+
"""
|
60
|
+
driver = OpenAIModelDriver(
|
61
|
+
tools_adapter=self._tools_adapter, provider_name=self.name
|
62
|
+
)
|
63
|
+
driver.config = self._driver_config
|
64
|
+
return driver
|
56
65
|
|
57
|
-
|
58
|
-
|
66
|
+
@property
|
67
|
+
def model_name(self):
|
68
|
+
return self._driver_config.model
|
59
69
|
|
60
|
-
|
61
|
-
|
62
|
-
|
70
|
+
@property
|
71
|
+
def driver_config(self):
|
72
|
+
"""Public, read-only access to the provider's LLMDriverConfig object."""
|
73
|
+
return self._driver_config
|
63
74
|
|
64
75
|
def execute_tool(self, tool_name: str, event_bus, *args, **kwargs):
|
65
76
|
self._tools_adapter.event_bus = event_bus
|
@@ -3,7 +3,7 @@ from janito.llm.model import LLMModelInfo
|
|
3
3
|
from janito.llm.auth import LLMAuthManager
|
4
4
|
from janito.llm.driver_config import LLMDriverConfig
|
5
5
|
from janito.drivers.mistralai.driver import MistralAIModelDriver
|
6
|
-
from janito.tools
|
6
|
+
from janito.tools import get_local_tools_adapter
|
7
7
|
from janito.providers.registry import LLMProviderRegistry
|
8
8
|
|
9
9
|
from .model_info import MODEL_SPECS
|
@@ -29,7 +29,7 @@ class MistralAIProvider(LLMProvider):
|
|
29
29
|
return
|
30
30
|
self.auth_manager = auth_manager or LLMAuthManager()
|
31
31
|
self._api_key = self.auth_manager.get_credentials(type(self).name)
|
32
|
-
self._tools_adapter =
|
32
|
+
self._tools_adapter = get_local_tools_adapter()
|
33
33
|
self._info = config or LLMDriverConfig(model=None)
|
34
34
|
if not self._info.model:
|
35
35
|
self._info.model = self.DEFAULT_MODEL
|
@@ -111,17 +111,6 @@ MODEL_SPECS = {
|
|
111
111
|
open="openai",
|
112
112
|
driver="OpenAIModelDriver",
|
113
113
|
),
|
114
|
-
"o4-mini-high": LLMModelInfo(
|
115
|
-
name="o4-mini-high",
|
116
|
-
context=200000,
|
117
|
-
max_input=100000,
|
118
|
-
max_cot="N/A",
|
119
|
-
max_response=100000,
|
120
|
-
thinking_supported=True,
|
121
|
-
default_temp=0.2,
|
122
|
-
open="openai",
|
123
|
-
driver="OpenAIModelDriver",
|
124
|
-
),
|
125
114
|
# duplicated gpt-4-turbo with minimal properties for distinction
|
126
115
|
"gpt-4-turbo-alt": LLMModelInfo(
|
127
116
|
name="gpt-4-turbo",
|
@@ -17,7 +17,7 @@ class OpenAIProvider(LLMProvider):
|
|
17
17
|
maintainer = "João Pinto <lamego.pinto@gmail.com>"
|
18
18
|
MODEL_SPECS = MODEL_SPECS
|
19
19
|
DEFAULT_MODEL = (
|
20
|
-
"gpt-4.1" # Options: gpt-4.1, gpt-4o, o3-mini, o4-mini,
|
20
|
+
"gpt-4.1" # Options: gpt-4.1, gpt-4o, o3-mini, o4-mini,
|
21
21
|
)
|
22
22
|
|
23
23
|
def __init__(
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# Provider static metadata registry for listing purposes (name, maintainer, and future fields)
|
2
2
|
STATIC_PROVIDER_METADATA = {
|
3
3
|
"openai": {
|
4
|
+
},
|
5
|
+
"google": {
|
4
6
|
"maintainer": "João Pinto <lamego.pinto@gmail.com>",
|
5
7
|
},
|
6
8
|
"azure_openai": {
|
7
9
|
"maintainer": "João Pinto <lamego.pinto@gmail.com>",
|
8
10
|
},
|
9
|
-
"google": {
|
10
|
-
"maintainer": "Needs maintainer",
|
11
|
-
},
|
12
11
|
"mistralai": {
|
13
12
|
"maintainer": "Needs maintainer",
|
14
13
|
},
|
janito/providers/registry.py
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
from typing import Type, Dict
|
2
|
-
from janito.llm.provider import LLMProvider
|
3
|
-
|
4
|
-
|
5
|
-
class LLMProviderRegistry:
|
6
|
-
"""
|
7
|
-
Registry for LLM provider classes.
|
8
|
-
"""
|
9
|
-
|
10
|
-
_providers: Dict[str, Type[LLMProvider]] = {}
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def register(cls, name: str, provider_cls: Type[LLMProvider]):
|
14
|
-
if name in cls._providers:
|
15
|
-
raise ValueError(f"Provider '{name}' is already registered.")
|
16
|
-
cls._providers[name] = provider_cls
|
17
|
-
|
18
|
-
@classmethod
|
19
|
-
def get(cls, name: str) -> Type[LLMProvider]:
|
20
|
-
if name not in cls._providers:
|
21
|
-
|
22
|
-
return cls._providers[name]
|
23
|
-
|
24
|
-
@classmethod
|
25
|
-
def list_providers(cls):
|
26
|
-
return list(cls._providers.keys())
|
1
|
+
from typing import Type, Dict
|
2
|
+
from janito.llm.provider import LLMProvider
|
3
|
+
|
4
|
+
|
5
|
+
class LLMProviderRegistry:
|
6
|
+
"""
|
7
|
+
Registry for LLM provider classes.
|
8
|
+
"""
|
9
|
+
|
10
|
+
_providers: Dict[str, Type[LLMProvider]] = {}
|
11
|
+
|
12
|
+
@classmethod
|
13
|
+
def register(cls, name: str, provider_cls: Type[LLMProvider]):
|
14
|
+
if name in cls._providers:
|
15
|
+
raise ValueError(f"Provider '{name}' is already registered.")
|
16
|
+
cls._providers[name] = provider_cls
|
17
|
+
|
18
|
+
@classmethod
|
19
|
+
def get(cls, name: str) -> Type[LLMProvider]:
|
20
|
+
if name not in cls._providers:
|
21
|
+
return None
|
22
|
+
return cls._providers[name]
|
23
|
+
|
24
|
+
@classmethod
|
25
|
+
def list_providers(cls):
|
26
|
+
return list(cls._providers.keys())
|
@@ -1 +1 @@
|
|
1
|
-
# Tools providers package: for plug-and-play tool collections, integrations, and adapters.
|
1
|
+
# Tools providers package: for plug-and-play tool collections, integrations, and adapters.
|
@@ -1,62 +1,62 @@
|
|
1
|
-
from .adapter import LocalToolsAdapter
|
2
|
-
|
3
|
-
from .ask_user import AskUserTool
|
4
|
-
from .copy_file import CopyFileTool
|
5
|
-
from .create_directory import CreateDirectoryTool
|
6
|
-
from .create_file import CreateFileTool
|
7
|
-
from .fetch_url import FetchUrlTool
|
8
|
-
from .find_files import FindFilesTool
|
9
|
-
from .view_file import ViewFileTool
|
10
|
-
from .move_file import MoveFileTool
|
11
|
-
from .open_url import OpenUrlTool
|
12
|
-
from .open_html_in_browser import OpenHtmlInBrowserTool
|
13
|
-
from .python_code_run import PythonCodeRunTool
|
14
|
-
from .python_command_run import PythonCommandRunTool
|
15
|
-
from .python_file_run import PythonFileRunTool
|
16
|
-
from .remove_directory import RemoveDirectoryTool
|
17
|
-
from .remove_file import RemoveFileTool
|
18
|
-
from .replace_text_in_file import ReplaceTextInFileTool
|
19
|
-
from .run_bash_command import RunBashCommandTool
|
20
|
-
from .run_powershell_command import RunPowershellCommandTool
|
21
|
-
from .get_file_outline.core import GetFileOutlineTool
|
22
|
-
from .get_file_outline.search_outline import SearchOutlineTool
|
23
|
-
from .search_text.core import SearchTextTool
|
24
|
-
from .validate_file_syntax.core import ValidateFileSyntaxTool
|
25
|
-
|
26
|
-
# Singleton tools adapter with all standard tools registered
|
27
|
-
import os
|
28
|
-
local_tools_adapter = LocalToolsAdapter(workdir=os.getcwd())
|
29
|
-
|
30
|
-
def get_local_tools_adapter(workdir=None):
|
31
|
-
import os
|
32
|
-
return LocalToolsAdapter(workdir=workdir or os.getcwd())
|
33
|
-
|
34
|
-
# Register tools
|
35
|
-
for tool_class in [
|
36
|
-
AskUserTool,
|
37
|
-
CopyFileTool,
|
38
|
-
CreateDirectoryTool,
|
39
|
-
CreateFileTool,
|
40
|
-
FetchUrlTool,
|
41
|
-
FindFilesTool,
|
42
|
-
ViewFileTool,
|
43
|
-
MoveFileTool,
|
44
|
-
OpenUrlTool,
|
45
|
-
OpenHtmlInBrowserTool,
|
46
|
-
PythonCodeRunTool,
|
47
|
-
PythonCommandRunTool,
|
48
|
-
PythonFileRunTool,
|
49
|
-
RemoveDirectoryTool,
|
50
|
-
RemoveFileTool,
|
51
|
-
ReplaceTextInFileTool,
|
52
|
-
RunBashCommandTool,
|
53
|
-
RunPowershellCommandTool,
|
54
|
-
GetFileOutlineTool,
|
55
|
-
SearchOutlineTool,
|
56
|
-
SearchTextTool,
|
57
|
-
ValidateFileSyntaxTool,
|
58
|
-
]:
|
59
|
-
local_tools_adapter.register_tool(tool_class)
|
60
|
-
|
61
|
-
# DEBUG: Print registered tools at startup
|
62
|
-
|
1
|
+
from .adapter import LocalToolsAdapter
|
2
|
+
|
3
|
+
from .ask_user import AskUserTool
|
4
|
+
from .copy_file import CopyFileTool
|
5
|
+
from .create_directory import CreateDirectoryTool
|
6
|
+
from .create_file import CreateFileTool
|
7
|
+
from .fetch_url import FetchUrlTool
|
8
|
+
from .find_files import FindFilesTool
|
9
|
+
from .view_file import ViewFileTool
|
10
|
+
from .move_file import MoveFileTool
|
11
|
+
from .open_url import OpenUrlTool
|
12
|
+
from .open_html_in_browser import OpenHtmlInBrowserTool
|
13
|
+
from .python_code_run import PythonCodeRunTool
|
14
|
+
from .python_command_run import PythonCommandRunTool
|
15
|
+
from .python_file_run import PythonFileRunTool
|
16
|
+
from .remove_directory import RemoveDirectoryTool
|
17
|
+
from .remove_file import RemoveFileTool
|
18
|
+
from .replace_text_in_file import ReplaceTextInFileTool
|
19
|
+
from .run_bash_command import RunBashCommandTool
|
20
|
+
from .run_powershell_command import RunPowershellCommandTool
|
21
|
+
from .get_file_outline.core import GetFileOutlineTool
|
22
|
+
from .get_file_outline.search_outline import SearchOutlineTool
|
23
|
+
from .search_text.core import SearchTextTool
|
24
|
+
from .validate_file_syntax.core import ValidateFileSyntaxTool
|
25
|
+
|
26
|
+
# Singleton tools adapter with all standard tools registered
|
27
|
+
import os
|
28
|
+
local_tools_adapter = LocalToolsAdapter(workdir=os.getcwd())
|
29
|
+
|
30
|
+
def get_local_tools_adapter(workdir=None):
|
31
|
+
import os
|
32
|
+
return LocalToolsAdapter(workdir=workdir or os.getcwd())
|
33
|
+
|
34
|
+
# Register tools
|
35
|
+
for tool_class in [
|
36
|
+
AskUserTool,
|
37
|
+
CopyFileTool,
|
38
|
+
CreateDirectoryTool,
|
39
|
+
CreateFileTool,
|
40
|
+
FetchUrlTool,
|
41
|
+
FindFilesTool,
|
42
|
+
ViewFileTool,
|
43
|
+
MoveFileTool,
|
44
|
+
OpenUrlTool,
|
45
|
+
OpenHtmlInBrowserTool,
|
46
|
+
PythonCodeRunTool,
|
47
|
+
PythonCommandRunTool,
|
48
|
+
PythonFileRunTool,
|
49
|
+
RemoveDirectoryTool,
|
50
|
+
RemoveFileTool,
|
51
|
+
ReplaceTextInFileTool,
|
52
|
+
RunBashCommandTool,
|
53
|
+
RunPowershellCommandTool,
|
54
|
+
GetFileOutlineTool,
|
55
|
+
SearchOutlineTool,
|
56
|
+
SearchTextTool,
|
57
|
+
ValidateFileSyntaxTool,
|
58
|
+
]:
|
59
|
+
local_tools_adapter.register_tool(tool_class)
|
60
|
+
|
61
|
+
# DEBUG: Print registered tools at startup
|
62
|
+
|