janito 3.14.1__py3-none-any.whl → 3.15.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 (38) hide show
  1. janito/platform_discovery.py +1 -8
  2. janito/plugins/tools/local/adapter.py +3 -2
  3. janito/plugins/tools/local/ask_user.py +111 -112
  4. janito/plugins/tools/local/copy_file.py +86 -87
  5. janito/plugins/tools/local/create_directory.py +111 -112
  6. janito/plugins/tools/local/create_file.py +0 -1
  7. janito/plugins/tools/local/delete_text_in_file.py +133 -134
  8. janito/plugins/tools/local/fetch_url.py +465 -466
  9. janito/plugins/tools/local/find_files.py +142 -143
  10. janito/plugins/tools/local/markdown_view.py +0 -1
  11. janito/plugins/tools/local/move_file.py +130 -131
  12. janito/plugins/tools/local/open_html_in_browser.py +50 -51
  13. janito/plugins/tools/local/open_url.py +36 -37
  14. janito/plugins/tools/local/python_code_run.py +171 -172
  15. janito/plugins/tools/local/python_command_run.py +170 -171
  16. janito/plugins/tools/local/python_file_run.py +171 -172
  17. janito/plugins/tools/local/read_chart.py +258 -259
  18. janito/plugins/tools/local/read_files.py +57 -58
  19. janito/plugins/tools/local/remove_directory.py +54 -55
  20. janito/plugins/tools/local/remove_file.py +57 -58
  21. janito/plugins/tools/local/replace_text_in_file.py +275 -276
  22. janito/plugins/tools/local/run_bash_command.py +182 -183
  23. janito/plugins/tools/local/run_powershell_command.py +217 -218
  24. janito/plugins/tools/local/show_image.py +0 -1
  25. janito/plugins/tools/local/show_image_grid.py +0 -1
  26. janito/plugins/tools/local/view_file.py +0 -1
  27. janito/providers/alibaba/provider.py +1 -1
  28. janito/providers/deepseek/model_info.py +16 -37
  29. janito/providers/deepseek/provider.py +4 -3
  30. janito/tools/base.py +19 -12
  31. janito/tools/tool_base.py +122 -121
  32. janito/tools/tools_schema.py +104 -104
  33. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/METADATA +9 -32
  34. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/RECORD +38 -38
  35. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/WHEEL +0 -0
  36. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/entry_points.txt +0 -0
  37. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/licenses/LICENSE +0 -0
  38. {janito-3.14.1.dist-info → janito-3.15.0.dist-info}/top_level.txt +0 -0
