mojentic 0.8.4__py3-none-any.whl → 1.0.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 (106) hide show
  1. _examples/async_dispatcher_example.py +12 -4
  2. _examples/async_llm_example.py +1 -2
  3. _examples/broker_as_tool.py +42 -17
  4. _examples/broker_examples.py +5 -7
  5. _examples/broker_image_examples.py +1 -1
  6. _examples/characterize_ollama.py +3 -3
  7. _examples/characterize_openai.py +1 -1
  8. _examples/chat_session.py +2 -2
  9. _examples/chat_session_with_tool.py +2 -2
  10. _examples/coding_file_tool.py +16 -18
  11. _examples/current_datetime_tool_example.py +2 -2
  12. _examples/embeddings.py +1 -1
  13. _examples/ephemeral_task_manager_example.py +15 -11
  14. _examples/fetch_openai_models.py +10 -3
  15. _examples/file_deduplication.py +6 -6
  16. _examples/file_tool.py +5 -5
  17. _examples/image_analysis.py +2 -3
  18. _examples/image_broker.py +1 -1
  19. _examples/image_broker_splat.py +1 -1
  20. _examples/iterative_solver.py +3 -3
  21. _examples/model_characterization.py +2 -0
  22. _examples/openai_gateway_enhanced_demo.py +15 -5
  23. _examples/raw.py +1 -1
  24. _examples/react/agents/decisioning_agent.py +173 -15
  25. _examples/react/agents/summarization_agent.py +89 -0
  26. _examples/react/agents/thinking_agent.py +84 -14
  27. _examples/react/agents/tool_call_agent.py +83 -0
  28. _examples/react/formatters.py +38 -4
  29. _examples/react/models/base.py +60 -11
  30. _examples/react/models/events.py +76 -8
  31. _examples/react.py +71 -21
  32. _examples/recursive_agent.py +2 -2
  33. _examples/simple_llm.py +3 -3
  34. _examples/simple_llm_repl.py +1 -1
  35. _examples/simple_structured.py +1 -1
  36. _examples/simple_tool.py +2 -2
  37. _examples/solver_chat_session.py +5 -11
  38. _examples/streaming.py +36 -18
  39. _examples/tell_user_example.py +4 -4
  40. _examples/tracer_demo.py +18 -20
  41. _examples/tracer_qt_viewer.py +49 -46
  42. _examples/working_memory.py +1 -1
  43. mojentic/__init__.py +3 -3
  44. mojentic/agents/__init__.py +26 -8
  45. mojentic/agents/{agent_broker.py → agent_event_adapter.py} +3 -3
  46. mojentic/agents/async_aggregator_agent_spec.py +32 -33
  47. mojentic/agents/async_llm_agent.py +9 -5
  48. mojentic/agents/async_llm_agent_spec.py +21 -22
  49. mojentic/agents/base_async_agent.py +2 -2
  50. mojentic/agents/base_llm_agent.py +6 -2
  51. mojentic/agents/iterative_problem_solver.py +11 -5
  52. mojentic/agents/simple_recursive_agent.py +11 -10
  53. mojentic/agents/simple_recursive_agent_spec.py +423 -0
  54. mojentic/async_dispatcher.py +0 -1
  55. mojentic/async_dispatcher_spec.py +1 -1
  56. mojentic/context/__init__.py +0 -2
  57. mojentic/dispatcher.py +7 -8
  58. mojentic/llm/__init__.py +5 -5
  59. mojentic/llm/gateways/__init__.py +19 -18
  60. mojentic/llm/gateways/anthropic.py +1 -0
  61. mojentic/llm/gateways/anthropic_messages_adapter.py +0 -1
  62. mojentic/llm/gateways/llm_gateway.py +1 -1
  63. mojentic/llm/gateways/ollama.py +23 -18
  64. mojentic/llm/gateways/openai.py +243 -44
  65. mojentic/llm/gateways/openai_message_adapter_spec.py +3 -3
  66. mojentic/llm/gateways/openai_model_registry.py +7 -6
  67. mojentic/llm/gateways/openai_model_registry_spec.py +1 -2
  68. mojentic/llm/gateways/openai_temperature_handling_spec.py +2 -2
  69. mojentic/llm/llm_broker.py +162 -2
  70. mojentic/llm/llm_broker_spec.py +76 -2
  71. mojentic/llm/message_composers.py +6 -3
  72. mojentic/llm/message_composers_spec.py +5 -1
  73. mojentic/llm/registry/__init__.py +0 -3
  74. mojentic/llm/registry/populate_registry_from_ollama.py +2 -2
  75. mojentic/llm/tools/__init__.py +0 -9
  76. mojentic/llm/tools/ask_user_tool.py +11 -5
  77. mojentic/llm/tools/current_datetime.py +9 -6
  78. mojentic/llm/tools/date_resolver.py +10 -4
  79. mojentic/llm/tools/date_resolver_spec.py +0 -1
  80. mojentic/llm/tools/ephemeral_task_manager/append_task_tool.py +4 -1
  81. mojentic/llm/tools/ephemeral_task_manager/ephemeral_task_list.py +1 -1
  82. mojentic/llm/tools/ephemeral_task_manager/insert_task_after_tool.py +4 -1
  83. mojentic/llm/tools/ephemeral_task_manager/prepend_task_tool.py +5 -2
  84. mojentic/llm/tools/file_manager.py +131 -28
  85. mojentic/llm/tools/file_manager_spec.py +0 -3
  86. mojentic/llm/tools/llm_tool.py +1 -1
  87. mojentic/llm/tools/llm_tool_spec.py +0 -2
  88. mojentic/llm/tools/organic_web_search.py +4 -2
  89. mojentic/llm/tools/tell_user_tool.py +6 -2
  90. mojentic/llm/tools/tool_wrapper.py +2 -2
  91. mojentic/tracer/__init__.py +1 -10
  92. mojentic/tracer/event_store.py +7 -8
  93. mojentic/tracer/event_store_spec.py +1 -2
  94. mojentic/tracer/null_tracer.py +37 -43
  95. mojentic/tracer/tracer_events.py +8 -2
  96. mojentic/tracer/tracer_events_spec.py +6 -7
  97. mojentic/tracer/tracer_system.py +37 -36
  98. mojentic/tracer/tracer_system_spec.py +21 -6
  99. mojentic/utils/__init__.py +1 -1
  100. mojentic/utils/formatting.py +1 -0
  101. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/METADATA +76 -27
  102. mojentic-1.0.0.dist-info/RECORD +149 -0
  103. mojentic-0.8.4.dist-info/RECORD +0 -146
  104. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/WHEEL +0 -0
  105. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/licenses/LICENSE.md +0 -0
  106. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/top_level.txt +0 -0
