mojentic 0.5.1__py3-none-any.whl → 0.5.3__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.
@@ -1,4 +1,8 @@
1
+ import logging
1
2
  import os
3
+
4
+ logging.basicConfig(level=logging.WARN)
5
+
2
6
  from pathlib import Path
3
7
 
4
8
  from pydantic import BaseModel, Field
@@ -39,19 +43,34 @@ def check_tool_use(llm):
39
43
  tools=[ResolveDateTool()])
40
44
  print(result)
41
45
 
42
- def check_image_analysis(llm):
46
+ def check_image_analysis(llm, image_path: Path = None):
47
+ if image_path is None:
48
+ image_path = Path.cwd() / 'images' / 'flash_rom.jpg'
43
49
  result = llm.generate(messages=[
44
50
  (LLMMessage(content='What is in this image?',
45
- image_paths=[str(Path.cwd() / 'images' / 'flash_rom.jpg')]))
51
+ image_paths=[str(image_path)]))
46
52
  ])
47
53
  print(result)
48
54
 
49
- check_simple_textgen(openai_llm())
50
- check_structured_output(openai_llm())
51
- check_tool_use(openai_llm())
52
- check_image_analysis(openai_llm())
55
+ models = ["gpt-4o", "gpt-4.1", "o3", "gpt-4.5-preview", "o4-mini"]
56
+ images = [
57
+ Path.cwd() / 'images' / 'flash_rom.jpg',
58
+ Path.cwd() / 'images' / 'screen_cap.png',
59
+ Path.cwd() / 'images' / 'xbox-one.jpg',
60
+ ]
61
+
62
+ for image in images:
63
+ for model in models:
64
+ print(f"Checking {model} with {str(image)}")
65
+ check_image_analysis(openai_llm(model=model), image)
66
+
67
+
68
+ # check_simple_textgen(openai_llm(model="o4-mini"))
69
+ # check_structured_output(openai_llm(model="o4-mini"))
70
+ # check_tool_use(openai_llm(model="o4-mini"))
71
+ # check_image_analysis(openai_llm(model="gpt-4o"))
53
72
 
54
- check_simple_textgen(ollama_llm())
55
- check_structured_output(ollama_llm())
56
- check_tool_use(ollama_llm())
57
- check_image_analysis(ollama_llm(model="gemma3:27b"))
73
+ # check_simple_textgen(ollama_llm())
74
+ # check_structured_output(ollama_llm())
75
+ # check_tool_use(ollama_llm())
76
+ # check_image_analysis(ollama_llm(model="gemma3:27b"))
@@ -253,7 +253,7 @@ class MessageBuilder():
253
253
 
254
254
  return self
255
255
 
256
- def load_content(self, file_path: Union[str, Path], template_values: Optional[Dict[str, str]] = None) -> "MessageBuilder":
256
+ def load_content(self, file_path: Union[str, Path], template_values: Optional[Dict[str, Union[str, Path]]] = None) -> "MessageBuilder":
257
257
  """
258
258
  Load content from a file into the content field of the MessageBuilder.
259
259
 
@@ -265,11 +265,14 @@ class MessageBuilder():
265
265
  ----------
266
266
  file_path : Union[str, Path]
267
267
  Path to the file to load content from. Can be a string or Path object.
268
- template_values : Optional[Dict[str, str]], optional
268
+ template_values : Optional[Dict[str, Union[str, Path]]], optional
269
269
  Dictionary of values used to replace placeholders in the content.
270
270
  For example, if the content contains "{greeting}" and template_values is
271
271
  {"greeting": "Hello, World!"}, then "{greeting}" will be replaced with
272
- "Hello, World!". Default is None.
272
+ "Hello, World!".
273
+ If a value is a Path object, it will be treated as a file reference and the
274
+ content of that file will be used to replace the placeholder.
275
+ Default is None.
273
276
 
274
277
  Returns
275
278
  -------
@@ -290,7 +293,15 @@ class MessageBuilder():
290
293
  # Replace placeholders with template values if provided
291
294
  if template_values:
292
295
  for key, value in template_values.items():
293
- self.content = self.content.replace(f"{{{key}}}", value)
296
+ if isinstance(value, Path):
297
+ # If value is a Path, read the content of the file
298
+ if not self.file_gateway.exists(value):
299
+ raise FileNotFoundError(f"Template file not found: {value}")
300
+ file_content = self.file_gateway.read(value).strip()
301
+ self.content = self.content.replace(f"{{{key}}}", file_content)
302
+ else:
303
+ # If value is a string, use it directly
304
+ self.content = self.content.replace(f"{{{key}}}", value)
294
305
 
295
306
  return self
296
307
 
@@ -307,11 +318,14 @@ class MessageBuilder():
307
318
  LLMMessage
308
319
  An LLMMessage object containing the message content and image paths.
309
320
  """