@@ -1,218 +1,217 @@
1
- from janito.tools.tool_base import ToolBase, ToolPermissions
2
- from janito.report_events import ReportAction
3
- from janito.plugins.tools.local.adapter import register_local_tool
4
- from janito.i18n import tr
5
- import subprocess
6
- import os
7
- from janito.tools.path_utils import expand_path
8
- import tempfile
9
- import threading
10
-
11
-
12
- @register_local_tool
13
- class RunPowershellCommandTool(ToolBase):
14
- """
15
- Execute a non-interactive command using the PowerShell shell and capture live output.
16
- This tool explicitly invokes 'powershell.exe' (on Windows) or 'pwsh' (on other platforms if available).
17
- All commands are automatically prepended with UTF-8 output encoding:
18
- $OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
19
- For file output, it is recommended to use -Encoding utf8 in your PowerShell commands (e.g., Out-File -Encoding utf8) to ensure correct file encoding.
20
-
21
- Args:
22
- command (str): The PowerShell command to execute. This string is passed directly to PowerShell using the --Command argument (not as a script file).
23
- timeout (int): Timeout in seconds for the command. Defaults to 60.
24
- require_confirmation (bool): If True, require user confirmation before running. Defaults to False.
25
- requires_user_input (bool): If True, warns that the command may require user input and might hang. Defaults to False. Non-interactive commands are preferred for automation and reliability.
26
- silent (bool): If True, suppresses progress and status messages. Defaults to False.
27
-
28
- Returns:
29
- str: Output and status message, or file paths/line counts if output is large.
30
- """
31
-
32
- permissions = ToolPermissions(execute=True)
33
- tool_name = "run_powershell_command"
34
-
35
- def _confirm_and_warn(self, command, require_confirmation, requires_user_input):
36
- if requires_user_input:
37
- self.report_warning(
38
- tr(
39
- "⚠️ Warning: This command might be interactive, require user input, and might hang."
40
- ),
41
- ReportAction.EXECUTE,
42
- )
43
- if require_confirmation:
44
- self.report_warning(
45
- tr("⚠️ Confirmation requested, but no handler (auto-confirmed)."),
46
- ReportAction.EXECUTE,
47
- )
48
- return True # Auto-confirm for now
49
- return True
50
-
51
- def _launch_process(self, shell_exe, command_with_encoding):
52
- env = os.environ.copy()
53
- env["PYTHONIOENCODING"] = "utf-8"
54
- return subprocess.Popen(
55
- [
56
- shell_exe,
57
- "-NoProfile",
58
- "-ExecutionPolicy",
59
- "Bypass",
60
- "-Command",
61
- command_with_encoding,
62
- ],
63
- stdout=subprocess.PIPE,
64
- stderr=subprocess.PIPE,
65
- text=True,
66
- bufsize=1,
67
- universal_newlines=True,
68
- encoding="utf-8",
69
- env=env,
70
- )
71
-
72
- def _stream_output(self, stream, file_obj, report_func, count_func, counter):
73
- for line in stream:
74
- file_obj.write(line)
75
- file_obj.flush()
76
- report_func(line.rstrip("\r\n"), ReportAction.EXECUTE)
77
- if count_func == "stdout":
78
- counter["stdout"] += 1
79
- else:
80
- counter["stderr"] += 1
81
-
82
- def _format_result(
83
- self, requires_user_input, return_code, stdout_file, stderr_file, max_lines=100
84
- ):
85
- warning_msg = ""
86
- if requires_user_input:
87
- warning_msg = tr(
88
- "⚠️ Warning: This command might be interactive, require user input, and might hang.\n"
89
- )
90
- with open(stdout_file.name, "r", encoding="utf-8", errors="replace") as out_f:
91
- stdout_content = out_f.read()
92
- with open(stderr_file.name, "r", encoding="utf-8", errors="replace") as err_f:
93
- stderr_content = err_f.read()
94
- stdout_lines = stdout_content.count("\n")
95
- stderr_lines = stderr_content.count("\n")
96
- if stdout_lines <= max_lines and stderr_lines <= max_lines:
97
- result = warning_msg + tr(
98
- "Return code: {return_code}\n--- STDOUT ---\n{stdout_content}",
99
- return_code=return_code,
100
- stdout_content=stdout_content,
101
- )
102
- if stderr_content.strip():
103
- result += tr(
104
- "\n--- STDERR ---\n{stderr_content}",
105
- stderr_content=stderr_content,
106
- )
107
- return result
108
- else:
109
- result = warning_msg + tr(
110
- "stdout_file: {stdout_file} (lines: {stdout_lines})\n",
111
- stdout_file=stdout_file.name,
112
- stdout_lines=stdout_lines,
113
- )
114
- if stderr_lines > 0 and stderr_content.strip():
115
- result += tr(
116
- "stderr_file: {stderr_file} (lines: {stderr_lines})\n",
117
- stderr_file=stderr_file.name,
118
- stderr_lines=stderr_lines,
119
- )
120
- result += tr(
121
- "returncode: {return_code}\nUse the view_file tool to inspect the contents of these files when needed.",
122
- return_code=return_code,
123
- )
124
- return result
125
-
126
- def run(
127
- self,
128
- command: str,
129
- timeout: int = 60,
130
- require_confirmation: bool = False,
131
- requires_user_input: bool = False,
132
- silent: bool = False,
133
- ) -> str:
134
- if not command.strip():
135
- self.report_warning(tr("ℹ️ Empty command provided."), ReportAction.EXECUTE)
136
- return tr("Warning: Empty command provided. Operation skipped.")
137
- encoding_prefix = "$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; "
138
- command_with_encoding = encoding_prefix + command
139
- if not silent:
140
- self.report_action(
141
- tr("🖥️ Running PowerShell command: {command} ...\n", command=command),
142
- ReportAction.EXECUTE,
143
- )
144
- else:
145
- self.report_action(tr("⚡ Executing..."), ReportAction.EXECUTE)
146
- self._confirm_and_warn(command, require_confirmation, requires_user_input)
147
- from janito.platform_discovery import PlatformDiscovery
148
-
149
- pd = PlatformDiscovery()
150
- shell_exe = "powershell.exe" if pd.is_windows() else "pwsh"
151
- try:
152
- with (
153
- tempfile.NamedTemporaryFile(
154
- mode="w+",
155
- prefix="run_powershell_stdout_",
156
- delete=False,
157
- encoding="utf-8",
158
- ) as stdout_file,
159
- tempfile.NamedTemporaryFile(
160
- mode="w+",
161
- prefix="run_powershell_stderr_",
162
- delete=False,
163
- encoding="utf-8",
164
- ) as stderr_file,
165
- ):
166
- process = self._launch_process(shell_exe, command_with_encoding)
167
- counter = {"stdout": 0, "stderr": 0}
168
- stdout_thread = threading.Thread(
169
- target=self._stream_output,
170
- args=(
171
- process.stdout,
172
- stdout_file,
173
- self.report_stdout,
174
- "stdout",
175
- counter,
176
- ),
177
- )
178
- stderr_thread = threading.Thread(
179
- target=self._stream_output,
180
- args=(
181
- process.stderr,
182
- stderr_file,
183
- self.report_stderr,
184
- "stderr",
185
- counter,
186
- ),
187
- )
188
- stdout_thread.start()
189
- stderr_thread.start()
190
- try:
191
- return_code = process.wait(timeout=timeout)
192
- except subprocess.TimeoutExpired:
193
- process.kill()
194
- self.report_error(
195
- tr(
196
- " ❌ Timed out after {timeout} seconds.",
197
- timeout=timeout,
198
- ),
199
- ReportAction.EXECUTE,
200
- )
201
- return tr(
202
- "Command timed out after {timeout} seconds.", timeout=timeout
203
- )
204
- stdout_thread.join()
205
- stderr_thread.join()
206
- stdout_file.flush()
207
- stderr_file.flush()
208
- if not silent:
209
- self.report_success(
210
- tr(" ✅ return code {return_code}", return_code=return_code),
211
- ReportAction.EXECUTE,
212
- )
213
- return self._format_result(
214
- requires_user_input, return_code, stdout_file, stderr_file
215
- )
216
- except Exception as e:
217
- self.report_error(tr(" Error: {error}", error=e), ReportAction.EXECUTE)
218
- return tr("Error running command: {error}", error=e)
1
+ from janito.tools.tool_base import ToolBase, ToolPermissions
2
+ from janito.report_events import ReportAction
3
+ from janito.plugins.tools.local.adapter import register_local_tool
4
+ from janito.i18n import tr
5
+ import subprocess
6
+ import os
7
+ from janito.tools.path_utils import expand_path
8
+ import tempfile
9
+ import threading
10
+
11
+
12
+ @register_local_tool
13
+ class RunPowershellCommandTool(ToolBase):
14
+ """
15
+ Execute a non-interactive command using the PowerShell shell and capture live output.
16
+ This tool explicitly invokes 'powershell.exe' (on Windows) or 'pwsh' (on other platforms if available).
17
+ All commands are automatically prepended with UTF-8 output encoding:
18
+ $OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
19
+ For file output, it is recommended to use -Encoding utf8 in your PowerShell commands (e.g., Out-File -Encoding utf8) to ensure correct file encoding.
20
+
21
+ Args:
22
+ command (str): The PowerShell command to execute. This string is passed directly to PowerShell using the --Command argument (not as a script file).
23
+ timeout (int): Timeout in seconds for the command. Defaults to 60.
24
+ require_confirmation (bool): If True, require user confirmation before running. Defaults to False.
25
+ requires_user_input (bool): If True, warns that the command may require user input and might hang. Defaults to False. Non-interactive commands are preferred for automation and reliability.
26
+ silent (bool): If True, suppresses progress and status messages. Defaults to False.
27
+
28
+ Returns:
29
+ str: Output and status message, or file paths/line counts if output is large.
30
+ """
31
+
32
+ permissions = ToolPermissions(execute=True)
33
+
34
+ def _confirm_and_warn(self, command, require_confirmation, requires_user_input):
35
+ if requires_user_input:
36
+ self.report_warning(
37
+ tr(
38
+ "⚠️ Warning: This command might be interactive, require user input, and might hang."
39
+ ),
40
+ ReportAction.EXECUTE,
41
+ )
42
+ if require_confirmation:
43
+ self.report_warning(
44
+ tr("⚠️ Confirmation requested, but no handler (auto-confirmed)."),
45
+ ReportAction.EXECUTE,
46
+ )
47
+ return True # Auto-confirm for now
48
+ return True
49
+
50
+ def _launch_process(self, shell_exe, command_with_encoding):
51
+ env = os.environ.copy()
52
+ env["PYTHONIOENCODING"] = "utf-8"
53
+ return subprocess.Popen(
54
+ [
55
+ shell_exe,
56
+ "-NoProfile",
57
+ "-ExecutionPolicy",
58
+ "Bypass",
59
+ "-Command",
60
+ command_with_encoding,
61
+ ],
62
+ stdout=subprocess.PIPE,
63
+ stderr=subprocess.PIPE,
64
+ text=True,
65
+ bufsize=1,
66
+ universal_newlines=True,
67
+ encoding="utf-8",
68
+ env=env,
69
+ )
70
+
71
+ def _stream_output(self, stream, file_obj, report_func, count_func, counter):
72
+ for line in stream:
73
+ file_obj.write(line)
74
+ file_obj.flush()
75
+ report_func(line.rstrip("\r\n"), ReportAction.EXECUTE)
76
+ if count_func == "stdout":
77
+ counter["stdout"] += 1
78
+ else:
79
+ counter["stderr"] += 1
80
+
81
+ def _format_result(
82
+ self, requires_user_input, return_code, stdout_file, stderr_file, max_lines=100
83
+ ):
84
+ warning_msg = ""
85
+ if requires_user_input:
86
+ warning_msg = tr(
87
+ "⚠️ Warning: This command might be interactive, require user input, and might hang.\n"
88
+ )
89
+ with open(stdout_file.name, "r", encoding="utf-8", errors="replace") as out_f:
90
+ stdout_content = out_f.read()
91
+ with open(stderr_file.name, "r", encoding="utf-8", errors="replace") as err_f:
92
+ stderr_content = err_f.read()
93
+ stdout_lines = stdout_content.count("\n")
94
+ stderr_lines = stderr_content.count("\n")
95
+ if stdout_lines <= max_lines and stderr_lines <= max_lines:
96
+ result = warning_msg + tr(
97
+ "Return code: {return_code}\n--- STDOUT ---\n{stdout_content}",
98
+ return_code=return_code,
99
+ stdout_content=stdout_content,
100
+ )
101
+ if stderr_content.strip():
102
+ result += tr(
103
+ "\n--- STDERR ---\n{stderr_content}",
104
+ stderr_content=stderr_content,
105
+ )
106
+ return result
107
+ else:
108
+ result = warning_msg + tr(
109
+ "stdout_file: {stdout_file} (lines: {stdout_lines})\n",
110
+ stdout_file=stdout_file.name,
111
+ stdout_lines=stdout_lines,
112
+ )
113
+ if stderr_lines > 0 and stderr_content.strip():
114
+ result += tr(
115
+ "stderr_file: {stderr_file} (lines: {stderr_lines})\n",
116
+ stderr_file=stderr_file.name,
117
+ stderr_lines=stderr_lines,
118
+ )
119
+ result += tr(
120
+ "returncode: {return_code}\nUse the view_file tool to inspect the contents of these files when needed.",
121
+ return_code=return_code,
122
+ )
123
+ return result
124
+
125
+ def run(
126
+ self,
127
+ command: str,
128
+ timeout: int = 60,
129
+ require_confirmation: bool = False,
130
+ requires_user_input: bool = False,
131
+ silent: bool = False,
132
+ ) -> str:
133
+ if not command.strip():
134
+ self.report_warning(tr("ℹ️ Empty command provided."), ReportAction.EXECUTE)
135
+ return tr("Warning: Empty command provided. Operation skipped.")
136
+ encoding_prefix = "$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; "
137
+ command_with_encoding = encoding_prefix + command
138
+ if not silent:
139
+ self.report_action(
140
+ tr("🖥️ Running PowerShell command: {command} ...\n", command=command),
141
+ ReportAction.EXECUTE,
142
+ )
143
+ else:
144
+ self.report_action(tr("⚡ Executing..."), ReportAction.EXECUTE)
145
+ self._confirm_and_warn(command, require_confirmation, requires_user_input)
146
+ from janito.platform_discovery import PlatformDiscovery
147
+
148
+ pd = PlatformDiscovery()
149
+ shell_exe = "powershell.exe" if pd.is_windows() else "pwsh"
150
+ try:
151
+ with (
152
+ tempfile.NamedTemporaryFile(
153
+ mode="w+",
154
+ prefix="run_powershell_stdout_",
155
+ delete=False,
156
+ encoding="utf-8",
157
+ ) as stdout_file,
158
+ tempfile.NamedTemporaryFile(
159
+ mode="w+",
160
+ prefix="run_powershell_stderr_",
161
+ delete=False,
162
+ encoding="utf-8",
163
+ ) as stderr_file,
164
+ ):
165
+ process = self._launch_process(shell_exe, command_with_encoding)
166
+ counter = {"stdout": 0, "stderr": 0}
167
+ stdout_thread = threading.Thread(
168
+ target=self._stream_output,
169
+ args=(
170
+ process.stdout,
171
+ stdout_file,
172
+ self.report_stdout,
173
+ "stdout",
174
+ counter,
175
+ ),
176
+ )
177
+ stderr_thread = threading.Thread(
178
+ target=self._stream_output,
179
+ args=(
180
+ process.stderr,
181
+ stderr_file,
182
+ self.report_stderr,
183
+ "stderr",
184
+ counter,
185
+ ),
186
+ )
187
+ stdout_thread.start()
188
+ stderr_thread.start()
189
+ try:
190
+ return_code = process.wait(timeout=timeout)
191
+ except subprocess.TimeoutExpired:
192
+ process.kill()
193
+ self.report_error(
194
+ tr(
195
+ " ❌ Timed out after {timeout} seconds.",
196
+ timeout=timeout,
197
+ ),
198
+ ReportAction.EXECUTE,
199
+ )
200
+ return tr(
201
+ "Command timed out after {timeout} seconds.", timeout=timeout
202
+ )
203
+ stdout_thread.join()
204
+ stderr_thread.join()
205
+ stdout_file.flush()
206
+ stderr_file.flush()
207
+ if not silent:
208
+ self.report_success(
209
+ tr(" ✅ return code {return_code}", return_code=return_code),
210
+ ReportAction.EXECUTE,
211
+ )
212
+ return self._format_result(
213
+ requires_user_input, return_code, stdout_file, stderr_file
214
+ )
215
+ except Exception as e:
216
+ self.report_error(tr(" Error: {error}", error=e), ReportAction.EXECUTE)
217
+ return tr("Error running command: {error}", error=e)
@@ -20,7 +20,6 @@ class ShowImageTool(ToolBase):
20
20
  """
21
21
 
22
22
  permissions = ToolPermissions(read=True)
23
- tool_name = "show_image"
24
23
 
25
24
  @protect_against_loops(max_calls=5, time_window=10.0, key_field="path")
26
25
  def run(
@@ -22,7 +22,6 @@ class ShowImageGridTool(ToolBase):
22
22
  """
