janito 2.2.0__py3-none-any.whl → 2.3.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 (130) hide show
  1. janito/__init__.py +6 -6
  2. janito/agent/setup_agent.py +14 -5
  3. janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +3 -1
  4. janito/cli/chat_mode/bindings.py +6 -0
  5. janito/cli/chat_mode/session.py +16 -0
  6. janito/cli/chat_mode/shell/autocomplete.py +21 -21
  7. janito/cli/chat_mode/shell/commands/__init__.py +3 -0
  8. janito/cli/chat_mode/shell/commands/clear.py +12 -12
  9. janito/cli/chat_mode/shell/commands/exec.py +27 -0
  10. janito/cli/chat_mode/shell/commands/multi.py +51 -51
  11. janito/cli/chat_mode/shell/commands/tools.py +17 -6
  12. janito/cli/chat_mode/shell/input_history.py +62 -62
  13. janito/cli/chat_mode/shell/session/manager.py +1 -0
  14. janito/cli/chat_mode/toolbar.py +1 -0
  15. janito/cli/cli_commands/list_models.py +35 -35
  16. janito/cli/cli_commands/list_providers.py +9 -9
  17. janito/cli/cli_commands/list_tools.py +53 -53
  18. janito/cli/cli_commands/model_selection.py +50 -50
  19. janito/cli/cli_commands/model_utils.py +13 -2
  20. janito/cli/cli_commands/set_api_key.py +19 -19
  21. janito/cli/cli_commands/show_config.py +51 -51
  22. janito/cli/cli_commands/show_system_prompt.py +62 -62
  23. janito/cli/config.py +2 -1
  24. janito/cli/core/__init__.py +4 -4
  25. janito/cli/core/event_logger.py +59 -59
  26. janito/cli/core/getters.py +3 -1
  27. janito/cli/core/runner.py +165 -148
  28. janito/cli/core/setters.py +5 -1
  29. janito/cli/core/unsetters.py +54 -54
  30. janito/cli/main_cli.py +12 -1
  31. janito/cli/prompt_core.py +5 -2
  32. janito/cli/rich_terminal_reporter.py +22 -3
  33. janito/cli/single_shot_mode/__init__.py +6 -6
  34. janito/cli/single_shot_mode/handler.py +11 -1
  35. janito/cli/verbose_output.py +1 -1
  36. janito/config.py +5 -5
  37. janito/config_manager.py +2 -0
  38. janito/driver_events.py +14 -0
  39. janito/drivers/anthropic/driver.py +113 -113
  40. janito/drivers/azure_openai/driver.py +38 -3
  41. janito/drivers/driver_registry.py +0 -2
  42. janito/drivers/openai/driver.py +196 -36
  43. janito/formatting_token.py +54 -54
  44. janito/i18n/__init__.py +35 -35
  45. janito/i18n/messages.py +23 -23
  46. janito/i18n/pt.py +47 -47
  47. janito/llm/__init__.py +5 -5
  48. janito/llm/agent.py +443 -443
  49. janito/llm/auth.py +1 -0
  50. janito/llm/driver.py +7 -1
  51. janito/llm/driver_config.py +1 -0
  52. janito/llm/driver_config_builder.py +34 -34
  53. janito/llm/driver_input.py +12 -12
  54. janito/llm/message_parts.py +60 -60
  55. janito/llm/model.py +38 -38
  56. janito/llm/provider.py +196 -196
  57. janito/provider_config.py +7 -3
  58. janito/provider_registry.py +176 -158
  59. janito/providers/__init__.py +1 -0
  60. janito/providers/anthropic/model_info.py +22 -22
  61. janito/providers/anthropic/provider.py +2 -2
  62. janito/providers/azure_openai/model_info.py +7 -6
  63. janito/providers/azure_openai/provider.py +30 -2
  64. janito/providers/deepseek/__init__.py +1 -1
  65. janito/providers/deepseek/model_info.py +16 -16
  66. janito/providers/deepseek/provider.py +91 -91
  67. janito/providers/google/model_info.py +21 -29
  68. janito/providers/google/provider.py +49 -38
  69. janito/providers/mistralai/provider.py +2 -2
  70. janito/providers/provider_static_info.py +2 -3
  71. janito/tools/adapters/__init__.py +1 -1
  72. janito/tools/adapters/local/adapter.py +33 -11
  73. janito/tools/adapters/local/ask_user.py +102 -102
  74. janito/tools/adapters/local/copy_file.py +84 -84
  75. janito/tools/adapters/local/create_directory.py +69 -69
  76. janito/tools/adapters/local/create_file.py +82 -82
  77. janito/tools/adapters/local/delete_text_in_file.py +4 -7
  78. janito/tools/adapters/local/fetch_url.py +97 -97
  79. janito/tools/adapters/local/find_files.py +138 -138
  80. janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
  81. janito/tools/adapters/local/get_file_outline/core.py +117 -117
  82. janito/tools/adapters/local/get_file_outline/java_outline.py +40 -40
  83. janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
  84. janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
  85. janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
  86. janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
  87. janito/tools/adapters/local/move_file.py +3 -13
  88. janito/tools/adapters/local/python_code_run.py +166 -166
  89. janito/tools/adapters/local/python_command_run.py +164 -164
  90. janito/tools/adapters/local/python_file_run.py +163 -163
  91. janito/tools/adapters/local/remove_directory.py +6 -17
  92. janito/tools/adapters/local/remove_file.py +4 -10
  93. janito/tools/adapters/local/replace_text_in_file.py +6 -9
  94. janito/tools/adapters/local/run_bash_command.py +176 -176
  95. janito/tools/adapters/local/run_powershell_command.py +219 -219
  96. janito/tools/adapters/local/search_text/__init__.py +1 -1
  97. janito/tools/adapters/local/search_text/core.py +201 -201
  98. janito/tools/adapters/local/search_text/match_lines.py +1 -1
  99. janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
  100. janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
  101. janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
  102. janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
  103. janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
  104. janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
  105. janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
  106. janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
  107. janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
  108. janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
  109. janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
  110. janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
  111. janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
  112. janito/tools/adapters/local/view_file.py +167 -167
  113. janito/tools/inspect_registry.py +17 -17
  114. janito/tools/tool_base.py +105 -105
  115. janito/tools/tool_events.py +58 -58
  116. janito/tools/tool_run_exception.py +12 -12
  117. janito/tools/tool_use_tracker.py +81 -81
  118. janito/tools/tool_utils.py +45 -45
  119. janito/tools/tools_adapter.py +78 -6
  120. janito/tools/tools_schema.py +104 -104
  121. janito/version.py +4 -4
  122. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/METADATA +388 -251
  123. janito-2.3.0.dist-info/RECORD +181 -0
  124. janito/drivers/google_genai/driver.py +0 -54
  125. janito/drivers/google_genai/schema_generator.py +0 -67
  126. janito-2.2.0.dist-info/RECORD +0 -182
  127. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
  128. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
  129. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/licenses/LICENSE +0 -0
  130. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -1,158 +1,176 @@