@@ -62,7 +62,11 @@ class TextAnalyzerAgent(BaseAsyncLLMAgent):
62
62
  def __init__(self, llm: LLMBroker):
63
63
  super().__init__(
64
64
  llm=llm,
65
- behaviour="You are a text analysis assistant. Your job is to provide a detailed analysis of the given text, including key themes, structure, and notable elements.",
65
+ behaviour=(
66
+ "You are a text analysis assistant. "
67
+ "Your job is to provide a detailed analysis of the given text, "
68
+ "including key themes, structure, and notable elements."
69
+ ),
66
70
  response_model=AnalysisResponse
67
71
  )
68
72
 
@@ -93,7 +97,11 @@ class TextSummarizerAgent(BaseAsyncLLMAgent):
93
97
  def __init__(self, llm: LLMBroker):
94
98
  super().__init__(
95
99
  llm=llm,
96
- behaviour="You are a text summarization assistant. Your job is to provide concise, accurate summaries of texts while preserving the key information and main points.",
100
+ behaviour=(
101
+ "You are a text summarization assistant. "
102
+ "Your job is to provide concise, accurate summaries of texts "
103
+ "while preserving the key information and main points."
104
+ ),
97
105
  response_model=SummaryResponse
98
106
  )
99
107
 
@@ -143,8 +151,8 @@ Analysis: {analysis_event.analysis}
143
151
 
144
152
  Summary: {summary_event.summary}
145
153
 
146
- Please create a well-structured, insightful report that integrates the analysis and summary,
147
- highlighting the most important aspects of the text. The report should provide a comprehensive
154
+ Please create a well-structured, insightful report that integrates the analysis and summary,
155
+ highlighting the most important aspects of the text. The report should provide a comprehensive
148
156
  understanding of the text's content, structure, and significance.
149
157
  """
150
158
  # Create a temporary LLM agent to generate the response
@@ -5,14 +5,13 @@ This script shows how to create and use asynchronous LLM agents with the AsyncDi
5
5
  """
6
6
 
7
7
  import asyncio
8
- from typing import List, Optional
8
+ from typing import List
9
9
 
10
10
  from pydantic import BaseModel, Field
11
11
 
12
12
  from mojentic.agents.async_aggregator_agent import AsyncAggregatorAgent
13
13
  from mojentic.agents.async_llm_agent import BaseAsyncLLMAgent
14
14
  from mojentic.async_dispatcher import AsyncDispatcher
15
- from mojentic.context.shared_working_memory import SharedWorkingMemory
16
15
  from mojentic.event import Event
17
16
  from mojentic.llm import LLMBroker
18
17
  from mojentic.router import Router