321
+ parts = []
310
322
  if self.file_paths:
311
323
  file_contents = [self._file_content_partial(p) for p in self.file_paths]
312
- self.content = "\n\n".join(file_contents)
324
+ parts.append("\n\n".join(file_contents))
325
+ if self.content is not None:
326
+ parts.append(self.content)
313
327
  return LLMMessage(
314
328
  role=self.role,
315
- content=self.content,
329
+ content="\n\n".join(parts),
316
330
  image_paths=[str(p) for p in self.image_paths]
317
331
  )
@@ -21,7 +21,8 @@ class ResolveDateTool(LLMTool):
21
21
 
22
22
  return {
23
23
  "relative_date": relative_date_found,
24
- "resolved_date": resolved_date.strftime('%Y-%m-%d')
24
+ "resolved_date": resolved_date.strftime('%Y-%m-%d'),
25
+ "summary": f"The date on '{relative_date_found}' is {resolved_date.strftime('%Y-%m-%d')}"
25
26
  }
26
27
 
27
28
  @property
@@ -30,7 +31,7 @@ class ResolveDateTool(LLMTool):
30
31
  "type": "function",
31
32
  "function": {
32
33
  "name": "resolve_date",
33
- "description": "Take text that specifies a relative date, and output an absolute date. If no reference date is provided, the current date is used.",
34
+ "description": "Take text that specifies a relative date, and output an absolute date. If no reference date is available, the current date is used.",
34
35
  "parameters": {
35
36
  "type": "object",
36
37
  "properties": {
@@ -41,7 +42,7 @@ class ResolveDateTool(LLMTool):
41
42
  "reference_date_in_iso8601": {
42
43
  "type": "string",
43
44
  "description": "The date from which the resolved date should be calculated, in YYYY-MM-DD"
44
- " format. If not provided, the current date is used."
45
+ " format. Do not provide if you weren't provided one, I will assume the current date."
45
46
  }
46
47
  },
47
48
  "additionalProperties": False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mojentic
3
- Version: 0.5.1
3
+ Version: 0.5.3
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
@@ -1,6 +1,6 @@
1
1
  _examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  _examples/broker_as_tool.py,sha256=axLrX9lzQAAxSTCmm1njvOk63EWfVRG3NU6pLiMyYH8,2962
3
- _examples/broker_examples.py,sha256=2KxHNgHR4or52OoiNOJFgXDOLaHOVgIkflQVkHbfabM,1698
3
+ _examples/broker_examples.py,sha256=0byvkckM34pOnJhiddh7Rvfy2zRalBH6DT9ayUDT2OE,2292
4
4
  _examples/characterize_ollama.py,sha256=_TzPEAoTuB-saTiaypEQAsUpiBeM37l9I5wCMU3GM4E,2521
5
5
  _examples/characterize_openai.py,sha256=JQQNjsHIEegjLAS3uzDmq_Ci_ZqXTqjcoVaC-rS_R_8,564
6
6
  _examples/chat_session.py,sha256=7mLpH4IGQUgyyiY-fYbikDEiR5vEH-V5Z1qtB50d_qg,288
@@ -59,7 +59,7 @@ mojentic/llm/chat_session.py,sha256=H2gY0mZYVym8jC69VHsmKaRZ9T87Suyw0-TW5r850nA,
59
59
  mojentic/llm/chat_session_spec.py,sha256=8-jj-EHV2WwWuvo3t8I75kSEAYiG1nR-OEwkkLTi_z0,3872
60
60
  mojentic/llm/llm_broker.py,sha256=8dEgqU-cPesPk4-jx36oPnvKxB34bLONbpyAW_2L-es,5884
61
61
  mojentic/llm/llm_broker_spec.py,sha256=zxOf3n8lXmUsowzlMcC-fRcOj_6wwDf7xIqLIV278nM,6979
62
- mojentic/llm/message_composers.py,sha256=IrTK6HrwAQtJRMW5spMRZmX4yKHl2SJdOkFYvhVXZYg,11305
62
+ mojentic/llm/message_composers.py,sha256=Fo9o7UGZOOIYoGI_DyOfP_oMiEiCMQz-zdWdTKtozVk,12108
63
63
  mojentic/llm/message_composers_spec.py,sha256=IXZ-Gl--1MGbmRkFNxucWTE7OZgLQHDDgw1WqMiZnF0,14762
64
64
  mojentic/llm/gateways/__init__.py,sha256=u7hXzngoRw_qbsJeiCH2NQ8vC2hF5DnqcXsfLVVPSSw,104
65
65
  mojentic/llm/gateways/anthropic.py,sha256=SsyNjq9QaXaqiMM43C9fwLp57hpgFtwNPJUnOAYVrtc,1788
@@ -82,7 +82,7 @@ mojentic/llm/registry/populate_registry_from_ollama.py,sha256=YFlnyXW-Htveu8frPE
82
82
  mojentic/llm/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  mojentic/llm/tools/ask_user_tool.py,sha256=WrI3uTzIEmr_S5Pl-rmvh2f3O2IIFYfnJ5zeel_59ck,972
84
84
  mojentic/llm/tools/current_datetime.py,sha256=JkIFlBBnvE4CMcgZizqITVTtNfL7zeeLxD54E7oMeC8,1585
85
- mojentic/llm/tools/date_resolver.py,sha256=Vs8kmAONKif03YcVMZ3TqkKyOJZiy1yEAOqjTcvJFA8,2048
85
+ mojentic/llm/tools/date_resolver.py,sha256=VDxX59PTHo0PstDxaJUo3SF7vkvQoG92bo6j8ABq8y4,2185
86
86
  mojentic/llm/tools/date_resolver_spec.py,sha256=OaRvJyhSN8sgi75euk4E5ImaqUmvQdgZKY8u_NOiPWE,1185
87
87
  mojentic/llm/tools/file_manager.py,sha256=X8Uw4XtdH_Ol2EB3SN11-GYlC1diJ1cAywU9_EuCjCg,3788
88
88
  mojentic/llm/tools/llm_tool.py,sha256=wU1DNf9DpMtcHhP-YC6_NAn1Frel_Ota6yqgPK2Xsp4,407
@@ -91,8 +91,8 @@ mojentic/llm/tools/tool_wrapper_spec.py,sha256=LGqtre-g8SzOy3xtpbMdgTnw2EdYutmFO
91
91
  mojentic/llm/tools/web_search.py,sha256=L1accST2xMhGAkwHCLlIvKihTLiaYxl0NI6IqCJWGCw,1102
92
92
  mojentic/utils/__init__.py,sha256=lqECkkoFvHFttDnafRE1vvh0Dmna_lwupMToP5VvX5k,115
93
93
  mojentic/utils/formatting.py,sha256=bPrwwdluXdQ8TsFxfWtHNOeMWKNvAfABSoUnnA1g7c8,947
94
- mojentic-0.5.1.dist-info/licenses/LICENSE.md,sha256=txSgV8n5zY1W3NiF5HHsCwlaW0e8We1cSC6TuJUqxXA,1060
95
- mojentic-0.5.1.dist-info/METADATA,sha256=YIXg6guNrmTF3fBI225OEvBGuFro2uPOdmnGl5xi1Xc,4935
96
- mojentic-0.5.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
97
- mojentic-0.5.1.dist-info/top_level.txt,sha256=Q-BvPQ8Eu1jnEqK8Xkr6A9C8Xa1z38oPZRHuA5MCTqg,19
98
- mojentic-0.5.1.dist-info/RECORD,,
94
+ mojentic-0.5.3.dist-info/licenses/LICENSE.md,sha256=txSgV8n5zY1W3NiF5HHsCwlaW0e8We1cSC6TuJUqxXA,1060
95
+ mojentic-0.5.3.dist-info/METADATA,sha256=0WlHklNeQXHa9joHQTemZmBVRYeI12UVTHjZ46Ao9c4,4935
96
+ mojentic-0.5.3.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
97
+ mojentic-0.5.3.dist-info/top_level.txt,sha256=Q-BvPQ8Eu1jnEqK8Xkr6A9C8Xa1z38oPZRHuA5MCTqg,19
98
+ mojentic-0.5.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5