1
- """
2
- ProviderRegistry: Handles provider listing and selection logic for janito CLI.
3
- """
4
-
5
- from rich.table import Table
6
- from janito.cli.console import shared_console
7
- from janito.providers.registry import LLMProviderRegistry
8
- from janito.providers.provider_static_info import STATIC_PROVIDER_METADATA
9
- from janito.llm.auth import LLMAuthManager
10
- import sys
11
- from janito.exceptions import MissingProviderSelectionException
12
-
13
-
14
- class ProviderRegistry:
15
- def list_providers(self):
16
- """List all supported LLM providers as a table using rich, showing if auth is configured and supported model names."""
17
- providers = self._get_provider_names()
18
- table = self._create_table()
19
- rows = self._get_all_provider_rows(providers)
20
- self._add_rows_to_table(table, rows)
21
- self._print_table(table)
22
-
23
- def _get_provider_names(self):
24
- return list(STATIC_PROVIDER_METADATA.keys())
25
-
26
- def _create_table(self):
27
- table = Table(title="Supported LLM Providers")
28
- table.add_column("Provider", style="cyan")
29
- table.add_column("Maintainer", style="yellow", justify="center")
30
- table.add_column("Model Names", style="magenta")
31
- return table
32
-
33
- def _get_all_provider_rows(self, providers):
34
- rows = []
35
- for p in providers:
36
- info = self._get_provider_info(p)
37
- # info is (provider_name, maintainer, model_names, skip)
38
- if len(info) == 4 and info[3]:
39
- continue # skip providers flagged as not implemented
40
- rows.append(info[:3])
41
- rows.sort(key=self._maintainer_sort_key)
42
- return rows
43
-
44
- def _add_rows_to_table(self, table, rows):
45
- for idx, (p, maintainer, model_names) in enumerate(rows):
46
- table.add_row(p, maintainer, model_names)
47
- if idx != len(rows) - 1:
48
- table.add_section()
49
-
50
- def _print_table(self, table):
51
- shared_console.print(table)
52
-
53
- def _get_provider_info(self, provider_name):
54
- static_info = STATIC_PROVIDER_METADATA.get(provider_name, {})
55
- maintainer_val = static_info.get("maintainer", "-")
56
- maintainer = (
57
- "[red]🚨 Needs maintainer[/red]"
58
- if maintainer_val == "Needs maintainer"
59
- else f"👤 {maintainer_val}"
60
- )
61
- model_names = "-"
62
- unavailable_reason = None
63
- skip = False
64
- try:
65
- provider_class = LLMProviderRegistry.get(provider_name)
66
- creds = LLMAuthManager().get_credentials(provider_name)
67
- provider_instance = None
68
- instantiation_failed = False
69
- try:
70
- provider_instance = provider_class()
71
- except NotImplementedError:
72
- skip = True
73
- unavailable_reason = "Not implemented"
74
- model_names = f"[red]❌ Not implemented[/red]"
75
- except Exception as e:
76
- instantiation_failed = True
77
- unavailable_reason = (
78
- f"Unavailable (import error or missing dependency): {str(e)}"
79
- )
80
- model_names = f"[red]❌ {unavailable_reason}[/red]"
81
- if not instantiation_failed and provider_instance is not None:
82
- available, unavailable_reason = self._get_availability(
83
- provider_instance
84
- )
85
- if (
86
- not available
87
- and unavailable_reason
88
- and "not implemented" in str(unavailable_reason).lower()
89
- ):
90
- skip = True
91
- if available:
92
- model_names = self._get_model_names(provider_name)
93
- else:
94
- model_names = f"[red]❌ {unavailable_reason}[/red]"
95
- except Exception as import_error:
96
- model_names = f"[red]❌ Unavailable (cannot import provider module): {str(import_error)}[/red]"
97
- return (provider_name, maintainer, model_names, skip)
98
-
99
- def _get_availability(self, provider_instance):
100
- try:
101
- available = getattr(provider_instance, "available", True)
102
- unavailable_reason = getattr(provider_instance, "unavailable_reason", None)
103
- except Exception as e:
104
- available = False
105
- unavailable_reason = f"Error reading runtime availability: {str(e)}"
106
- return available, unavailable_reason
107
-
108
- def _get_model_names(self, provider_name):
109
- provider_to_specs = {
110
- "openai": "janito.providers.openai.model_info",
111
- "azure_openai": "janito.providers.azure_openai.model_info",
112
- "google": "janito.providers.google.model_info",
113
- "mistralai": "janito.providers.mistralai.model_info",
114
- "deepseek": "janito.providers.deepseek.model_info",
115
- }
116
- if provider_name in provider_to_specs:
117
- try:
118
- mod = __import__(
119
- provider_to_specs[provider_name], fromlist=["MODEL_SPECS"]
120
- )
121
- return ", ".join(mod.MODEL_SPECS.keys())
122
- except Exception:
123
- return "(Error)"
124
- return "-"
125
-
126
- def _maintainer_sort_key(self, row):
127
- maint = row[1]
128
- is_needs_maint = "Needs maintainer" in maint
129
- return (is_needs_maint, row[2] != " Auth")
130
-
131
- def get_provider(self, provider_name):
132
- """Return the provider class for the given provider name. Returns None if not found."""
133
- from janito.providers.registry import LLMProviderRegistry
134
-
135
- if not provider_name:
136
- print("Error: Provider name must be specified.")
137
- return None
138
- provider_class = LLMProviderRegistry.get(provider_name)
139
- if provider_class is None:
140
- available = ', '.join(LLMProviderRegistry.list_providers())
141
- print(f"Error: Provider '{provider_name}' is not recognized. Available providers: {available}.")
142
- return None
143
- return provider_class
144
-
145
- def get_instance(self, provider_name, config=None):
146
- """Return an instance of the provider for the given provider name, optionally passing a config object. Returns None if not found."""
147
- provider_class = self.get_provider(provider_name)
148
- if provider_class is None:
149
- return None
150
- if config is not None:
151
- return provider_class(config=config)
152
- return provider_class()
153
-
154
-
155
- # For backward compatibility
156
- def list_providers():
157
- """Legacy function for listing providers, now uses ProviderRegistry class."""
158
- ProviderRegistry().list_providers()
1
+ """
2
+ ProviderRegistry: Handles provider listing and selection logic for janito CLI.
3
+ """
4
+
5
+ from rich.table import Table
6
+ from janito.cli.console import shared_console
7
+ from janito.providers.registry import LLMProviderRegistry
8
+ from janito.providers.provider_static_info import STATIC_PROVIDER_METADATA
9
+ from janito.llm.auth import LLMAuthManager
10
+ import sys
11
+ from janito.exceptions import MissingProviderSelectionException
12
+
13
+
14
+ class ProviderRegistry:
15
+ def list_providers(self):
16
+ """List all supported LLM providers as a table using rich, showing if auth is configured and supported model names."""
17
+ providers = self._get_provider_names()
18
+ table = self._create_table()
19
+ rows = self._get_all_provider_rows(providers)
20
+ self._add_rows_to_table(table, rows)
21
+ self._print_table(table)
22
+
23
+ def _get_provider_names(self):
24
+ return list(STATIC_PROVIDER_METADATA.keys())
25
+
26
+ def _create_table(self):
27
+ table = Table(title="Supported LLM Providers")
28
+ table.add_column("Provider", style="cyan")
29
+ table.add_column("Maintainer", style="yellow", justify="center")
30
+ table.add_column("Model Names", style="magenta")
31
+ return table
32
+
33
+ def _get_all_provider_rows(self, providers):
34
+ rows = []
35
+ for p in providers:
36
+ info = self._get_provider_info(p)
37
+ # info is (provider_name, maintainer, model_names, skip)
38
+ if len(info) == 4 and info[3]:
39
+ continue # skip providers flagged as not implemented
40
+ rows.append(info[:3])
41
+ rows.sort(key=self._maintainer_sort_key)
42
+ return rows
43
+
44
+ def _add_rows_to_table(self, table, rows):
45
+ for idx, (p, maintainer, model_names) in enumerate(rows):
46
+ table.add_row(p, maintainer, model_names)
47
+ if idx != len(rows) - 1:
48
+ table.add_section()
49
+
50
+ def _print_table(self, table):
51
+ """Print the table using rich when running in a terminal; otherwise fall back to a plain ASCII listing.
52
+ This avoids UnicodeDecodeError when the parent process captures the output with a non-UTF8 encoding.
53
+ """
54
+ import sys
55
+
56
+ if sys.stdout.isatty():
57
+ # Safe to use rich's unicode output when attached to an interactive terminal.
58
+ shared_console.print(table)
59
+ return
60
+
61
+ # Fallback: plain ASCII output
62
+ print("Supported LLM Providers")
63
+ print("Provider | Maintainer | Model Names")
64
+ for row in table.rows:
65
+ # row is a rich.table.Row -> row.cells is a list of Text objects
66
+ cells_text = [str(cell) for cell in row.cells]
67
+ ascii_row = " | ".join(cells_text).encode("ascii", "ignore").decode("ascii")
68
+ print(ascii_row)
69
+ shared_console.print(table)
70
+
71
+ def _get_provider_info(self, provider_name):
72
+ static_info = STATIC_PROVIDER_METADATA.get(provider_name, {})
73
+ maintainer_val = static_info.get("maintainer", "-")
74
+ maintainer = (
75
+ "[red]🚨 Needs maintainer[/red]"
76
+ if maintainer_val == "Needs maintainer"
77
+ else f"👤 {maintainer_val}"
78
+ )
79
+ model_names = "-"
80
+ unavailable_reason = None
81
+ skip = False
82
+ try:
83
+ provider_class = LLMProviderRegistry.get(provider_name)
84
+ creds = LLMAuthManager().get_credentials(provider_name)
85
+ provider_instance = None
86
+ instantiation_failed = False
87
+ try:
88
+ provider_instance = provider_class()
89
+ except NotImplementedError:
90
+ skip = True
91
+ unavailable_reason = "Not implemented"
92
+ model_names = f"[red]❌ Not implemented[/red]"
93
+ except Exception as e:
94
+ instantiation_failed = True
95
+ unavailable_reason = (
96
+ f"Unavailable (import error or missing dependency): {str(e)}"
97
+ )
98
+ model_names = f"[red]❌ {unavailable_reason}[/red]"
99
+ if not instantiation_failed and provider_instance is not None:
100
+ available, unavailable_reason = self._get_availability(
101
+ provider_instance
102
+ )
103
+ if (
104
+ not available
105
+ and unavailable_reason
106
+ and "not implemented" in str(unavailable_reason).lower()
107
+ ):
108
+ skip = True
109
+ if available:
110
+ model_names = self._get_model_names(provider_name)
111
+ else:
112
+ model_names = f"[red]❌ {unavailable_reason}[/red]"
113
+ except Exception as import_error:
114
+ model_names = f"[red]❌ Unavailable (cannot import provider module): {str(import_error)}[/red]"
115
+ return (provider_name, maintainer, model_names, skip)
116
+
117
+ def _get_availability(self, provider_instance):
118
+ try:
119
+ available = getattr(provider_instance, "available", True)
120
+ unavailable_reason = getattr(provider_instance, "unavailable_reason", None)
121
+ except Exception as e:
122
+ available = False
123
+ unavailable_reason = f"Error reading runtime availability: {str(e)}"
124
+ return available, unavailable_reason
125
+
126
+ def _get_model_names(self, provider_name):
127
+ provider_to_specs = {
128
+ "openai": "janito.providers.openai.model_info",
129
+ "azure_openai": "janito.providers.azure_openai.model_info",
130
+ "google": "janito.providers.google.model_info",
131
+ "mistralai": "janito.providers.mistralai.model_info",
132
+ "deepseek": "janito.providers.deepseek.model_info",
133
+ }
134
+ if provider_name in provider_to_specs:
135
+ try:
136
+ mod = __import__(
137
+ provider_to_specs[provider_name], fromlist=["MODEL_SPECS"]
138
+ )
139
+ return ", ".join(mod.MODEL_SPECS.keys())
140
+ except Exception:
141
+ return "(Error)"
142
+ return "-"
143
+
144
+ def _maintainer_sort_key(self, row):
145
+ maint = row[1]
146
+ is_needs_maint = "Needs maintainer" in maint
147
+ return (is_needs_maint, row[2] != "✅ Auth")
148
+
149
+ def get_provider(self, provider_name):
150
+ """Return the provider class for the given provider name. Returns None if not found."""
151
+ from janito.providers.registry import LLMProviderRegistry
152
+
153
+ if not provider_name:
154
+ print("Error: Provider name must be specified.")
155
+ return None
156
+ provider_class = LLMProviderRegistry.get(provider_name)
157
+ if provider_class is None:
158
+ available = ', '.join(LLMProviderRegistry.list_providers())
159
+ print(f"Error: Provider '{provider_name}' is not recognized. Available providers: {available}.")
160
+ return None
161
+ return provider_class
162
+
163
+ def get_instance(self, provider_name, config=None):
164
+ """Return an instance of the provider for the given provider name, optionally passing a config object. Returns None if not found."""
165
+ provider_class = self.get_provider(provider_name)
166
+ if provider_class is None:
167
+ return None
168
+ if config is not None:
169
+ return provider_class(config=config)
170
+ return provider_class()
171
+
172
+
173
+ # For backward compatibility
174
+ def list_providers():
175
+ """Legacy function for listing providers, now uses ProviderRegistry class."""
176
+ ProviderRegistry().list_providers()
@@ -1,5 +1,6 @@
1
1
  # Ensure all providers are registered by importing their modules