@@ -2,7 +2,7 @@ import os
2
2
  from mojentic.agents.base_llm_agent import BaseLLMAgent
3
3
  from mojentic.llm.llm_broker import LLMBroker
4
4
  from mojentic.llm.tools.date_resolver import ResolveDateTool
5
- from mojentic.llm.tools.file_manager import FileManager, ListFilesTool, ReadFileTool, WriteFileTool, FilesystemGateway
5
+ from mojentic.llm.tools.file_manager import ListFilesTool, ReadFileTool, WriteFileTool, FilesystemGateway
6
6
  from mojentic.llm.tools.tool_wrapper import ToolWrapper
7
7
 
8
8
  #
@@ -10,9 +10,12 @@ from mojentic.llm.tools.tool_wrapper import ToolWrapper
10
10
  #
11
11
 
12
12
  temporal_specialist = BaseLLMAgent(
13
- llm=LLMBroker(model="qwen2.5:7b"),
13
+ llm=LLMBroker(model="qwen3:7b"),
14
14
  tools=[ResolveDateTool()],
15
- behaviour="You are a historian and sociologist who focuses on sorting out temporal events, determining what happened or will happen when."
15
+ behaviour=(
16
+ "You are a historian and sociologist who focuses on sorting out temporal events, "
17
+ "determining what happened or will happen when."
18
+ )
16
19
  )
17
20
 
18
21
  if not os.path.exists("local"):
@@ -22,37 +25,59 @@ if not os.path.exists("local"):
22
25
  fs = FilesystemGateway(base_path="local")
23
26
 
24
27
  knowledge_specialist = BaseLLMAgent(
25
- llm=LLMBroker(model="llama3.3-70b-32k"),
28
+ llm=LLMBroker(model="qwen3:32b"),
26
29
  tools=[
27
30
  ListFilesTool(fs),
28
31
  ReadFileTool(fs),
29
32
  WriteFileTool(fs),
30
33
  ],
31
- behaviour="You are a knowledge management agent who focuses on sorting out facts and information, able to organize elemental ideas and make connections between them. You can list files to find out where you stored information, read files to review that information, and write files to store that information for later retrieval."
34
+ behaviour=(
35
+ "You are a knowledge management agent who focuses on sorting out facts and information, "
36
+ "able to organize elemental ideas and make connections between them. You can list files "
37
+ "to find out where you stored information, read files to review that information, and "
38
+ "write files to store that information for later retrieval."
39
+ )
32
40
  )
33
41
 
34
42
 
35
-
36
43
  coordinator = BaseLLMAgent(
37
- llm=LLMBroker(model="llama3.3-70b-32k"),
44
+ llm=LLMBroker(model="qwen3:32b"),
38
45
  behaviour="You are a coordinator who can manage multiple agents and delegate tasks to them to solve problems.",
39
46
  tools=[
40
- ToolWrapper(temporal_specialist, "temporal_specialist", "A historian and sociologist who focuses on sorting out temporal events, figuring out dates, determining what happened or will happen when."),
41
- ToolWrapper(knowledge_specialist, "knowledge_specialist", "A knowledge management specialist who focuses on sorting out facts and information, able to organize elemental ideas and make connections between them. Can list files to find out where you stored information, read files to review that information, and write files to store that information for later retrieval."),
47
+ ToolWrapper(
48
+ temporal_specialist,
49
+ "temporal_specialist",
50
+ "A historian and sociologist who focuses on sorting out temporal events, figuring out "
51
+ "dates, determining what happened or will happen when."
52
+ ),
53
+ ToolWrapper(
54
+ knowledge_specialist,
55
+ "knowledge_specialist",
56
+ "A knowledge management specialist who focuses on sorting out facts and information, "
57
+ "able to organize elemental ideas and make connections between them. Can list files to "
58
+ "find out where you stored information, read files to review that information, and "
59
+ "write files to store that information for later retrieval."
60
+ ),
42
61
  ]
43
62
  )
44
63
 
