mojentic 0.9.0__py3-none-any.whl → 1.0.1__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.
- _examples/async_dispatcher_example.py +12 -4
- _examples/async_llm_example.py +1 -2
- _examples/broker_as_tool.py +39 -14
- _examples/broker_examples.py +4 -6
- _examples/characterize_ollama.py +1 -1
- _examples/characterize_openai.py +1 -1
- _examples/chat_session.py +1 -1
- _examples/chat_session_with_tool.py +1 -1
- _examples/coding_file_tool.py +1 -3
- _examples/current_datetime_tool_example.py +1 -1
- _examples/embeddings.py +1 -1
- _examples/ephemeral_task_manager_example.py +13 -9
- _examples/fetch_openai_models.py +10 -3
- _examples/file_deduplication.py +6 -6
- _examples/image_analysis.py +2 -3
- _examples/image_broker.py +1 -1
- _examples/image_broker_splat.py +1 -1
- _examples/iterative_solver.py +2 -2
- _examples/model_characterization.py +2 -0
- _examples/openai_gateway_enhanced_demo.py +15 -5
- _examples/raw.py +1 -1
- _examples/react/agents/decisioning_agent.py +173 -15
- _examples/react/agents/summarization_agent.py +89 -0
- _examples/react/agents/thinking_agent.py +84 -14
- _examples/react/agents/tool_call_agent.py +83 -0
- _examples/react/formatters.py +38 -4
- _examples/react/models/base.py +60 -11
- _examples/react/models/events.py +76 -8
- _examples/react.py +71 -21
- _examples/recursive_agent.py +1 -1
- _examples/solver_chat_session.py +1 -7
- _examples/streaming.py +7 -5
- _examples/tell_user_example.py +3 -3
- _examples/tracer_demo.py +15 -17
- _examples/tracer_qt_viewer.py +49 -46
- mojentic/__init__.py +3 -3
- mojentic/agents/__init__.py +26 -8
- mojentic/agents/{agent_broker.py → agent_event_adapter.py} +3 -3
- mojentic/agents/async_aggregator_agent_spec.py +32 -33
- mojentic/agents/async_llm_agent.py +9 -5
- mojentic/agents/async_llm_agent_spec.py +21 -22
- mojentic/agents/base_async_agent.py +2 -2
- mojentic/agents/base_llm_agent.py +6 -2
- mojentic/agents/iterative_problem_solver.py +11 -5
- mojentic/agents/simple_recursive_agent.py +11 -10
- mojentic/agents/simple_recursive_agent_spec.py +423 -0
- mojentic/async_dispatcher.py +0 -1
- mojentic/async_dispatcher_spec.py +1 -1
- mojentic/context/__init__.py +0 -2
- mojentic/dispatcher.py +7 -8
- mojentic/llm/__init__.py +5 -5
- mojentic/llm/chat_session.py +24 -1
- mojentic/llm/chat_session_spec.py +40 -0
- mojentic/llm/gateways/__init__.py +19 -18
- mojentic/llm/gateways/anthropic.py +1 -0
- mojentic/llm/gateways/anthropic_messages_adapter.py +0 -1
- mojentic/llm/gateways/llm_gateway.py +1 -1
- mojentic/llm/gateways/ollama.py +2 -0
- mojentic/llm/gateways/openai.py +62 -58
- mojentic/llm/gateways/openai_message_adapter_spec.py +3 -3
- mojentic/llm/gateways/openai_model_registry.py +7 -6
- mojentic/llm/gateways/openai_model_registry_spec.py +1 -2
- mojentic/llm/gateways/openai_temperature_handling_spec.py +2 -2
- mojentic/llm/llm_broker.py +7 -5
- mojentic/llm/llm_broker_spec.py +7 -2
- mojentic/llm/message_composers.py +6 -3
- mojentic/llm/message_composers_spec.py +5 -1
- mojentic/llm/registry/__init__.py +0 -3
- mojentic/llm/tools/__init__.py +0 -9
- mojentic/llm/tools/ask_user_tool.py +11 -5
- mojentic/llm/tools/current_datetime.py +9 -6
- mojentic/llm/tools/date_resolver.py +10 -4
- mojentic/llm/tools/date_resolver_spec.py +0 -1
- mojentic/llm/tools/ephemeral_task_manager/append_task_tool.py +4 -1
- mojentic/llm/tools/ephemeral_task_manager/ephemeral_task_list.py +1 -1
- mojentic/llm/tools/ephemeral_task_manager/insert_task_after_tool.py +4 -1
- mojentic/llm/tools/ephemeral_task_manager/prepend_task_tool.py +5 -2
- mojentic/llm/tools/file_manager.py +131 -28
- mojentic/llm/tools/file_manager_spec.py +0 -3
- mojentic/llm/tools/llm_tool.py +1 -1
- mojentic/llm/tools/llm_tool_spec.py +0 -2
- mojentic/llm/tools/organic_web_search.py +4 -2
- mojentic/llm/tools/tell_user_tool.py +6 -2
- mojentic/llm/tools/tool_wrapper.py +2 -2
- mojentic/tracer/__init__.py +1 -10
- mojentic/tracer/event_store.py +7 -8
- mojentic/tracer/event_store_spec.py +1 -2
- mojentic/tracer/null_tracer.py +37 -43
- mojentic/tracer/tracer_events.py +8 -2
- mojentic/tracer/tracer_events_spec.py +6 -7
- mojentic/tracer/tracer_system.py +37 -36
- mojentic/tracer/tracer_system_spec.py +21 -6
- mojentic/utils/__init__.py +1 -1
- mojentic/utils/formatting.py +1 -0
- {mojentic-0.9.0.dist-info → mojentic-1.0.1.dist-info}/METADATA +47 -29
- mojentic-1.0.1.dist-info/RECORD +149 -0
- {mojentic-0.9.0.dist-info → mojentic-1.0.1.dist-info}/WHEEL +1 -1
- mojentic-0.9.0.dist-info/RECORD +0 -146
- {mojentic-0.9.0.dist-info → mojentic-1.0.1.dist-info}/licenses/LICENSE.md +0 -0
- {mojentic-0.9.0.dist-info → mojentic-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -12,7 +12,7 @@ class FileTypeSensor:
|
|
|
12
12
|
"""
|
|
13
13
|
Initialize the TypeSensor with a default mapping of file extensions to language declarations.
|
|
14
14
|
|
|
15
|
-
The TypeSensor is used to determine the appropriate language syntax highlighting
|
|
15
|
+
The TypeSensor is used to determine the appropriate language syntax highlighting
|
|
16
16
|
for code blocks in markdown based on file extensions.
|
|
17
17
|
"""
|
|
18
18
|
self.extension_map: Dict[str, str] = {
|
|
@@ -129,7 +129,6 @@ class MessageBuilder():
|
|
|
129
129
|
f"{content.strip()}\n"
|
|
130
130
|
f"```\n")
|
|
131
131
|
|
|
132
|
-
|
|
133
132
|
def add_image(self, image_path: Union[str, Path]) -> "MessageBuilder":
|
|
134
133
|
"""
|
|
135
134
|
Add a single image to the message.
|
|
@@ -253,7 +252,11 @@ class MessageBuilder():
|
|
|
253
252
|
|
|
254
253
|
return self
|
|
255
254
|
|
|
256
|
-
def load_content(
|
|
255
|
+
def load_content(
|
|
256
|
+
self,
|
|
257
|
+
file_path: Union[str, Path],
|
|
258
|
+
template_values: Optional[Dict[str, Union[str, Path]]] = None
|
|
259
|
+
) -> "MessageBuilder":
|
|
257
260
|
"""
|
|
258
261
|
Load content from a file into the content field of the MessageBuilder.
|
|
259
262
|
|
|
@@ -14,10 +14,12 @@ def file_gateway(mocker):
|
|
|
14
14
|
file_gateway.is_binary.return_value = False
|
|
15
15
|
return file_gateway
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
@pytest.fixture
|
|
18
19
|
def file_path():
|
|
19
20
|
return Path("/path/to/file.txt")
|
|
20
21
|
|
|
22
|
+
|
|
21
23
|
@pytest.fixture
|
|
22
24
|
def whitespace_file_content():
|
|
23
25
|
return "\n\n \n test file content with whitespace \n\n \n"
|
|
@@ -122,7 +124,9 @@ class DescribeMessageBuilder:
|
|
|
122
124
|
assert "test file content" in result
|
|
123
125
|
assert "```" in result
|
|
124
126
|
|
|
125
|
-
def should_strip_whitespace_from_file_content(
|
|
127
|
+
def should_strip_whitespace_from_file_content(
|
|
128
|
+
self, message_builder, file_gateway, file_path, whitespace_file_content, mocker
|
|
129
|
+
):
|
|
126
130
|
# Use the fixtures instead of creating file path and content directly
|
|
127
131
|
file_gateway.read.return_value = whitespace_file_content
|
|
128
132
|
mocker.patch.object(message_builder.type_sensor, 'get_language', return_value='text')
|
mojentic/llm/tools/__init__.py
CHANGED
|
@@ -3,16 +3,7 @@ Mojentic LLM tools module for extending LLM capabilities.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
# Base tool class
|
|
6
|
-
from .llm_tool import LLMTool
|
|
7
|
-
from .tool_wrapper import ToolWrapper
|
|
8
6
|
|
|
9
7
|
# Common tools
|
|
10
|
-
from .ask_user_tool import AskUserTool
|
|
11
|
-
from .current_datetime import CurrentDateTimeTool
|
|
12
|
-
from .date_resolver import ResolveDateTool
|
|
13
|
-
from .organic_web_search import OrganicWebSearchTool
|
|
14
|
-
from .tell_user_tool import TellUserTool
|
|
15
8
|
|
|
16
9
|
# Import tool modules
|
|
17
|
-
from . import file_manager
|
|
18
|
-
from . import ephemeral_task_manager
|
|
@@ -3,8 +3,8 @@ from mojentic.llm.tools.llm_tool import LLMTool
|
|
|
3
3
|
|
|
4
4
|
class AskUserTool(LLMTool):
|
|
5
5
|
def run(self, user_request: str) -> str:
|
|
6
|
-
print(
|
|
7
|
-
return input(
|
|
6
|
+
print("\n\n\nI NEED YOUR HELP!\n{user_request}")
|
|
7
|
+
return input("Your response: ")
|
|
8
8
|
|
|
9
9
|
@property
|
|
10
10
|
def descriptor(self):
|
|
@@ -12,16 +12,22 @@ class AskUserTool(LLMTool):
|
|
|
12
12
|
"type": "function",
|
|
13
13
|
"function": {
|
|
14
14
|
"name": "ask_user",
|
|
15
|
-
"description":
|
|
15
|
+
"description": (
|
|
16
|
+
"If you do not know how to proceed, ask the user a question, or ask them for "
|
|
17
|
+
"help or to do something for you."
|
|
18
|
+
),
|
|
16
19
|
"parameters": {
|
|
17
20
|
"type": "object",
|
|
18
21
|
"properties": {
|
|
19
22
|
"user_request": {
|
|
20
23
|
"type": "string",
|
|
21
|
-
"description":
|
|
24
|
+
"description": (
|
|
25
|
+
"The question you need the user to answer, or the task you need the user to "
|
|
26
|
+
"do for you."
|
|
27
|
+
)
|
|
22
28
|
}
|
|
23
29
|
},
|
|
24
30
|
"required": ["user_request"]
|
|
25
31
|
},
|
|
26
32
|
},
|
|
27
|
-
}
|
|
33
|
+
}
|
|
@@ -6,12 +6,12 @@ class CurrentDateTimeTool(LLMTool):
|
|
|
6
6
|
def run(self, format_string: str = "%Y-%m-%d %H:%M:%S") -> dict:
|
|
7
7
|
"""
|
|
8
8
|
Returns the current date and time.
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
Parameters
|
|
11
11
|
----------
|
|
12
12
|
format_string : str, optional
|
|
13
13
|
The format string for the datetime, by default "%Y-%m-%d %H:%M:%S"
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
Returns
|
|
16
16
|
-------
|
|
17
17
|
dict
|
|
@@ -19,13 +19,13 @@ class CurrentDateTimeTool(LLMTool):
|
|
|
19
19
|
"""
|
|
20
20
|
current_time = datetime.now()
|
|
21
21
|
formatted_time = current_time.strftime(format_string)
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
return {
|
|
24
24
|
"current_datetime": formatted_time,
|
|
25
25
|
"timestamp": current_time.timestamp(),
|
|
26
26
|
"timezone": datetime.now().astimezone().tzname()
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
@property
|
|
30
30
|
def descriptor(self):
|
|
31
31
|
return {
|
|
@@ -38,10 +38,13 @@ class CurrentDateTimeTool(LLMTool):
|
|
|
38
38
|
"properties": {
|
|
39
39
|
"format_string": {
|
|
40
40
|
"type": "string",
|
|
41
|
-
"description":
|
|
41
|
+
"description": (
|
|
42
|
+
"Format string for the datetime (e.g., '%Y-%m-%d %H:%M:%S', '%A, %B %d, %Y'). "
|
|
43
|
+
"Default is ISO format."
|
|
44
|
+
)
|
|
42
45
|
}
|
|
43
46
|
},
|
|
44
47
|
"required": []
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
}
|
|
50
|
+
}
|
|
@@ -7,7 +7,7 @@ from mojentic.llm.tools.llm_tool import LLMTool
|
|
|
7
7
|
|
|
8
8
|
# Avoid circular imports with TYPE_CHECKING
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
|
-
|
|
10
|
+
pass
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ResolveDateTool(LLMTool):
|
|
@@ -34,7 +34,10 @@ class ResolveDateTool(LLMTool):
|
|
|
34
34
|
"type": "function",
|
|
35
35
|
"function": {
|
|
36
36
|
"name": "resolve_date",
|
|
37
|
-
"description":
|
|
37
|
+
"description": (
|
|
38
|
+
"Take text that specifies a relative date, and output an absolute date. If no "
|
|
39
|
+
"reference date is available, the current date is used."
|
|
40
|
+
),
|
|
38
41
|
"parameters": {
|
|
39
42
|
"type": "object",
|
|
40
43
|
"properties": {
|
|
@@ -44,8 +47,11 @@ class ResolveDateTool(LLMTool):
|
|
|
44
47
|
},
|
|
45
48
|
"reference_date_in_iso8601": {
|
|
46
49
|
"type": "string",
|
|
47
|
-
"description":
|
|
48
|
-
|
|
50
|
+
"description": (
|
|
51
|
+
"The date from which the resolved date should be calculated, in YYYY-MM-DD "
|
|
52
|
+
"format. Do not provide if you weren't provided one, I will assume the "
|
|
53
|
+
"current date."
|
|
54
|
+
)
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
"additionalProperties": False,
|
|
@@ -61,7 +61,10 @@ class AppendTaskTool(LLMTool):
|
|
|
61
61
|
"type": "function",
|
|
62
62
|
"function": {
|
|
63
63
|
"name": "append_task",
|
|
64
|
-
"description":
|
|
64
|
+
"description": (
|
|
65
|
+
"Append a new task to the end of the task list with a description. The task will "
|
|
66
|
+
"start with 'pending' status."
|
|
67
|
+
),
|
|
65
68
|
"parameters": {
|
|
66
69
|
"type": "object",
|
|
67
70
|
"properties": {
|
|
@@ -64,7 +64,10 @@ class InsertTaskAfterTool(LLMTool):
|
|
|
64
64
|
"type": "function",
|
|
65
65
|
"function": {
|
|
66
66
|
"name": "insert_task_after",
|
|
67
|
-
"description":
|
|
67
|
+
"description": (
|
|
68
|
+
"Insert a new task after an existing task in the task list. The task will start with "
|
|
69
|
+
"'pending' status."
|
|
70
|
+
),
|
|
68
71
|
"parameters": {
|
|
69
72
|
"type": "object",
|
|
70
73
|
"properties": {
|
|
@@ -61,7 +61,10 @@ class PrependTaskTool(LLMTool):
|
|
|
61
61
|
"type": "function",
|
|
62
62
|
"function": {
|
|
63
63
|
"name": "prepend_task",
|
|
64
|
-
"description":
|
|
64
|
+
"description": (
|
|
65
|
+
"Prepend a new task to the beginning of the task list with a description. The task "
|
|
66
|
+
"will start with 'pending' status."
|
|
67
|
+
),
|
|
65
68
|
"parameters": {
|
|
66
69
|
"type": "object",
|
|
67
70
|
"properties": {
|
|
@@ -74,4 +77,4 @@ class PrependTaskTool(LLMTool):
|
|
|
74
77
|
"additionalProperties": False
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
}
|
|
80
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
import glob
|
|
4
|
-
import difflib
|
|
5
4
|
|
|
6
5
|
from mojentic.llm.tools.llm_tool import LLMTool
|
|
7
6
|
|
|
@@ -93,7 +92,6 @@ class FilesystemGateway:
|
|
|
93
92
|
|
|
94
93
|
return matching_lines
|
|
95
94
|
|
|
96
|
-
|
|
97
95
|
def edit_file_with_diff(self, path: str, file_name: str, diff: str) -> str:
|
|
98
96
|
"""Edit a file by applying a diff to it."""
|
|
99
97
|
resolved_path = self._resolve_path(path)
|
|
@@ -150,14 +148,14 @@ class FilesystemGateway:
|
|
|
150
148
|
match = re.match(r'@@ -(\d+) \+(\d+) @@', line)
|
|
151
149
|
if match:
|
|
152
150
|
start_line = int(match.group(1))
|
|
153
|
-
|
|
151
|
+
int(match.group(2))
|
|
154
152
|
else:
|
|
155
153
|
# Skip invalid hunk header
|
|
156
154
|
i += 1
|
|
157
155
|
continue
|
|
158
156
|
else:
|
|
159
157
|
start_line = int(match.group(1))
|
|
160
|
-
|
|
158
|
+
int(match.group(3))
|
|
161
159
|
|
|
162
160
|
# Line numbers in diff are 1-based, but our array is 0-based
|
|
163
161
|
start_line -= 1
|
|
@@ -308,17 +306,29 @@ class ListFilesTool(LLMTool):
|
|
|
308
306
|
"type": "function",
|
|
309
307
|
"function": {
|
|
310
308
|
"name": "list_files",
|
|
311
|
-
"description":
|
|
309
|
+
"description": (
|
|
310
|
+
"List files in the specified directory (non-recursive), optionally filtered by extension. "
|
|
311
|
+
"Use this when you need to see what files are available in a specific directory without "
|
|
312
|
+
"including subdirectories."
|
|
313
|
+
),
|
|
312
314
|
"parameters": {
|
|
313
315
|
"type": "object",
|
|
314
316
|
"properties": {
|
|
315
317
|
"path": {
|
|
316
318
|
"type": "string",
|
|
317
|
-
"description":
|
|
319
|
+
"description": (
|
|
320
|
+
"The path relative to the sandbox root to list files from. For example, '.' for "
|
|
321
|
+
"the root directory, 'src' for the src directory, or 'docs/images' for a nested "
|
|
322
|
+
"directory."
|
|
323
|
+
)
|
|
318
324
|
},
|
|
319
325
|
"extension": {
|
|
320
326
|
"type": "string",
|
|
321
|
-
"description":
|
|
327
|
+
"description": (
|
|
328
|
+
"The file extension to filter by (e.g., '.py', '.txt', '.md'). If not provided, "
|
|
329
|
+
"all files will be listed. For example, using '.py' will only list Python files "
|
|
330
|
+
"in the directory."
|
|
331
|
+
)
|
|
322
332
|
}
|
|
323
333
|
},
|
|
324
334
|
"additionalProperties": False,
|
|
@@ -356,13 +366,20 @@ class ReadFileTool(LLMTool):
|
|
|
356
366
|
"type": "function",
|
|
357
367
|
"function": {
|
|
358
368
|
"name": "read_file",
|
|
359
|
-
"description":
|
|
369
|
+
"description": (
|
|
370
|
+
"Read the entire content of a file as a string. Use this when you need to access or "
|
|
371
|
+
"analyze the complete contents of a file."
|
|
372
|
+
),
|
|
360
373
|
"parameters": {
|
|
361
374
|
"type": "object",
|
|
362
375
|
"properties": {
|
|
363
376
|
"path": {
|
|
364
377
|
"type": "string",
|
|
365
|
-
"description":
|
|
378
|
+
"description": (
|
|
379
|
+
"The full relative path including the filename of the file to read. For example, "
|
|
380
|
+
"'README.md' for a file in the root directory, 'src/main.py' for a file in the "
|
|
381
|
+
"src directory, or 'docs/images/diagram.png' for a file in a nested directory."
|
|
382
|
+
)
|
|
366
383
|
}
|
|
367
384
|
},
|
|
368
385
|
"additionalProperties": False,
|
|
@@ -399,17 +416,29 @@ class WriteFileTool(LLMTool):
|
|
|
399
416
|
"type": "function",
|
|
400
417
|
"function": {
|
|
401
418
|
"name": "write_file",
|
|
402
|
-
"description":
|
|
419
|
+
"description": (
|
|
420
|
+
"Write content to a file, completely overwriting any existing content. Use this when you "
|
|
421
|
+
"want to replace the entire contents of a file with new content."
|
|
422
|
+
),
|
|
403
423
|
"parameters": {
|
|
404
424
|
"type": "object",
|
|
405
425
|
"properties": {
|
|
406
426
|
"path": {
|
|
407
427
|
"type": "string",
|
|
408
|
-
"description":
|
|
428
|
+
"description": (
|
|
429
|
+
"The full relative path including the filename where the file should be written. "
|
|
430
|
+
"For example, 'output.txt' for a file in the root directory, 'src/main.py' for "
|
|
431
|
+
"a file in the src directory, or 'docs/images/diagram.png' for a file in a "
|
|
432
|
+
"nested directory."
|
|
433
|
+
)
|
|
409
434
|
},
|
|
410
435
|
"content": {
|
|
411
436
|
"type": "string",
|
|
412
|
-
"description":
|
|
437
|
+
"description": (
|
|
438
|
+
"The content to write to the file. This will completely replace any existing "
|
|
439
|
+
"content in the file. For example, 'Hello, world!' for a simple text file, or a "
|
|
440
|
+
"JSON string for a configuration file."
|
|
441
|
+
)
|
|
413
442
|
}
|
|
414
443
|
},
|
|
415
444
|
"additionalProperties": False,
|
|
@@ -441,13 +470,22 @@ class ListAllFilesTool(LLMTool):
|
|
|
441
470
|
"type": "function",
|
|
442
471
|
"function": {
|
|
443
472
|
"name": "list_all_files",
|
|
444
|
-
"description":
|
|
473
|
+
"description": (
|
|
474
|
+
"List all files recursively in the specified directory, including files in "
|
|
475
|
+
"subdirectories. Use this when you need a complete inventory of all files in a "
|
|
476
|
+
"directory and its subdirectories."
|
|
477
|
+
),
|
|
445
478
|
"parameters": {
|
|
446
479
|
"type": "object",
|
|
447
480
|
"properties": {
|
|
448
481
|
"path": {
|
|
449
482
|
"type": "string",
|
|
450
|
-
"description":
|
|
483
|
+
"description": (
|
|
484
|
+
"The path relative to the sandbox root to list files from recursively. For "
|
|
485
|
+
"example, '.' for the root directory and all subdirectories, 'src' for the src "
|
|
486
|
+
"directory and all its subdirectories, or 'docs/images' for a nested directory "
|
|
487
|
+
"and its subdirectories."
|
|
488
|
+
)
|
|
451
489
|
}
|
|
452
490
|
},
|
|
453
491
|
"additionalProperties": False,
|
|
@@ -479,17 +517,30 @@ class FindFilesByGlobTool(LLMTool):
|
|
|
479
517
|
"type": "function",
|
|
480
518
|
"function": {
|
|
481
519
|
"name": "find_files_by_glob",
|
|
482
|
-
"description":
|
|
520
|
+
"description": (
|
|
521
|
+
"Find files matching a glob pattern in the specified directory. Use this when you need to "
|
|
522
|
+
"locate files with specific patterns in their names or paths (e.g., all Python files with "
|
|
523
|
+
"'*.py' or all text files in any subdirectory with '**/*.txt')."
|
|
524
|
+
),
|
|
483
525
|
"parameters": {
|
|
484
526
|
"type": "object",
|
|
485
527
|
"properties": {
|
|
486
528
|
"path": {
|
|
487
529
|
"type": "string",
|
|
488
|
-
"description":
|
|
530
|
+
"description": (
|
|
531
|
+
"The path relative to the sandbox root to search for files from. For example, "
|
|
532
|
+
"'.' for the root directory, 'src' for the src directory, or 'docs/images' for a "
|
|
533
|
+
"nested directory."
|
|
534
|
+
)
|
|
489
535
|
},
|
|
490
536
|
"pattern": {
|
|
491
537
|
"type": "string",
|
|
492
|
-
"description":
|
|
538
|
+
"description": (
|
|
539
|
+
"The glob pattern to match files against. Examples: '*.py' for all Python files in "
|
|
540
|
+
"the specified directory, '**/*.txt' for all text files in the specified directory "
|
|
541
|
+
"and any subdirectory, or '**/*test*.py' for all Python files with 'test' in "
|
|
542
|
+
"their name in the specified directory and any subdirectory."
|
|
543
|
+
)
|
|
493
544
|
}
|
|
494
545
|
},
|
|
495
546
|
"additionalProperties": False,
|
|
@@ -523,17 +574,30 @@ class FindFilesContainingTool(LLMTool):
|
|
|
523
574
|
"type": "function",
|
|
524
575
|
"function": {
|
|
525
576
|
"name": "find_files_containing",
|
|
526
|
-
"description":
|
|
577
|
+
"description": (
|
|
578
|
+
"Find files containing text matching a regex pattern in the specified directory. Use "
|
|
579
|
+
"this when you need to search for specific content across multiple files, such as "
|
|
580
|
+
"finding all files that contain a particular function name or text string."
|
|
581
|
+
),
|
|
527
582
|
"parameters": {
|
|
528
583
|
"type": "object",
|
|
529
584
|
"properties": {
|
|
530
585
|
"path": {
|
|
531
586
|
"type": "string",
|
|
532
|
-
"description":
|
|
587
|
+
"description": (
|
|
588
|
+
"The path relative to the sandbox root to search in. For example, '.' for the "
|
|
589
|
+
"root directory, 'src' for the src directory, or 'docs/images' for a nested "
|
|
590
|
+
"directory."
|
|
591
|
+
)
|
|
533
592
|
},
|
|
534
593
|
"pattern": {
|
|
535
594
|
"type": "string",
|
|
536
|
-
"description":
|
|
595
|
+
"description": (
|
|
596
|
+
"The regex pattern to search for in files. Examples: 'function\\s+main' to find "
|
|
597
|
+
"files containing a main function, 'import\\s+os' to find files importing the os "
|
|
598
|
+
"module, or 'TODO|FIXME' to find files containing TODO or FIXME comments. The "
|
|
599
|
+
"pattern uses Python's re module syntax."
|
|
600
|
+
)
|
|
537
601
|
}
|
|
538
602
|
},
|
|
539
603
|
"additionalProperties": False,
|
|
@@ -573,17 +637,31 @@ class FindLinesMatchingTool(LLMTool):
|
|
|
573
637
|
"type": "function",
|
|
574
638
|
"function": {
|
|
575
639
|
"name": "find_lines_matching",
|
|
576
|
-
"description":
|
|
640
|
+
"description": (
|
|
641
|
+
"Find all lines in a file matching a regex pattern, returning both line numbers and "
|
|
642
|
+
"content. Use this when you need to locate specific patterns within a single file and "
|
|
643
|
+
"need to know exactly where they appear."
|
|
644
|
+
),
|
|
577
645
|
"parameters": {
|
|
578
646
|
"type": "object",
|
|
579
647
|
"properties": {
|
|
580
648
|
"path": {
|
|
581
649
|
"type": "string",
|
|
582
|
-
"description":
|
|
650
|
+
"description": (
|
|
651
|
+
"The full relative path including the filename of the file to search. For "
|
|
652
|
+
"example, 'README.md' for a file in the root directory, 'src/main.py' for a file "
|
|
653
|
+
"in the src directory, or 'docs/images/diagram.png' for a file in a nested "
|
|
654
|
+
"directory."
|
|
655
|
+
)
|
|
583
656
|
},
|
|
584
657
|
"pattern": {
|
|
585
658
|
"type": "string",
|
|
586
|
-
"description":
|
|
659
|
+
"description": (
|
|
660
|
+
"The regex pattern to match lines against. Examples: 'def\\s+\\w+' to find all "
|
|
661
|
+
"function definitions, 'class\\s+\\w+' to find all class definitions, or "
|
|
662
|
+
"'TODO|FIXME' to find all TODO or FIXME comments. The pattern uses Python's re "
|
|
663
|
+
"module syntax."
|
|
664
|
+
)
|
|
587
665
|
}
|
|
588
666
|
},
|
|
589
667
|
"additionalProperties": False,
|
|
@@ -621,17 +699,33 @@ class EditFileWithDiffTool(LLMTool):
|
|
|
621
699
|
"type": "function",
|
|
622
700
|
"function": {
|
|
623
701
|
"name": "edit_file_with_diff",
|
|
624
|
-
"description":
|
|
702
|
+
"description": (
|
|
703
|
+
"Edit a file by applying a diff to it. Use this for making selective changes to parts "
|
|
704
|
+
"of a file while preserving the rest of the content, unlike write_file which completely "
|
|
705
|
+
"replaces the file. The diff should be in a unified diff format with lines prefixed by "
|
|
706
|
+
"'+' (add), '-' (remove), or ' ' (context)."
|
|
707
|
+
),
|
|
625
708
|
"parameters": {
|
|
626
709
|
"type": "object",
|
|
627
710
|
"properties": {
|
|
628
711
|
"path": {
|
|
629
712
|
"type": "string",
|
|
630
|
-
"description":
|
|
713
|
+
"description": (
|
|
714
|
+
"The full relative path including the filename of the file to edit. For example, "
|
|
715
|
+
"'README.md' for a file in the root directory, 'src/main.py' for a file in the "
|
|
716
|
+
"src directory, or 'docs/images/diagram.png' for a file in a nested directory."
|
|
717
|
+
)
|
|
631
718
|
},
|
|
632
719
|
"diff": {
|
|
633
720
|
"type": "string",
|
|
634
|
-
"description":
|
|
721
|
+
"description": (
|
|
722
|
+
"The diff to apply to the file in unified diff format. Lines to add should be "
|
|
723
|
+
"prefixed with '+', lines to remove with '-', and context lines with ' ' (space). "
|
|
724
|
+
"Example:\n\n```\n This is a context line (unchanged)\n-This line will be "
|
|
725
|
+
"removed\n+This line will be added\n This is another context line\n```\n\n"
|
|
726
|
+
"The diff should include enough context lines to uniquely identify the section "
|
|
727
|
+
"of the file to modify."
|
|
728
|
+
)
|
|
635
729
|
}
|
|
636
730
|
},
|
|
637
731
|
"additionalProperties": False,
|
|
@@ -669,13 +763,22 @@ class CreateDirectoryTool(LLMTool):
|
|
|
669
763
|
"type": "function",
|
|
670
764
|
"function": {
|
|
671
765
|
"name": "create_directory",
|
|
672
|
-
"description":
|
|
766
|
+
"description": (
|
|
767
|
+
"Create a new directory at the specified path. If the directory already exists, this "
|
|
768
|
+
"operation will succeed without error. Use this when you need to create a directory "
|
|
769
|
+
"structure before writing files to it."
|
|
770
|
+
),
|
|
673
771
|
"parameters": {
|
|
674
772
|
"type": "object",
|
|
675
773
|
"properties": {
|
|
676
774
|
"path": {
|
|
677
775
|
"type": "string",
|
|
678
|
-
"description":
|
|
776
|
+
"description": (
|
|
777
|
+
"The relative path where the directory should be created. For example, "
|
|
778
|
+
"'new_folder' for a directory in the root, 'src/new_folder' for a directory in "
|
|
779
|
+
"the src directory, or 'docs/images/new_folder' for a nested directory. Parent "
|
|
780
|
+
"directories will be created automatically if they don't exist."
|
|
781
|
+
)
|
|
679
782
|
}
|
|
680
783
|
},
|
|
681
784
|
"additionalProperties": False,
|
mojentic/llm/tools/llm_tool.py
CHANGED
|
@@ -21,8 +21,10 @@ class OrganicWebSearchTool(LLMTool):
|
|
|
21
21
|
"type": "function",
|
|
22
22
|
"function": {
|
|
23
23
|
"name": "organic_web_search",
|
|
24
|
-
"description":
|
|
25
|
-
"Search the Internet for information matching the given query
|
|
24
|
+
"description": (
|
|
25
|
+
"Search the Internet for information matching the given query "
|
|
26
|
+
"and return the organic search results."
|
|
27
|
+
),
|
|
26
28
|
"parameters": {
|
|
27
29
|
"type": "object",
|
|
28
30
|
"properties": {
|
|
@@ -12,7 +12,11 @@ class TellUserTool(LLMTool):
|
|
|
12
12
|
"type": "function",
|
|
13
13
|
"function": {
|
|
14
14
|
"name": "tell_user",
|
|
15
|
-
"description":
|
|
15
|
+
"description": (
|
|
16
|
+
"Display a message to the user without expecting a response. Use this to send "
|
|
17
|
+
"important intermediate information to the user as you work on completing their "
|
|
18
|
+
"request."
|
|
19
|
+
),
|
|
16
20
|
"parameters": {
|
|
17
21
|
"type": "object",
|
|
18
22
|
"properties": {
|
|
@@ -24,4 +28,4 @@ class TellUserTool(LLMTool):
|
|
|
24
28
|
"required": ["message"]
|
|
25
29
|
},
|
|
26
30
|
},
|
|
27
|
-
}
|
|
31
|
+
}
|