2
2
  import janito.providers.openai.provider
3
+ import janito.providers.google.provider
3
4
  import janito.providers.mistralai.provider
4
5
  import janito.providers.google.provider
5
6
  import janito.providers.azure_openai.provider
@@ -1,22 +1,22 @@
1
- from janito.llm.model import LLMModelInfo
2
-
3
- MODEL_SPECS = {
4
- "claude-3-opus-20240229": LLMModelInfo(
5
- name="claude-3-opus-20240229",
6
- max_response=200000,
7
- default_temp=0.7,
8
- driver="AnthropicModelDriver",
9
- ),
10
- "claude-3-sonnet-20240229": LLMModelInfo(
11
- name="claude-3-sonnet-20240229",
12
- max_response=200000,
13
- default_temp=0.7,
14
- driver="AnthropicModelDriver",
15
- ),
16
- "claude-3-haiku-20240307": LLMModelInfo(
17
- name="claude-3-haiku-20240307",
18
- max_response=200000,
19
- default_temp=0.7,
20
- driver="AnthropicModelDriver",
21
- ),
22
- }
1
+ from janito.llm.model import LLMModelInfo
2
+
3
+ MODEL_SPECS = {
4
+ "claude-3-opus-20240229": LLMModelInfo(
5
+ name="claude-3-opus-20240229",
6
+ max_response=200000,
7
+ default_temp=0.7,
8
+ driver="AnthropicModelDriver",
9
+ ),
10
+ "claude-3-sonnet-20240229": LLMModelInfo(
11
+ name="claude-3-sonnet-20240229",
12
+ max_response=200000,
13
+ default_temp=0.7,
14
+ driver="AnthropicModelDriver",
15
+ ),
16
+ "claude-3-haiku-20240307": LLMModelInfo(
17
+ name="claude-3-haiku-20240307",
18
+ max_response=200000,
19
+ default_temp=0.7,
20
+ driver="AnthropicModelDriver",
21
+ ),
22
+ }
@@ -2,7 +2,7 @@ from janito.llm.provider import LLMProvider
2
2
  from janito.llm.model import LLMModelInfo