45
- result = coordinator.generate_response("""
46
-
64
+ result = coordinator.generate_response(
65
+ """
47
66
  I have several things I need to do this week:
48
67
 
49
- - On Monday, I need to ensure that I have called Scotiabank and ordered replacement cards for my current, credit, and line of credit accounts.
50
- - On Wednesday, I need to drive into Toronto for work. While in Toronto I need to pick up razors. I need to make sure I see Gregg, Britney and Vikram.
68
+ - On Monday, I need to ensure that I have called Scotiabank and ordered replacement cards for "
69
+ "my current, credit, and line of credit accounts.
70
+ - On Wednesday, I need to drive into Toronto for work. While in Toronto I need to pick up "
71
+ "razors. I need to make sure I see Gregg, Britney and Vikram.
51
72
  - On Thursday, I need to ensure I'm up by 7am so that I can be showered and ready for work by 9.
52
- - On Friday, I need to ensure that I have my laundry done and my bags packed for my trip to Ottawa.
73
+ - On Friday, I need to ensure that I have my laundry done and my bags packed for my trip to "
74
+ "Ottawa.
53
75
 
54
- Create me a markdown file for each day of the week, named "YYYY-MM-DD-ToDo.md" where the date is the date of that day.
55
- Make a list of to-do items in the markdown file, and add a section for the day's daily notes that I can fill out each day.
56
- """)
76
+ Create me a markdown file for each day of the week, named "YYYY-MM-DD-ToDo.md" where the date "
77
+ "is the date of that day.
78
+ Make a list of to-do items in the markdown file, and add a section for the day's daily notes that "
79
+ "I can fill out each day.
80
+ """
81
+ )
57
82
 
58
83
  print(result)
@@ -1,18 +1,16 @@
1
1
  import logging
2
2
  import os
3
-
4
- from mojentic.llm import LLMBroker
5
- from mojentic.llm.gateways import OpenAIGateway
6
-
7
- logging.basicConfig(level=logging.WARN)
8
-
9
3
  from pathlib import Path
10
4
 
11
5
  from pydantic import BaseModel, Field
12
6
 
7
+ from mojentic.llm import LLMBroker
8
+ from mojentic.llm.gateways import OpenAIGateway
13
9
  from mojentic.llm.gateways.models import LLMMessage
14
10
  from mojentic.llm.tools.date_resolver import ResolveDateTool
15
11
 
12
+ logging.basicConfig(level=logging.WARN)
13
+
16
14
 
17
15
  def openai_llm(model="gpt-5"):
18
16
  api_key = os.getenv("OPENAI_API_KEY")
@@ -21,7 +19,7 @@ def openai_llm(model="gpt-5"):
21
19
  return llm
22
20
 
23
21
 
24
- def ollama_llm(model="llama3.3-70b-32k"):
22
+ def ollama_llm(model="qwen3:32b"):
25
23
  llm = LLMBroker(model=model)
26
24
  return llm
27
25
 
@@ -13,7 +13,7 @@ def openai_llm(model="gpt-4o"):
13
13
  return llm
14
14
 
15
15
 
16
- def ollama_llm(model="llama3.3-70b-32k"):
16
+ def ollama_llm(model="qwen3:32b"):
17
17
  llm = LLMBroker(model=model)
18
18
  return llm
19
19
 
@@ -1,7 +1,7 @@
1
1
  from ollama import chat
2
2
  from pydantic import BaseModel, Field
3
3
 
4
- from mojentic.llm.gateways.models import LLMMessage, MessageRole
4
+ from mojentic.llm.gateways.models import LLMMessage
5
5
  from mojentic.llm.gateways.ollama import OllamaGateway
6
6
  from mojentic.llm.tools.date_resolver import ResolveDateTool
7
7
 
@@ -13,7 +13,7 @@ def check_ollama_gateway():
13
13
  label: str = Field(..., description="The label describing the feeling.")
14
14
 
