janito 2.2.0__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 -0
- 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 +1 -0
- 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 +165 -148
- 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 +176 -158
- 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 +30 -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/provider_static_info.py +2 -3
- janito/tools/adapters/__init__.py +1 -1
- 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 -138
- janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
- janito/tools/adapters/local/get_file_outline/core.py +117 -117
- janito/tools/adapters/local/get_file_outline/java_outline.py +40 -40
- 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/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 +4 -10
- 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.2.0.dist-info → janito-2.3.0.dist-info}/METADATA +388 -251
- janito-2.3.0.dist-info/RECORD +181 -0
- janito/drivers/google_genai/driver.py +0 -54
- janito/drivers/google_genai/schema_generator.py +0 -67
- janito-2.2.0.dist-info/RECORD +0 -182
- {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
- {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
- {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/licenses/LICENSE +0 -0
- {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -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
|
@@ -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
|
},
|
@@ -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.
|
@@ -3,20 +3,35 @@ from janito.tools.tools_adapter import ToolsAdapterBase as ToolsAdapter
|
|
3
3
|
|
4
4
|
|
5
5
|
class LocalToolsAdapter(ToolsAdapter):
|
6
|
-
def
|
7
|
-
"""
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def set_execution_tools_enabled(self, enabled: bool):
|
7
|
+
"""
|
8
|
+
Dynamically include or exclude execution tools from the enabled_tools set.
|
9
|
+
If enabled_tools is None, all tools are enabled (default). If set, restricts enabled tools.
|
10
|
+
"""
|
11
|
+
all_tool_names = set(self._tools.keys())
|
12
|
+
exec_tool_names = {
|
13
|
+
name for name, entry in self._tools.items()
|
14
|
+
if getattr(entry["instance"], "provides_execution", False)
|
15
|
+
}
|
16
|
+
if self._enabled_tools is None:
|
17
|
+
# If not restricted, create a new enabled-tools set excluding execution tools if disabling
|
18
|
+
if enabled:
|
19
|
+
self._enabled_tools = None # all tools enabled
|
20
|
+
else:
|
21
|
+
self._enabled_tools = all_tool_names - exec_tool_names
|
22
|
+
else:
|
23
|
+
if enabled:
|
24
|
+
self._enabled_tools |= exec_tool_names
|
25
|
+
else:
|
26
|
+
self._enabled_tools -= exec_tool_names
|
12
27
|
|
13
28
|
"""
|
14
29
|
Adapter for local, statically registered tools in the agent/tools system.
|
15
30
|
Handles registration, lookup, enabling/disabling, listing, and now, tool execution (merged from executor).
|
16
31
|
"""
|
17
32
|
|
18
|
-
def __init__(self, tools=None, event_bus=None,
|
19
|
-
super().__init__(tools=tools, event_bus=event_bus,
|
33
|
+
def __init__(self, tools=None, event_bus=None, enabled_tools=None, workdir=None):
|
34
|
+
super().__init__(tools=tools, event_bus=event_bus, enabled_tools=enabled_tools)
|
20
35
|
self._tools: Dict[str, Dict[str, Any]] = {}
|
21
36
|
self.workdir = workdir
|
22
37
|
if self.workdir:
|
@@ -56,13 +71,19 @@ class LocalToolsAdapter(ToolsAdapter):
|
|
56
71
|
return self._tools[name]["instance"] if name in self._tools else None
|
57
72
|
|
58
73
|
def list_tools(self):
|
59
|
-
|
74
|
+
if self._enabled_tools is None:
|
75
|
+
return list(self._tools.keys())
|
76
|
+
return [name for name in self._tools.keys() if name in self._enabled_tools]
|
60
77
|
|
61
78
|
def get_tool_classes(self):
|
62
|
-
|
79
|
+
if self._enabled_tools is None:
|
80
|
+
return [entry["class"] for entry in self._tools.values()]
|
81
|
+
return [entry["class"] for name, entry in self._tools.items() if name in self._enabled_tools]
|
63
82
|
|
64
83
|
def get_tools(self):
|
65
|
-
|
84
|
+
if self._enabled_tools is None:
|
85
|
+
return [entry["instance"] for entry in self._tools.values()]
|
86
|
+
return [entry["instance"] for name, entry in self._tools.items() if name in self._enabled_tools]
|
66
87
|
|
67
88
|
|
68
89
|
def add_tool(self, tool):
|
@@ -94,3 +115,4 @@ def register_local_tool(tool=None):
|
|
94
115
|
if tool is None:
|
95
116
|
return decorator
|
96
117
|
return decorator(tool)
|
118
|
+
|