3
3
  from janito.llm.auth import LLMAuthManager
4
4
  from janito.llm.driver_config import LLMDriverConfig
5
- from janito.tools.adapters.local.adapter import LocalToolsAdapter
5
+ from janito.tools import get_local_tools_adapter
6
6
  from janito.providers.registry import LLMProviderRegistry
7
7
 
8
8
  from .model_info import MODEL_SPECS
@@ -28,7 +28,7 @@ class AnthropicProvider(LLMProvider):
28
28
  return
29
29
  self.auth_manager = auth_manager or LLMAuthManager()
30
30
  self._api_key = self.auth_manager.get_credentials(type(self).name)
31
- self._tools_adapter = LocalToolsAdapter()
31
+ self._tools_adapter = get_local_tools_adapter()
32
32
  self._info = config or LLMDriverConfig(model=None)
33
33
  if not self._info.model:
34
34
  self._info.model = self.DEFAULT_MODEL
@@ -1,14 +1,15 @@
1
1
  from janito.llm.model import LLMModelInfo
2
+ from janito.providers.openai.model_info import MODEL_SPECS as OPENAI_MODEL_SPECS
2
3
 
3
4
  MODEL_SPECS = {
4
5
  "azure_openai_deployment": LLMModelInfo(
5
6
  name="azure_openai_deployment",
6
- context="N/A",
7
- max_input="N/A",
8
- max_cot="N/A",
9
- max_response="N/A",
10
- thinking_supported=False,
11
- default_temp=0.2,
7
+ context=OPENAI_MODEL_SPECS["gpt-4o"].context,
8
+ max_input=OPENAI_MODEL_SPECS["gpt-4o"].max_input,
9
+ max_cot=OPENAI_MODEL_SPECS["gpt-4o"].max_cot,
10
+ max_response=OPENAI_MODEL_SPECS["gpt-4o"].max_response,
11
+ thinking_supported=OPENAI_MODEL_SPECS["gpt-4o"].thinking_supported,
12
+ default_temp=OPENAI_MODEL_SPECS["gpt-4o"].default_temp,
12
13
  open="azure_openai",
13
14
  driver="AzureOpenAIModelDriver",
14
15
  )
@@ -2,7 +2,7 @@ from janito.llm.provider import LLMProvider
2
2
  from janito.llm.model import LLMModelInfo
3
3
  from janito.llm.auth import LLMAuthManager
4
4
  from janito.llm.driver_config import LLMDriverConfig
5
- from janito.tools.adapters.local.adapter import LocalToolsAdapter
5
+ from janito.tools import get_local_tools_adapter
6
6
  from janito.providers.registry import LLMProviderRegistry
7
7
 
8
8
  from .model_info import MODEL_SPECS
@@ -28,7 +28,7 @@ class AzureOpenAIProvider(LLMProvider):
28
28
  return
29
29
  self._auth_manager = auth_manager or LLMAuthManager()
30
30
  self._api_key = self._auth_manager.get_credentials(type(self).name)
31
- self._tools_adapter = LocalToolsAdapter()
31
+ self._tools_adapter = get_local_tools_adapter()
32
32
  self._driver_config = config or LLMDriverConfig(model=None)
33
33
  if not self._driver_config.model:
34
34
  self._driver_config.model = self.DEFAULT_MODEL
@@ -36,6 +36,11 @@ class AzureOpenAIProvider(LLMProvider):
36
36
  self._driver_config.api_key = self._api_key
37
37
  if not self._driver_config.extra.get("api_version"):
38
38
  self._driver_config.extra["api_version"] = "2023-05-15"
39
+ # Inject azure_deployment_name from config if present
40
+ from janito.config import config as global_config
41
+ deployment_name = global_config.get("azure_deployment_name")
42
+ if deployment_name:
43
+ self._driver_config.extra["azure_deployment_name"] = deployment_name
39
44
  self.fill_missing_device_info(self._driver_config)
40
45
  self._driver = AzureOpenAIModelDriver(tools_adapter=self._tools_adapter)
41
46
 
@@ -61,6 +66,29 @@ class AzureOpenAIProvider(LLMProvider):
61
66
  """
62
67
  return True
63
68
 
69
+ def get_model_info(self, model_name=None):
70
+ """
71
+ For Azure OpenAI, accept any deployment name as a valid model name.
72
+ If the model_name is not in MODEL_SPECS, return a generic info dict.
73
+ """
74
+ if model_name is None:
75
+ # Return all known specs, but note: only static ones are listed
76
+ return {name: model_info.to_dict() for name, model_info in self.MODEL_SPECS.items()}
77
+ if model_name in self.MODEL_SPECS:
78
+ return self.MODEL_SPECS[model_name].to_dict()
79
+ # Accept any deployment name as a valid model
80
+ return {
81
+ "name": model_name,
82
+ "context": "N/A",
83
+ "max_input": "N/A",
84
+ "max_cot": "N/A",
85
+ "max_response": "N/A",
86
+ "thinking_supported": False,
87
+ "default_temp": 0.2,
88
+ "open": "azure_openai",
89
+ "driver": "AzureOpenAIModelDriver",
90
+ }
91
+
64
92
  def create_driver(self):
65
93
  """
66
94
  Creates and returns a new AzureOpenAIModelDriver instance with the provider's configuration and tools adapter.
@@ -1 +1 @@
1
- # Deepseek provider package marker
1
+ # Deepseek provider package marker
@@ -1,16 +1,16 @@
1
- MODEL_SPECS = {
2
- "deepseek-chat": {
3
- "description": "DeepSeek Chat Model (OpenAI-compatible)",
4
- "context_window": 8192,
5
- "max_tokens": 4096,
6
- "family": "deepseek",
7
- "default": True,
8
- },
9
- "deepseek-reasoner": {
10
- "description": "DeepSeek Reasoner Model (OpenAI-compatible)",
11
- "context_window": 8192,
12
- "max_tokens": 4096,
13
- "family": "deepseek",
14
- "default": False,
15
- },
16
- }
1
+ MODEL_SPECS = {
2
+ "deepseek-chat": {
3
+ "description": "DeepSeek Chat Model (OpenAI-compatible)",
4
+ "context_window": 8192,
5
+ "max_tokens": 4096,
6
+ "family": "deepseek",
7
+ "default": True,
8
+ },
9
+ "deepseek-reasoner": {
10
+ "description": "DeepSeek Reasoner Model (OpenAI-compatible)",
11
+ "context_window": 8192,
12
+ "max_tokens": 4096,
13
+ "family": "deepseek",
14
+ "default": False,
15
+ },
16
+ }