15
15
  response = gateway.complete(
16
- model="llama3.2:1b",
16
+ model="qwen3:7b",
17
17
  messages=[LLMMessage(content="Hello, how are you?")],
18
18
  object_model=Feeling,
19
19
  temperature=1.0,
@@ -25,7 +25,7 @@ def check_ollama_gateway():
25
25
 
26
26
  def check_tools_call():
27
27
  response = chat(
28
- model="llama3.3-70b-32k",
28
+ model="qwen3:32b",
29
29
  messages=[
30
30
  # {
31
31
  # 'role': 'user',
@@ -2,7 +2,7 @@ import os
2
2
 
3
3
  from pydantic import BaseModel, Field
4
4
 
5
- from mojentic.llm.gateways.models import LLMMessage, MessageRole
5
+ from mojentic.llm.gateways.models import LLMMessage
6
6
  from mojentic.llm.gateways.openai import OpenAIGateway
7
7
 
8
8
  api_key = os.getenv("OPENAI_API_KEY")
_examples/chat_session.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from mojentic.llm import ChatSession, LLMBroker
2
2
 
3
- llm_broker = LLMBroker(model="llama3.3-70b-32k")
3
+ llm_broker = LLMBroker(model="qwen3:32b")
4
4
  chat_session = ChatSession(llm_broker)
5
5
 
6
6
  while True:
@@ -9,4 +9,4 @@ while True:
9
9
  break
10
10
  else:
11
11
  response = chat_session.send(query)
12
- print(response)
12
+ print(response)
@@ -1,7 +1,7 @@
1
1
  from mojentic.llm import ChatSession, LLMBroker
2
2
  from mojentic.llm.tools.date_resolver import ResolveDateTool
3
3
 
4
- llm_broker = LLMBroker(model="llama3.3-70b-32k")
4
+ llm_broker = LLMBroker(model="qwen3:32b")
5
5
  chat_session = ChatSession(llm_broker, tools=[ResolveDateTool()])
6
6
 
7
7
  while True:
@@ -10,4 +10,4 @@ while True:
10
10
  break
11
11
  else:
12
12
  response = chat_session.send(query)
13
- print(response)
13
+ print(response)
@@ -30,7 +30,7 @@ from mojentic.llm.tools.file_manager import (
30
30
  EditFileWithDiffTool, CreateDirectoryTool, FilesystemGateway
31
31
  )
32
32
 
33
- base_dir = Path(__file__).parent.parent.parent.parent / "code-playground2"
33
+ base_dir = Path(__file__).parent.parent.parent.parent / "code-playground3"
34
34
 
35
35
  # Initialize the LLM broker
36
36
 
@@ -38,9 +38,7 @@ api_key = os.getenv("OPENAI_API_KEY")
38
38
  gateway = OpenAIGateway(api_key)
39
39
  llm = LLMBroker(model="o4-mini", gateway=gateway)
40
40
 
41
- # llm = LLMBroker("qwen2.5-coder:32b")
42
- # llm = LLMBroker("llama3.3")
43
- # llm = LLMBroker(model="qwen3-128k:32b")
41
+ llm = LLMBroker("qwen3-coder:30b")
44
42
 
45
43
  # Create a filesystem gateway for the sandbox
46
44
  fs = FilesystemGateway(base_path=str(base_dir))
@@ -75,28 +73,28 @@ solver = IterativeProblemSolver(
75
73
  system_prompt="""
76
74
  # 0 - Project Identity & Context
77
75
 
78
- You are an expert and principled software engineer, well versed in writing Python games. You work
79
- carefully and purposefully and always check your work with an eye to testability and correctness.
80
- You know that every line of code you write is a liability, and you take care that every line
76
+ You are an expert and principled software engineer, well versed in writing Python games. You work
77
+ carefully and purposefully and always check your work with an eye to testability and correctness.
78
+ You know that every line of code you write is a liability, and you take care that every line
81
79
  matters.
82
80
 
83
81
  # 1 - Universal Engineering Principles
84
82
 
85
83
  * **Code is communication** — optimise for the next human reader.
86
- * **Simple Design Heuristics** — guiding principles, not iron laws; consult the user when you
84
+ * **Simple Design Heuristics** — guiding principles, not iron laws; consult the user when you
87
85
  need to break them.
88
86
  1. **All tests pass** — correctness is non‑negotiable.
89
87
  2. **Reveals intent** — code should read like an explanation.
90
- 3. **No *****knowledge***** duplication** — avoid multiple spots that must change together;
88
+ 3. **No *****knowledge***** duplication** — avoid multiple spots that must change together;
91
89
  identical code is only a smell when it hides duplicate *decisions*.
92
90
  4. **Minimal entities** — remove unnecessary indirection, classes, or parameters.
93
91
  * **Small, safe increments** — single‑reason commits; avoid speculative work (**YAGNI**).
94
92
  * **Tests are the executable spec** — red first, green always; test behaviour not implementation.
95
93
  * **Compose over inherit**; favour pure functions where practical, avoid side-effects.
96
- * **Functional core, imperative shell** — isolate pure business logic from I/O and side effects;
94
+ * **Functional core, imperative shell** — isolate pure business logic from I/O and side effects;
97
95
  push mutations to the system boundaries, build mockable gateways at those boundaries.
98
96
  * **Psychological safety** — review code, not colleagues; critique ideas, not authors.
99
- * **Version‑control etiquette** — descriptive commit messages, branch from `main`, PRs require
97
+ * **Version‑control etiquette** — descriptive commit messages, branch from `main`, PRs require
100
98
  green CI.
101
99
 
102
100
  # 2 - Python‑Specific Conventions
@@ -115,21 +113,21 @@ green CI.
115
113
 
116
114
  ## 2.2 Core Libraries
117
115
 
118
- Mandatory: pydantic, structlog, pytest, pytest-spec, pytest-cov, pytest-mock, flake8, black,
119
- pre‑commit, mkdocs‑material. Add new libs only when they eliminate **significant** boilerplate or
116
+ Mandatory: pydantic, structlog, pytest, pytest-spec, pytest-cov, pytest-mock, flake8, black,
117
+ pre‑commit, mkdocs‑material. Add new libs only when they eliminate **significant** boilerplate or
120
118
  risk.
121
119
 
122
120
  ## 2.3 Project Structure & Imports
123
121
 
124
122
  * **src‑layout**: code in `src/<package_name>/`; tests live beside code as `*_spec.py`.
125
- * Import order: 1) stdlib, 2) third‑party, 3) first‑party — each group alphabetised with a blank
123
+ * Import order: 1) stdlib, 2) third‑party, 3) first‑party — each group alphabetised with a blank
126
124
  line.
127
125
 
128
126
  ## 2.4 Naming & Style
129
127
 
130
128
  * `snake_case` for functions & vars, `PascalCase` for classes, `UPPER_SNAKE` for constants.
131
129
  * Prefix intentionally unused vars/args with `_`.
132
- * **flake8** (with plugins) handles linting, and **black** auto‑formats code. Max line length
130
+ * **flake8** (with plugins) handles linting, and **black** auto‑formats code. Max line length
133
131
  **100**.
134
132
  * Cyclomatic complexity cap: **10** (flake8 `C901`).
135
133
  * Use **f‑strings**; avoid magic numbers.
@@ -144,14 +142,14 @@ line.
144
142
 
145
143
  * Configure **structlog** for JSON output by default.
146
144
  * Never use `print` for diagnostics; reserve for user‑facing CLI UX.
147
- * Log levels: `DEBUG` (dev detail) → `INFO` (lifecycle) → `WARNING` (recoverable) → `ERROR` (user
145
+ * Log levels: `DEBUG` (dev detail) → `INFO` (lifecycle) → `WARNING` (recoverable) → `ERROR` (user
148
146
  visible).
149
147
 
150
148
  ## 2.7 Testing Strategy
151
149
 
152
150
  * **pytest** with **pytest-spec** for specification-style output.
153
151
  * Test files end with `_spec.py` and live in the same folder as the code under test.
154
- * Use **Arrange / Act / Assert** blocks separated by a blank line (no comments) **or** BDD
152
+ * Use **Arrange / Act / Assert** blocks separated by a blank line (no comments) **or** BDD
155
153
  `describe/should` classes.
156
154
  * Function names: use `should_*` and BDD-style specifications.
157
155
  * Class names: use `Describe*` and BDD-style test suites.
@@ -162,7 +160,7 @@ visible).
162
160
  # 3 - Planning and Goal Tracking
163
161
 
164
162
  - Use the provided task manager tools to create your plans and work through them step by step.
165
- - Before declaring yourself finished list all tasks, ensure they are all complete, and that you
163
+ - Before declaring yourself finished list all tasks, ensure they are all complete, and that you
166
164
  have not missed any steps
167
165
  - If you've missed or forgotten some steps, add them to the task list and continue
168
166
  - When all tasks are complete, and you can think of no more to add, declare yourself finished.
@@ -4,7 +4,7 @@ from mojentic.llm.tools.current_datetime import CurrentDateTimeTool
4
4
 
5
5
  # Create an LLM broker with a specified model
6
6
  # You can change the model to any supported model
7
- llm = LLMBroker(model="qwen2.5:7b") # Using the same model as in simple_tool.py
7
+ llm = LLMBroker(model="qwen3:7b") # Using the same model as in simple_tool.py
8
8
 
9
9
  # Create our custom tool
10
10
  datetime_tool = CurrentDateTimeTool()
@@ -25,4 +25,4 @@ result = llm.generate(
25
25
  )
26
26
 
27
27
  print("\nLLM Response with custom format:")
28
- print(result)
28
+ print(result)
_examples/embeddings.py CHANGED
@@ -6,4 +6,4 @@ ollama = OllamaGateway()
6
6
  print(len(ollama.calculate_embeddings("Hello, world!")))
7
7
 
8
8
  openai = OpenAIGateway(os.environ["OPENAI_API_KEY"])
9
- print(len(openai.calculate_embeddings("Hello, world!")))
9
+ print(len(openai.calculate_embeddings("Hello, world!")))
@@ -2,13 +2,6 @@
2
2
  Example script demonstrating the usage of the ephemeral task manager tools.
3
3
  """
4
4
  import logging
5
- import os
6
-
7
- from mojentic.llm.gateways import OpenAIGateway
8
-
9
- logging.basicConfig(
10
- level=logging.WARN
11
- )
12
5
 
13
6
  from mojentic.llm import LLMBroker
14
7
  from mojentic.llm.gateways.models import LLMMessage
@@ -24,13 +17,24 @@ from mojentic.llm.tools.ephemeral_task_manager import (
24
17
  )
25
18
  from mojentic.llm.tools.tell_user_tool import TellUserTool
26
19
 
20
+ logging.basicConfig(
21
+ level=logging.WARN
22
+ )
23
+
27
24
  # llm = LLMBroker(model="qwen3:30b-a3b-q4_K_M")
28
25
  # llm = LLMBroker(model="qwen3:32b")
29
- llm = LLMBroker(model="qwen2.5:7b")
30
- # llm = LLMBroker(model="qwen2.5:72b")
26
+ llm = LLMBroker(model="qwen3:7b")
27
+ # llm = LLMBroker(model="qwen3:72b")
31
28
  # llm = LLMBroker(model="o4-mini", gateway=OpenAIGateway(os.environ["OPENAI_API_KEY"]))
32
29
  message = LLMMessage(
33
- content="I want you to count from 1 to 10. Break that request down into individual tasks, track them using available tools, and perform them one by one until you're finished. Interrupt me to tell the user as you complete every task.")
30
+ content=(
31
+ "I want you to count from 1 to 10. "
32
+ "Break that request down into individual tasks, "
33
+ "track them using available tools, "
34
+ "and perform them one by one until you're finished. "
35
+ "Interrupt me to tell the user as you complete every task."
36
+ )
37
+ )
34
38
  task_list = EphemeralTaskList()
35
39
  tools = [
36
40
  AppendTaskTool(task_list),
@@ -45,4 +49,4 @@ tools = [
45
49
 
46
50
  result = llm.generate(messages=[message], tools=tools, temperature=0.0)
47
51
  print(result)
48
- print(task_list.list_tasks())
52
+ print(task_list.list_tasks())
@@ -5,6 +5,7 @@ Script to fetch current OpenAI models and update the registry with up-to-date mo
5
5
  import os
6
6
  from mojentic.llm.gateways.openai import OpenAIGateway
7
7
 
8
+
8
9
  def fetch_current_openai_models():
9
10
  """Fetch the current list of OpenAI models."""
10
11
  api_key = os.getenv("OPENAI_API_KEY")
@@ -20,6 +21,7 @@ def fetch_current_openai_models():
20
21
  print(f"ERROR: Failed to fetch models from OpenAI API: {e}")
21
22
  return None
22
23
 
24
+
23
25
  def categorize_models(models):
24
26
  """Categorize models by type based on naming patterns."""
25
27
  reasoning_models = []
@@ -32,7 +34,7 @@ def categorize_models(models):
32
34
 
33
35
  # Reasoning models: o1, o3, o4, and gpt-5 series
34
36
  if (any(pattern in model_lower for pattern in ['o1-', 'o3-', 'o4-', 'gpt-5']) or
35
- model_lower in ['o1', 'o3', 'o4', 'gpt-5']):
37
+ model_lower in ['o1', 'o3', 'o4', 'gpt-5']):
36
38
  reasoning_models.append(model)
37
39
  elif 'embedding' in model_lower:
38
40
  embedding_models.append(model)
@@ -48,6 +50,7 @@ def categorize_models(models):
48
50
  'other': sorted(other_models)
49
51
  }
50
52
 
53
+
51
54
  def print_model_lists(categorized_models):
52
55
  """Print the categorized models in a format ready for the registry."""
53
56
  print("=== Current OpenAI Models ===\n")
@@ -84,6 +87,7 @@ def print_model_lists(categorized_models):
84
87
  print(f'# "{model}",')
85
88
  print("# ]\n")
86
89
 
90
+
87
91
  if __name__ == "__main__":
88
92
  print("Fetching current OpenAI models...")
89
93
  models = fetch_current_openai_models()
@@ -99,6 +103,9 @@ if __name__ == "__main__":
99
103
  print(f"Embedding models: {len(categorized['embedding'])}")
100
104
  print(f"Other models: {len(categorized['other'])}")
101
105
 
102
- print("\nCopy the model lists above and update the _initialize_default_models() method in openai_model_registry.py")
106
+ print(
107
+ "\nCopy the model lists above and update the "
108
+ "_initialize_default_models() method in openai_model_registry.py"
109
+ )
103
110
  else:
104
- print("Failed to fetch models. Please check your API key and try again.")
111
+ print("Failed to fetch models. Please check your API key and try again.")
@@ -14,9 +14,9 @@ message_builder.add_images(image_path, image_path) # Adding the same image twic
14
14
 
15
15
  # Build the message and check the number of images
16
16
  message = message_builder.build()
17
- print(f"Number of images in message: {len(message.image_paths)}")
18
- print(f"Expected number of images: 1")
19
- print(f"De-duplication working: {len(message.image_paths) == 1}")
17
+ print("Number of images in message: {len(message.image_paths)}")
18
+ print("Expected number of images: 1")
19
+ print("De-duplication working: {len(message.image_paths) == 1}")
20
20
 
21
21
  # Test de-duplication of files
22
22
  print("\nTesting file de-duplication:")
@@ -31,8 +31,8 @@ message_builder.add_files(file_path, file_path) # Adding the same file twice mo
31
31
  # Build the message and check the number of files
32
32
  message = message_builder.build()
33
33
  # Since we're using the file content in the message, we need to check file_paths directly
34
- print(f"Number of files in message_builder.file_paths: {len(message_builder.file_paths)}")
35
- print(f"Expected number of files: 1")
36
- print(f"De-duplication working: {len(message_builder.file_paths) == 1}")
34
+ print("Number of files in message_builder.file_paths: {len(message_builder.file_paths)}")
35
+ print("Expected number of files: 1")
36
+ print("De-duplication working: {len(message_builder.file_paths) == 1}")
37
37
 
38
38
  print("\nTest completed.")
_examples/file_tool.py CHANGED
@@ -52,11 +52,11 @@ This is an unfinished story about Ernie, the most adorable and colourful caterpi
52
52
  #
53
53
 
54
54
 
55
- # llm = LLMBroker("llama3.3-70b-32k")
56
- # llm = LLMBroker("llama3.1:70b")
57
- # llm = LLMBroker("llama3.1:8b")
58
- llm = LLMBroker("qwen2.5:7b")
59
- # llm = LLMBroker("llama3.3")
55
+ # llm = LLMBroker("qwen3:32b")
56
+ # llm = LLMBroker("qwen3:32b")
57
+ # llm = LLMBroker("qwen3:7b")
58
+ llm = LLMBroker("qwen3:7b")
59
+ # llm = LLMBroker("qwen3:32b")
60
60
  # api_key = os.getenv("OPENAI_API_KEY")
61
61
  # gateway = OpenAIGateway(api_key)
62
62
  # llm = LLMBroker(model="gpt-4o-mini", gateway=gateway)
@@ -1,7 +1,6 @@
1
- import os
2
1
  from pathlib import Path
3
2
 
4
- from mojentic.llm.gateways import OllamaGateway, OpenAIGateway
3
+ from mojentic.llm.gateways import OllamaGateway
5
4
  from mojentic.llm.gateways.models import LLMMessage
6
5
 
7
6
  llmg = OllamaGateway()
@@ -18,4 +17,4 @@ response = llmg.complete(
18
17
  ],
19
18
  )
20
19
 
21
- print(response)
20
+ print(response)
_examples/image_broker.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from pathlib import Path
2
2
 
3
3
  from mojentic.llm import LLMBroker
4
- from mojentic.llm.message_composers import MessagesBuilder, MessageBuilder
4
+ from mojentic.llm.message_composers import MessageBuilder
5
5
 
6
6
  llm = LLMBroker(model="gemma3:27b")
7
7
 
@@ -47,4 +47,4 @@ print(f"Example 4: Added {len(message4.image_paths)} image(s)")
47
47
  # Generate a response using one of the messages (e.g., message1)
48
48
  print("\nGenerating response for Example 1...")
49
49
  result = llm.generate(messages=[message1])
50
- print(result)
50
+ print(result)
@@ -7,18 +7,18 @@ date-related query using the ResolveDateTool.
7
7
 
8
8
  import logging
9
9
 
10
- logging.basicConfig(level=logging.WARN)
11
-
12
10
  from mojentic.agents.iterative_problem_solver import IterativeProblemSolver
13
11
  from mojentic.llm.tools.date_resolver import ResolveDateTool
14
12
  from mojentic.llm.tools.ask_user_tool import AskUserTool
15
13
  from mojentic.llm import LLMBroker
16
14
 
15
+ logging.basicConfig(level=logging.WARN)
16
+
17
17
 
18
18
  def main():
19
19
  # Initialize the LLM broker with your preferred model
20
20
  # Uncomment one of the following lines or modify as needed:
21
- # llm = LLMBroker(model="llama3.3-70b-32k") # Ollama model
21
+ # llm = LLMBroker(model="qwen3:32b") # Ollama model
22
22
  # llm = LLMBroker(model="gpt-4o") # OpenAI model
23
23
  llm = LLMBroker(model="qwq") # Default model for example
24
24
 
@@ -2,6 +2,7 @@ import os
2
2
  from mojentic.llm.gateways.openai import OpenAIGateway
3
3
  from mojentic.llm.gateways.models import LLMMessage, MessageRole
4
4
 
5
+
5
6
  def check_model_characterization():
6
7
  """
7
8
  Test the model characterization functionality with different OpenAI models.
@@ -69,5 +70,6 @@ def check_model_characterization():
69
70
  print("\n" + "=" * 60)
70
71
  print("Model characterization test completed!")
71
72
 
73
+
72
74
  if __name__ == "__main__":
73
75
  check_model_characterization()