mojentic 0.9.0__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 (98) hide show
  1. _examples/async_dispatcher_example.py +12 -4
  2. _examples/async_llm_example.py +1 -2
  3. _examples/broker_as_tool.py +39 -14
  4. _examples/broker_examples.py +4 -6
  5. _examples/characterize_ollama.py +1 -1
  6. _examples/characterize_openai.py +1 -1
  7. _examples/chat_session.py +1 -1
  8. _examples/chat_session_with_tool.py +1 -1
  9. _examples/coding_file_tool.py +1 -3
  10. _examples/current_datetime_tool_example.py +1 -1
  11. _examples/embeddings.py +1 -1
  12. _examples/ephemeral_task_manager_example.py +13 -9
  13. _examples/fetch_openai_models.py +10 -3
  14. _examples/file_deduplication.py +6 -6
  15. _examples/image_analysis.py +2 -3
  16. _examples/image_broker.py +1 -1
  17. _examples/image_broker_splat.py +1 -1
  18. _examples/iterative_solver.py +2 -2
  19. _examples/model_characterization.py +2 -0
  20. _examples/openai_gateway_enhanced_demo.py +15 -5
  21. _examples/raw.py +1 -1
  22. _examples/react/agents/decisioning_agent.py +173 -15
  23. _examples/react/agents/summarization_agent.py +89 -0
  24. _examples/react/agents/thinking_agent.py +84 -14
  25. _examples/react/agents/tool_call_agent.py +83 -0
  26. _examples/react/formatters.py +38 -4
  27. _examples/react/models/base.py +60 -11
  28. _examples/react/models/events.py +76 -8
  29. _examples/react.py +71 -21
  30. _examples/recursive_agent.py +1 -1
  31. _examples/solver_chat_session.py +1 -7
  32. _examples/streaming.py +7 -4
  33. _examples/tell_user_example.py +3 -3
  34. _examples/tracer_demo.py +15 -17
  35. _examples/tracer_qt_viewer.py +49 -46
  36. mojentic/__init__.py +3 -3
  37. mojentic/agents/__init__.py +26 -8
  38. mojentic/agents/{agent_broker.py → agent_event_adapter.py} +3 -3
  39. mojentic/agents/async_aggregator_agent_spec.py +32 -33
  40. mojentic/agents/async_llm_agent.py +9 -5
  41. mojentic/agents/async_llm_agent_spec.py +21 -22
  42. mojentic/agents/base_async_agent.py +2 -2
  43. mojentic/agents/base_llm_agent.py +6 -2
  44. mojentic/agents/iterative_problem_solver.py +11 -5
  45. mojentic/agents/simple_recursive_agent.py +11 -10
  46. mojentic/agents/simple_recursive_agent_spec.py +423 -0
  47. mojentic/async_dispatcher.py +0 -1
  48. mojentic/async_dispatcher_spec.py +1 -1
  49. mojentic/context/__init__.py +0 -2
  50. mojentic/dispatcher.py +7 -8
  51. mojentic/llm/__init__.py +5 -5
  52. mojentic/llm/gateways/__init__.py +19 -18
  53. mojentic/llm/gateways/anthropic.py +1 -0
  54. mojentic/llm/gateways/anthropic_messages_adapter.py +0 -1
  55. mojentic/llm/gateways/llm_gateway.py +1 -1
  56. mojentic/llm/gateways/ollama.py +2 -0
  57. mojentic/llm/gateways/openai.py +62 -58
  58. mojentic/llm/gateways/openai_message_adapter_spec.py +3 -3
  59. mojentic/llm/gateways/openai_model_registry.py +7 -6
  60. mojentic/llm/gateways/openai_model_registry_spec.py +1 -2
  61. mojentic/llm/gateways/openai_temperature_handling_spec.py +2 -2
  62. mojentic/llm/llm_broker.py +7 -5
  63. mojentic/llm/llm_broker_spec.py +7 -2
  64. mojentic/llm/message_composers.py +6 -3
  65. mojentic/llm/message_composers_spec.py +5 -1
  66. mojentic/llm/registry/__init__.py +0 -3
  67. mojentic/llm/tools/__init__.py +0 -9
  68. mojentic/llm/tools/ask_user_tool.py +11 -5
  69. mojentic/llm/tools/current_datetime.py +9 -6
  70. mojentic/llm/tools/date_resolver.py +10 -4
  71. mojentic/llm/tools/date_resolver_spec.py +0 -1
  72. mojentic/llm/tools/ephemeral_task_manager/append_task_tool.py +4 -1
  73. mojentic/llm/tools/ephemeral_task_manager/ephemeral_task_list.py +1 -1
  74. mojentic/llm/tools/ephemeral_task_manager/insert_task_after_tool.py +4 -1
  75. mojentic/llm/tools/ephemeral_task_manager/prepend_task_tool.py +5 -2
  76. mojentic/llm/tools/file_manager.py +131 -28
  77. mojentic/llm/tools/file_manager_spec.py +0 -3
  78. mojentic/llm/tools/llm_tool.py +1 -1
  79. mojentic/llm/tools/llm_tool_spec.py +0 -2
  80. mojentic/llm/tools/organic_web_search.py +4 -2
  81. mojentic/llm/tools/tell_user_tool.py +6 -2
  82. mojentic/llm/tools/tool_wrapper.py +2 -2
  83. mojentic/tracer/__init__.py +1 -10
  84. mojentic/tracer/event_store.py +7 -8
  85. mojentic/tracer/event_store_spec.py +1 -2
  86. mojentic/tracer/null_tracer.py +37 -43
  87. mojentic/tracer/tracer_events.py +8 -2
  88. mojentic/tracer/tracer_events_spec.py +6 -7
  89. mojentic/tracer/tracer_system.py +37 -36
  90. mojentic/tracer/tracer_system_spec.py +21 -6
  91. mojentic/utils/__init__.py +1 -1
  92. mojentic/utils/formatting.py +1 -0
  93. {mojentic-0.9.0.dist-info → mojentic-1.0.0.dist-info}/METADATA +44 -26
  94. mojentic-1.0.0.dist-info/RECORD +149 -0
  95. mojentic-0.9.0.dist-info/RECORD +0 -146
  96. {mojentic-0.9.0.dist-info → mojentic-1.0.0.dist-info}/WHEEL +0 -0
  97. {mojentic-0.9.0.dist-info → mojentic-1.0.0.dist-info}/licenses/LICENSE.md +0 -0
  98. {mojentic-0.9.0.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
  #
@@ -12,7 +12,10 @@ from mojentic.llm.tools.tool_wrapper import ToolWrapper
12
12
  temporal_specialist = BaseLLMAgent(
13
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"):
@@ -28,31 +31,53 @@ knowledge_specialist = BaseLLMAgent(
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
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")
@@ -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
 
@@ -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
@@ -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)
@@ -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("qwen3-coder:30b")
42
41
  llm = LLMBroker("qwen3-coder:30b")
43
- # llm = LLMBroker(model="qwen3-128k:32b")
44
42
 
45
43
  # Create a filesystem gateway for the sandbox
46
44
  fs = FilesystemGateway(base_path=str(base_dir))
@@ -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
26
  llm = LLMBroker(model="qwen3:7b")
30
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.")
@@ -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,13 +7,13 @@ 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
@@ -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()
@@ -6,11 +6,11 @@ for reasoning models vs chat models, provides detailed logging, and offers bette
6
6
  error handling.
7
7
  """
8
8
 
9
- import os
10
9
  from mojentic.llm.gateways.openai import OpenAIGateway
11
10
  from mojentic.llm.gateways.openai_model_registry import get_model_registry
12
11
  from mojentic.llm.gateways.models import LLMMessage, MessageRole
13
12
 
13
+
14
14
  def demonstrate_model_registry():
15
15
  """Demonstrate the model registry capabilities."""
16
16
  print("=== Model Registry Demonstration ===")
@@ -38,6 +38,7 @@ def demonstrate_model_registry():
38
38
  token_param = capabilities.get_token_limit_param()
39
39
  print(f" → Defaulted to: type={capabilities.model_type.value}, token_param={token_param}")
40
40
 
41
+
41
42
  def demonstrate_parameter_adaptation():
42
43
  """Demonstrate parameter adaptation for different model types."""
43
44
  print("\n=== Parameter Adaptation Demonstration ===")
@@ -54,8 +55,14 @@ def demonstrate_parameter_adaptation():
54
55
  }
55
56
 
56
57
  adapted_args = gateway._adapt_parameters_for_model('o1-mini', original_args)
57
- print(f" Original: max_tokens={original_args.get('max_tokens')}, has_tools={'tools' in original_args}")
58
- print(f" Adapted: max_completion_tokens={adapted_args.get('max_completion_tokens')}, has_tools={'tools' in adapted_args}")
58
+ print(
59
+ f" Original: max_tokens={original_args.get('max_tokens')}, "
60
+ f"has_tools={'tools' in original_args}"
61
+ )
62
+ print(
63
+ f" Adapted: max_completion_tokens={adapted_args.get('max_completion_tokens')}, "
64
+ f"has_tools={'tools' in adapted_args}"
65
+ )
59
66
 
60
67
  print("\n2. Chat model parameter adaptation (gpt-4o):")
61
68
  original_args = {
@@ -69,6 +76,7 @@ def demonstrate_parameter_adaptation():
69
76
  print(f" Original: max_tokens={original_args.get('max_tokens')}, has_tools={'tools' in original_args}")
70
77
  print(f" Adapted: max_tokens={adapted_args.get('max_tokens')}, has_tools={'tools' in adapted_args}")
71
78
 
79
+
72
80
  def demonstrate_model_validation():
73
81
  """Demonstrate model parameter validation."""
74
82
  print("\n=== Model Validation Demonstration ===")
@@ -89,6 +97,7 @@ def demonstrate_model_validation():
89
97
  except Exception as e:
90
98
  print(f" Validation error: {e}")
91
99
 
100
+
92
101
  def demonstrate_registry_extensibility():
93
102
  """Demonstrate how to extend the registry with new models."""
94
103
  print("\n=== Registry Extensibility Demonstration ===")
@@ -106,7 +115,7 @@ def demonstrate_registry_extensibility():
106
115
  )
107
116
 
108
117
  registry.register_model("o5-preview", new_capabilities)
109
- print(f" Registered o5-preview as reasoning model")
118
+ print(" Registered o5-preview as reasoning model")
110
119
 
111
120
  # Test the new model
112
121
  capabilities = registry.get_model_capabilities("o5-preview")
@@ -120,6 +129,7 @@ def demonstrate_registry_extensibility():
120
129
  capabilities = registry.get_model_capabilities("claude-3-opus")
121
130
  print(f" claude-3-opus (inferred): type={capabilities.model_type.value}")
122
131
 
132
+
123
133
  if __name__ == "__main__":
124
134
  print("OpenAI Gateway Enhanced Infrastructure Demo")
125
135
  print("=" * 50)
@@ -137,4 +147,4 @@ if __name__ == "__main__":
137
147
  print("✓ Enhanced logging for debugging")
138
148
  print("✓ Parameter validation with helpful warnings")
139
149
  print("✓ Pattern matching for unknown models")
140
- print("✓ Comprehensive test coverage")
150
+ print("✓ Comprehensive test coverage")
_examples/raw.py CHANGED
@@ -18,4 +18,4 @@ anthropic_args = {
18
18
 
19
19
  response = client.messages.create(**anthropic_args)
20
20
 
21
- print(response.content[0].text)
21
+ print(response.content[0].text)