mojentic 0.5.5__py3-none-any.whl → 0.5.6__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.
- mojentic/llm/gateways/models.py +29 -1
- mojentic/llm/tools/llm_tool.py +15 -0
- mojentic/llm/tools/llm_tool_spec.py +68 -0
- {mojentic-0.5.5.dist-info → mojentic-0.5.6.dist-info}/METADATA +1 -1
- {mojentic-0.5.5.dist-info → mojentic-0.5.6.dist-info}/RECORD +8 -7
- {mojentic-0.5.5.dist-info → mojentic-0.5.6.dist-info}/WHEEL +0 -0
- {mojentic-0.5.5.dist-info → mojentic-0.5.6.dist-info}/licenses/LICENSE.md +0 -0
- {mojentic-0.5.5.dist-info → mojentic-0.5.6.dist-info}/top_level.txt +0 -0
mojentic/llm/gateways/models.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
-
from typing import Optional, List, Union,
|
|
2
|
+
from typing import Optional, List, Union, Annotated, Literal
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, Field
|
|
5
5
|
|
|
@@ -14,6 +14,34 @@ class MessageRole(Enum):
|
|
|
14
14
|
Tool = 'tool'
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
class Annotations(BaseModel):
|
|
18
|
+
audience: list[MessageRole] | None = None
|
|
19
|
+
priority: Annotated[float, Field(ge=0.0, le=1.0)] | None = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TextContent(BaseModel):
|
|
23
|
+
"""Text content for a message."""
|
|
24
|
+
|
|
25
|
+
type: Literal["text"]
|
|
26
|
+
text: str
|
|
27
|
+
"""The text content of the message."""
|
|
28
|
+
annotations: Annotations | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ImageContent(BaseModel):
|
|
32
|
+
"""Image content for a message."""
|
|
33
|
+
|
|
34
|
+
type: Literal["image"]
|
|
35
|
+
data: str
|
|
36
|
+
"""The base64-encoded image data."""
|
|
37
|
+
mimeType: str
|
|
38
|
+
"""
|
|
39
|
+
The MIME type of the image. Different providers may support different
|
|
40
|
+
image types.
|
|
41
|
+
"""
|
|
42
|
+
annotations: Annotations | None = None
|
|
43
|
+
|
|
44
|
+
|
|
17
45
|
class LLMToolCall(BaseModel):
|
|
18
46
|
"""
|
|
19
47
|
A tool call to be made available to the LLM.
|
mojentic/llm/tools/llm_tool.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from mojentic.llm.gateways.models import TextContent
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
class LLMTool:
|
|
2
7
|
def run(self, **kwargs):
|
|
3
8
|
raise NotImplementedError
|
|
4
9
|
|
|
10
|
+
def call_tool(self, **kwargs):
|
|
11
|
+
result = self.run(**kwargs)
|
|
12
|
+
if isinstance(result, dict):
|
|
13
|
+
result = json.dumps(result)
|
|
14
|
+
return {
|
|
15
|
+
"content": [
|
|
16
|
+
TextContent(type="text", text=result),
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
|
|
5
20
|
@property
|
|
6
21
|
def descriptor(self):
|
|
7
22
|
raise NotImplementedError
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from unittest.mock import Mock
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from mojentic.llm.gateways.models import TextContent
|
|
7
|
+
from mojentic.llm.tools.llm_tool import LLMTool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MockLLMTool(LLMTool):
|
|
11
|
+
"""A mock implementation of LLMTool for testing purposes."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, run_result=None):
|
|
14
|
+
self._run_result = run_result
|
|
15
|
+
self._descriptor = {
|
|
16
|
+
"function": {
|
|
17
|
+
"name": "mock_tool",
|
|
18
|
+
"description": "A mock tool for testing"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def run(self, **kwargs):
|
|
23
|
+
return self._run_result
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def descriptor(self):
|
|
27
|
+
return self._descriptor
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture
|
|
31
|
+
def mock_tool_with_dict_result():
|
|
32
|
+
return MockLLMTool(run_result={"key": "value"})
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture
|
|
36
|
+
def mock_tool_with_string_result():
|
|
37
|
+
return MockLLMTool(run_result="test result")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class DescribeLLMTool:
|
|
41
|
+
class DescribeCallTool:
|
|
42
|
+
|
|
43
|
+
def should_convert_dict_result_to_json_string(self, mock_tool_with_dict_result):
|
|
44
|
+
result = mock_tool_with_dict_result.call_tool()
|
|
45
|
+
|
|
46
|
+
assert "content" in result
|
|
47
|
+
assert isinstance(result["content"], list)
|
|
48
|
+
assert len(result["content"]) == 1
|
|
49
|
+
assert isinstance(result["content"][0], TextContent)
|
|
50
|
+
assert result["content"][0].text == json.dumps({"key": "value"})
|
|
51
|
+
|
|
52
|
+
def should_handle_string_result_directly(self, mock_tool_with_string_result):
|
|
53
|
+
result = mock_tool_with_string_result.call_tool()
|
|
54
|
+
|
|
55
|
+
assert "content" in result
|
|
56
|
+
assert isinstance(result["content"], list)
|
|
57
|
+
assert len(result["content"]) == 1
|
|
58
|
+
assert isinstance(result["content"][0], TextContent)
|
|
59
|
+
assert result["content"][0].text == "test result"
|
|
60
|
+
|
|
61
|
+
def should_pass_kwargs_to_run_method(self):
|
|
62
|
+
mock_run = Mock(return_value="test result")
|
|
63
|
+
tool = MockLLMTool()
|
|
64
|
+
tool.run = mock_run
|
|
65
|
+
|
|
66
|
+
tool.call_tool(param1="value1", param2="value2")
|
|
67
|
+
|
|
68
|
+
mock_run.assert_called_once_with(param1="value1", param2="value2")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mojentic
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
4
4
|
Summary: Mojentic is an agentic framework that aims to provide a simple and flexible way to assemble teams of agents to solve complex problems.
|
|
5
5
|
Author-email: Stacey Vetzal <stacey@vetzal.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/mojility/mojentic
|
|
@@ -71,7 +71,7 @@ mojentic/llm/gateways/anthropic_messages_adapter.py,sha256=K6kEZeVt7E1endbGMLsh5
|
|
|
71
71
|
mojentic/llm/gateways/embeddings_gateway.py,sha256=kcOhiyHzOyQgKgwPDQJD5oVvfwk71GsBgMYJOIDv5NU,1347
|
|
72
72
|
mojentic/llm/gateways/file_gateway.py,sha256=3bZpalSyl_R4016WzCmmjUBDtAgPsmx19eVGv6p1Ufk,1418
|
|
73
73
|
mojentic/llm/gateways/llm_gateway.py,sha256=5BayP6VuMgMHdAzCFaXLRjRCWh-IOYnaq_s4LZ0_3x4,2559
|
|
74
|
-
mojentic/llm/gateways/models.py,sha256=
|
|
74
|
+
mojentic/llm/gateways/models.py,sha256=lnGvr3E4C5n15v0aI8Cc0FMOH6GBCrk5_XaEEe3vKkM,3015
|
|
75
75
|
mojentic/llm/gateways/ollama.py,sha256=629fpZhC0zVCYqj360-PKTT4mQOLec5nzzvfMtS_mLQ,7581
|
|
76
76
|
mojentic/llm/gateways/ollama_messages_adapter.py,sha256=kUN_p2FyN88_trXMcL-Xsn9xPBU7pGKlJwTUEUCf6G4,1404
|
|
77
77
|
mojentic/llm/gateways/ollama_messages_adapter_spec.py,sha256=gVRbWDrHOa1EiZ0CkEWe0pGn-GKRqdGb-x56HBQeYSE,4981
|
|
@@ -89,7 +89,8 @@ mojentic/llm/tools/current_datetime.py,sha256=JkIFlBBnvE4CMcgZizqITVTtNfL7zeeLxD
|
|
|
89
89
|
mojentic/llm/tools/date_resolver.py,sha256=VDxX59PTHo0PstDxaJUo3SF7vkvQoG92bo6j8ABq8y4,2185
|
|
90
90
|
mojentic/llm/tools/date_resolver_spec.py,sha256=OaRvJyhSN8sgi75euk4E5ImaqUmvQdgZKY8u_NOiPWE,1185
|
|
91
91
|
mojentic/llm/tools/file_manager.py,sha256=X8Uw4XtdH_Ol2EB3SN11-GYlC1diJ1cAywU9_EuCjCg,3788
|
|
92
|
-
mojentic/llm/tools/llm_tool.py,sha256=
|
|
92
|
+
mojentic/llm/tools/llm_tool.py,sha256=i81TNkTiFNMtx-HAGV2bhRrTqoqzdxiPcI0lx05W3A4,745
|
|
93
|
+
mojentic/llm/tools/llm_tool_spec.py,sha256=mDRBXrrNvKh-8ZBq6_AbnU1nqdjtdkP_C2XmztllGQM,2071
|
|
93
94
|
mojentic/llm/tools/organic_web_search.py,sha256=X_WQSSFgeMp5jlm0tnqGOHDIZ2KHDvz3k6GF-XqsuN4,1301
|
|
94
95
|
mojentic/llm/tools/tell_user_tool.py,sha256=bF_PTfF0-skCi_Exw6EPpdfoNUZRJ4MWg-XCe4VYd6s,999
|
|
95
96
|
mojentic/llm/tools/tool_wrapper.py,sha256=6YZOhckgNsSUc7YK6bKjODjRTwi6wcH9bdcySUDPt3Q,1391
|
|
@@ -113,8 +114,8 @@ mojentic/llm/tools/ephemeral_task_manager/start_task_tool.py,sha256=VH8Wa4-ZmkMI
|
|
|
113
114
|
mojentic/llm/tools/ephemeral_task_manager/start_task_tool_spec.py,sha256=oDeVPPfquM2ojwG0aaNnbWCB_LRgm8runtG-CumZkLg,1490
|
|
114
115
|
mojentic/utils/__init__.py,sha256=lqECkkoFvHFttDnafRE1vvh0Dmna_lwupMToP5VvX5k,115
|
|
115
116
|
mojentic/utils/formatting.py,sha256=bPrwwdluXdQ8TsFxfWtHNOeMWKNvAfABSoUnnA1g7c8,947
|
|
116
|
-
mojentic-0.5.
|
|
117
|
-
mojentic-0.5.
|
|
118
|
-
mojentic-0.5.
|
|
119
|
-
mojentic-0.5.
|
|
120
|
-
mojentic-0.5.
|
|
117
|
+
mojentic-0.5.6.dist-info/licenses/LICENSE.md,sha256=txSgV8n5zY1W3NiF5HHsCwlaW0e8We1cSC6TuJUqxXA,1060
|
|
118
|
+
mojentic-0.5.6.dist-info/METADATA,sha256=4kNiXBHxU0wqwBFCBWww1rmoggWOh1om23j8NMAgei8,4956
|
|
119
|
+
mojentic-0.5.6.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
120
|
+
mojentic-0.5.6.dist-info/top_level.txt,sha256=Q-BvPQ8Eu1jnEqK8Xkr6A9C8Xa1z38oPZRHuA5MCTqg,19
|
|
121
|
+
mojentic-0.5.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|