23
23
 
24
24
  permissions = ToolPermissions(read=True)
25
- tool_name = "show_image_grid"
26
25
 
27
26
  @protect_against_loops(max_calls=5, time_window=10.0, key_field="paths")
28
27
  def run(
@@ -29,7 +29,6 @@ class ViewFileTool(ToolBase):
29
29
  """
30
30
 
31
31
  permissions = ToolPermissions(read=True)
32
- tool_name = "view_file"
33
32
 
34
33
  @protect_against_loops(max_calls=5, time_window=10.0, key_field="path")
35
34
  def run(self, path: str, from_line: int = None, to_line: int = None, as_base64: bool = False) -> str:
@@ -19,7 +19,7 @@ class AlibabaProvider(LLMProvider):
19
19
  NAME = "alibaba" # For backward compatibility
20
20
  MAINTAINER = "João Pinto <janito@ikignosis.org>"
21
21
  MODEL_SPECS = MODEL_SPECS
22
- DEFAULT_MODEL = "qwen3-next-80b-a3b-instruct" # 256k context, latest Qwen3 Next model
22
+ DEFAULT_MODEL = "qwen3-max-preview" # 256k context, Qwen3 Max Preview standard model
23
23
  available = OpenAIModelDriver.available
24
24
  unavailable_reason = OpenAIModelDriver.unavailable_reason
25
25
 
@@ -1,37 +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
- "deepseek-v3.1": {
17
- "description": "DeepSeek V3.1 Model (128K context, OpenAI-compatible)",
18
- "context_window": 131072,
19
- "max_tokens": 4096,
20
- "family": "deepseek",
21
- "default": False,
22
- },
23
- "deepseek-v3.1-base": {
24
- "description": "DeepSeek V3.1 Base Model (128K context, OpenAI-compatible)",
25
- "context_window": 131072,
26
- "max_tokens": 4096,
27
- "family": "deepseek",
28
- "default": False,
29
- },
30
- "deepseek-r1": {
31
- "description": "DeepSeek R1 Model (128K context, OpenAI-compatible)",
32
- "context_window": 131072,
33
- "max_tokens": 4096,
34
- "family": "deepseek",
35
- "default": False,
36
- },
37
- }
1
+ from janito.llm.model import LLMModelInfo
2
+
3
+ MODEL_SPECS = {
4
+ "deepseek-chat": LLMModelInfo(
5
+ name="deepseek-chat",
6
+ context=131072, # 128K context
7
+ max_response=4096, # Default 4K, Maximum 8K
8
+ driver="OpenAIModelDriver",
9
+ ),
10
+ "deepseek-reasoner": LLMModelInfo(
11
+ name="deepseek-reasoner",
12
+ context=131072, # 128K context
13
+ max_response=32768, # Default 32K, Maximum 64K
14
+ driver="OpenAIModelDriver",
15
+ ),
16
+ }
@@ -19,7 +19,7 @@ class DeepSeekProvider(LLMProvider):
19
19
  NAME = "deepseek" # For backward compatibility
20
20
  MAINTAINER = "João Pinto <janito@ikignosis.org>"
21
21
  MODEL_SPECS = MODEL_SPECS
22
- DEFAULT_MODEL = "deepseek-chat" # Options: deepseek-chat, deepseek-reasoner, deepseek-v3.1, deepseek-v3.1-base, deepseek-r1
22
+ DEFAULT_MODEL = "deepseek-chat" # Options: deepseek-chat, deepseek-reasoner
23
23
  available = OpenAIModelDriver.available
24
24
  unavailable_reason = OpenAIModelDriver.unavailable_reason
25
25
 
@@ -51,7 +51,6 @@ class DeepSeekProvider(LLMProvider):
51
51
  if not getattr(self.config, "base_url", None):
52
52
  self.config.base_url = "https://api.deepseek.com/v1"
53
53
 
54
- @property
55
54
  def create_driver(self) -> OpenAIModelDriver:
56
55
  """
57
56
  Create and return a new OpenAIModelDriver instance for DeepSeek.
@@ -75,4 +74,6 @@ class DeepSeekProvider(LLMProvider):
75
74
  return self.tools_adapter.execute_by_name(tool_name, *args, **kwargs)
76
75
 
77
76
 
78
- # Registration handled by providers/__init__.py to avoid circular imports
77
+ # Registration
78
+ from janito.providers.registry import LLMProviderRegistry
79
+ LLMProviderRegistry.register(DeepSeekProvider.name, DeepSeekProvider)
janito/tools/base.py CHANGED
@@ -1,12 +1,19 @@
1
- class BaseTool:
2
- """Base class for all tools."""
3
-
4
- tool_name: str = ""
5
-
6
- def __init__(self):
7
- if not self.tool_name:
8
- self.tool_name = self.__class__.__name__.lower()
9
-
10
- def run(self, *args, **kwargs) -> str:
11
- """Execute the tool."""
12
- raise NotImplementedError
1
+ class BaseTool:
2
+ """Base class for all tools."""
3
+
4
+ @property
5
+ def tool_name(self) -> str:
6
+ """Derive tool name from class name by convention."""
7
+ # Convert class name to snake_case and remove 'tool' suffix if present
8
+ class_name = self.__class__.__name__
9
+ if class_name.endswith('Tool'):
10
+ class_name = class_name[:-4]
11
+
12
+ # Convert CamelCase to snake_case
13
+ import re
14
+ name = re.sub(r'(?<!^)(?=[A-Z])', '_', class_name).lower()
15
+ return name
16
+
17
+ def run(self, *args, **kwargs) -> str:
18
+ """Execute the tool."""
19
+ raise NotImplementedError