janito 3.2.0__py3-none-any.whl → 3.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 (166) hide show
  1. janito/README.md +0 -3
  2. janito/cli/chat_mode/bindings.py +0 -26
  3. janito/cli/chat_mode/session.py +1 -12
  4. janito/cli/chat_mode/shell/commands/security/allowed_sites.py +33 -47
  5. janito/cli/cli_commands/list_plugins.py +8 -13
  6. janito/cli/core/model_guesser.py +24 -40
  7. janito/cli/prompt_core.py +9 -20
  8. janito/i18n/it.py +46 -46
  9. janito/llm/agent.py +16 -32
  10. janito/llm/driver.py +0 -8
  11. janito/{plugin_system → plugin_system_backup_20250825_070018}/core_loader.py +3 -76
  12. janito/{plugin_system → plugin_system_backup_20250825_070018}/core_loader_fixed.py +3 -79
  13. janito/plugins/__init__.py +21 -29
  14. janito/plugins/__main__.py +85 -0
  15. janito/plugins/base.py +57 -0
  16. janito/plugins/builtin.py +1 -1
  17. janito/plugins/core/filemanager/tools/copy_file.py +25 -1
  18. janito/plugins/core/filemanager/tools/create_directory.py +28 -1
  19. janito/plugins/core/filemanager/tools/create_file.py +27 -3
  20. janito/plugins/core/filemanager/tools/delete_text_in_file.py +1 -0
  21. janito/plugins/core/imagedisplay/plugin.py +1 -1
  22. janito/plugins/core_loader.py +144 -0
  23. janito/plugins/discovery.py +3 -3
  24. janito/plugins/example_plugin.py +1 -1
  25. janito/plugins/manager.py +1 -1
  26. janito/plugins_backup_20250825_070018/__init__.py +36 -0
  27. janito/{plugins → plugins_backup_20250825_070018}/auto_loader.py +11 -12
  28. janito/plugins_backup_20250825_070018/builtin.py +102 -0
  29. janito/plugins_backup_20250825_070018/config.py +84 -0
  30. janito/plugins_backup_20250825_070018/core/__init__.py +7 -0
  31. janito/plugins_backup_20250825_070018/core/codeanalyzer/__init__.py +43 -0
  32. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/__init__.py +1 -0
  33. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/core.py +122 -0
  34. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/__init__.py +1 -0
  35. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/core.py +205 -0
  36. janito/plugins_backup_20250825_070018/core/filemanager/__init__.py +124 -0
  37. janito/plugins_backup_20250825_070018/core/filemanager/tools/copy_file.py +87 -0
  38. janito/plugins_backup_20250825_070018/core/filemanager/tools/create_directory.py +70 -0
  39. janito/plugins_backup_20250825_070018/core/filemanager/tools/create_file.py +87 -0
  40. janito/plugins_backup_20250825_070018/core/filemanager/tools/delete_text_in_file.py +135 -0
  41. janito/plugins_backup_20250825_070018/core/filemanager/tools/find_files.py +143 -0
  42. janito/plugins_backup_20250825_070018/core/filemanager/tools/move_file.py +131 -0
  43. janito/plugins_backup_20250825_070018/core/filemanager/tools/read_files.py +58 -0
  44. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_directory.py +55 -0
  45. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_file.py +58 -0
  46. janito/plugins_backup_20250825_070018/core/filemanager/tools/replace_text_in_file.py +270 -0
  47. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/__init__.py +1 -0
  48. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/core.py +114 -0
  49. janito/plugins_backup_20250825_070018/core/filemanager/tools/view_file.py +172 -0
  50. janito/plugins_backup_20250825_070018/core/imagedisplay/__init__.py +14 -0
  51. janito/plugins_backup_20250825_070018/core/imagedisplay/plugin.py +51 -0
  52. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/__init__.py +1 -0
  53. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image.py +83 -0
  54. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image_grid.py +84 -0
  55. janito/plugins_backup_20250825_070018/core/system/__init__.py +23 -0
  56. janito/plugins_backup_20250825_070018/core/system/tools/run_bash_command.py +183 -0
  57. janito/plugins_backup_20250825_070018/core/system/tools/run_powershell_command.py +218 -0
  58. janito/plugins_backup_20250825_070018/core_adapter.py +55 -0
  59. janito/plugins_backup_20250825_070018/dev/__init__.py +7 -0
  60. janito/plugins_backup_20250825_070018/dev/pythondev/__init__.py +37 -0
  61. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_code_run.py +172 -0
  62. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_command_run.py +171 -0
  63. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_file_run.py +172 -0
  64. janito/plugins_backup_20250825_070018/dev/visualization/__init__.py +23 -0
  65. janito/plugins_backup_20250825_070018/dev/visualization/tools/read_chart.py +259 -0
  66. janito/plugins_backup_20250825_070018/discovery.py +289 -0
  67. janito/{plugins → plugins_backup_20250825_070018}/discovery_core.py +9 -14
  68. janito/plugins_backup_20250825_070018/example_plugin.py +108 -0
  69. janito/plugins_backup_20250825_070018/manager.py +243 -0
  70. janito/{plugins → plugins_backup_20250825_070018}/tools/core_tools_plugin.py +10 -9
  71. janito/{plugins → plugins_backup_20250825_070018}/tools/create_file.py +2 -2
  72. janito/{plugins → plugins_backup_20250825_070018}/tools/delete_text_in_file.py +1 -0
  73. janito/plugins_backup_20250825_070018/tools/get_file_outline/java_outline.py +47 -0
  74. janito/plugins_backup_20250825_070018/tools/get_file_outline/markdown_outline.py +14 -0
  75. janito/plugins_backup_20250825_070018/tools/get_file_outline/python_outline.py +303 -0
  76. janito/plugins_backup_20250825_070018/tools/get_file_outline/search_outline.py +36 -0
  77. janito/plugins_backup_20250825_070018/tools/search_text/match_lines.py +67 -0
  78. janito/plugins_backup_20250825_070018/tools/search_text/pattern_utils.py +73 -0
  79. janito/plugins_backup_20250825_070018/tools/search_text/traverse_directory.py +145 -0
  80. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/css_validator.py +35 -0
  81. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/html_validator.py +100 -0
  82. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/jinja2_validator.py +50 -0
  83. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/js_validator.py +27 -0
  84. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/json_validator.py +6 -0
  85. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/markdown_validator.py +109 -0
  86. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/ps1_validator.py +32 -0
  87. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/python_validator.py +5 -0
  88. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/xml_validator.py +11 -0
  89. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/yaml_validator.py +6 -0
  90. janito/plugins_backup_20250825_070018/ui/__init__.py +7 -0
  91. janito/plugins_backup_20250825_070018/ui/userinterface/__init__.py +16 -0
  92. janito/plugins_backup_20250825_070018/ui/userinterface/tools/ask_user.py +110 -0
  93. janito/plugins_backup_20250825_070018/web/__init__.py +7 -0
  94. janito/plugins_backup_20250825_070018/web/webtools/__init__.py +33 -0
  95. janito/plugins_backup_20250825_070018/web/webtools/tools/fetch_url.py +458 -0
  96. janito/plugins_backup_20250825_070018/web/webtools/tools/open_html_in_browser.py +51 -0
  97. janito/plugins_backup_20250825_070018/web/webtools/tools/open_url.py +37 -0
  98. janito/providers/__init__.py +0 -1
  99. janito/tools/base.py +31 -1
  100. janito/tools/cli_initializer.py +1 -1
  101. janito/tools/function_adapter.py +176 -0
  102. janito/tools/initialize.py +1 -1
  103. janito/tools/loop_protection_decorator.py +117 -114
  104. janito/tools/tool_base.py +142 -114
  105. janito/tools/tools_schema.py +12 -6
  106. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/METADATA +1 -1
  107. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/RECORD +160 -95
  108. janito/llm/cancellation_manager.py +0 -63
  109. janito/llm/enter_cancellation.py +0 -107
  110. janito/plugins/core_adapter.py +0 -131
  111. janito/providers/together/__init__.py +0 -1
  112. janito/providers/together/model_info.py +0 -69
  113. janito/providers/together/provider.py +0 -108
  114. /janito/{plugin_system → plugin_system_backup_20250825_070018}/__init__.py +0 -0
  115. /janito/{plugin_system → plugin_system_backup_20250825_070018}/base.py +0 -0
  116. /janito/{plugins → plugins_backup_20250825_070018}/auto_loader_fixed.py +0 -0
  117. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/java_outline.py +0 -0
  118. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/markdown_outline.py +0 -0
  119. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/python_outline.py +0 -0
  120. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/search_outline.py +0 -0
  121. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/match_lines.py +0 -0
  122. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/pattern_utils.py +0 -0
  123. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/traverse_directory.py +0 -0
  124. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/css_validator.py +0 -0
  125. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/html_validator.py +0 -0
  126. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/jinja2_validator.py +0 -0
  127. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/js_validator.py +0 -0
  128. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/json_validator.py +0 -0
  129. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/markdown_validator.py +0 -0
  130. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/ps1_validator.py +0 -0
  131. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/python_validator.py +0 -0
  132. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/xml_validator.py +0 -0
  133. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/yaml_validator.py +0 -0
  134. /janito/{plugins → plugins_backup_20250825_070018}/tools/__init__.py +0 -0
  135. /janito/{plugins → plugins_backup_20250825_070018}/tools/ask_user.py +0 -0
  136. /janito/{plugins → plugins_backup_20250825_070018}/tools/copy_file.py +0 -0
  137. /janito/{plugins → plugins_backup_20250825_070018}/tools/create_directory.py +0 -0
  138. /janito/{plugins → plugins_backup_20250825_070018}/tools/decorators.py +0 -0
  139. /janito/{plugins → plugins_backup_20250825_070018}/tools/fetch_url.py +0 -0
  140. /janito/{plugins → plugins_backup_20250825_070018}/tools/find_files.py +0 -0
  141. /janito/{plugins → plugins_backup_20250825_070018}/tools/get_file_outline/__init__.py +0 -0
  142. /janito/{plugins → plugins_backup_20250825_070018}/tools/get_file_outline/core.py +0 -0
  143. /janito/{plugins → plugins_backup_20250825_070018}/tools/move_file.py +0 -0
  144. /janito/{plugins → plugins_backup_20250825_070018}/tools/open_html_in_browser.py +0 -0
  145. /janito/{plugins → plugins_backup_20250825_070018}/tools/open_url.py +0 -0
  146. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_code_run.py +0 -0
  147. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_command_run.py +0 -0
  148. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_file_run.py +0 -0
  149. /janito/{plugins → plugins_backup_20250825_070018}/tools/read_chart.py +0 -0
  150. /janito/{plugins → plugins_backup_20250825_070018}/tools/read_files.py +0 -0
  151. /janito/{plugins → plugins_backup_20250825_070018}/tools/remove_directory.py +0 -0
  152. /janito/{plugins → plugins_backup_20250825_070018}/tools/remove_file.py +0 -0
  153. /janito/{plugins → plugins_backup_20250825_070018}/tools/replace_text_in_file.py +0 -0
  154. /janito/{plugins → plugins_backup_20250825_070018}/tools/run_bash_command.py +0 -0
  155. /janito/{plugins → plugins_backup_20250825_070018}/tools/run_powershell_command.py +0 -0
  156. /janito/{plugins → plugins_backup_20250825_070018}/tools/search_text/__init__.py +0 -0
  157. /janito/{plugins → plugins_backup_20250825_070018}/tools/search_text/core.py +0 -0
  158. /janito/{plugins → plugins_backup_20250825_070018}/tools/show_image.py +0 -0
  159. /janito/{plugins → plugins_backup_20250825_070018}/tools/show_image_grid.py +0 -0
  160. /janito/{plugins → plugins_backup_20250825_070018}/tools/validate_file_syntax/__init__.py +0 -0
  161. /janito/{plugins → plugins_backup_20250825_070018}/tools/validate_file_syntax/core.py +0 -0
  162. /janito/{plugins → plugins_backup_20250825_070018}/tools/view_file.py +0 -0
  163. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/WHEEL +0 -0
  164. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/entry_points.txt +0 -0
  165. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/licenses/LICENSE +0 -0
  166. {janito-3.2.0.dist-info → janito-3.3.0.dist-info}/top_level.txt +0 -0
@@ -1,131 +0,0 @@
1
- """
2
- Core plugin adapter for legacy plugin system.
3
-
4
- This module provides proper Plugin class implementations for core plugins
5
- that use the function-based approach instead of class-based.
6
- """
7
-
8
- from janito.plugin_system.base import Plugin, PluginMetadata
9
- from typing import List, Type
10
- from janito.tools.tool_base import ToolBase, ToolPermissions
11
-
12
-
13
- class CorePluginAdapter(Plugin):
14
- """Adapter for core plugins using function-based tools."""
15
-
16
- def __init__(self, plugin_name: str, description: str, tools_module):
17
- super().__init__()
18
- self._plugin_name = plugin_name
19
- self._description = description
20
- self._tools_module = tools_module
21
- self._tool_classes = []
22
-
23
- # Set the metadata attribute that Plugin expects
24
- self.metadata = self.get_metadata()
25
-
26
- def get_metadata(self) -> PluginMetadata:
27
- return PluginMetadata(
28
- name=self._plugin_name,
29
- version="1.0.0",
30
- description=self._description,
31
- author="Janito",
32
- license="MIT",
33
- )
34
-
35
- def get_tools(self) -> List[Type[ToolBase]]:
36
- return self._tool_classes
37
-
38
- def _create_tool_class(self, func):
39
- """Create a ToolBase class from a function."""
40
- resolved_tool_name = getattr(func, "tool_name", func.__name__)
41
-
42
- # Create a proper tool class with explicit parameters and documentation
43
- import inspect
44
- from typing import get_type_hints
45
-
46
- func_sig = inspect.signature(func)
47
- type_hints = get_type_hints(func)
48
-
49
- # Build parameter definitions for the run method
50
- param_defs = []
51
- param_docs = []
52
- for name, param in func_sig.parameters.items():
53
- type_hint = type_hints.get(name, str)
54
- if param.default == inspect.Parameter.empty:
55
- param_defs.append(f"{name}: {type_hint.__name__}")
56
- else:
57
- param_defs.append(f"{name}: {type_hint.__name__} = {repr(param.default)}")
58
-
59
- # Add parameter documentation
60
- param_docs.append(f" {name}: {type_hint.__name__} - Parameter {name}")
61
-
62
- # Get function docstring or create one
63
- func_doc = func.__doc__ or f"Execute {resolved_tool_name} tool"
64
-
65
- # Create the tool class with proper signature and documentation
66
- exec_globals = {
67
- 'ToolBase': ToolBase,
68
- 'ToolPermissions': ToolPermissions,
69
- 'func': func,
70
- 'inspect': inspect,
71
- 'str': str,
72
- 'List': list,
73
- 'Dict': dict,
74
- 'Optional': type(None),
75
- }
76
-
77
- param_docs_str = '\n'.join(param_docs)
78
-
79
- class_def = f'''
80
- class DynamicTool(ToolBase):
81
- """
82
- {func_doc}
83
-
84
- Parameters:
85
- {param_docs_str}
86
-
87
- Returns:
88
- str: Execution result
89
- """
90
- tool_name = "{resolved_tool_name}"
91
- permissions = ToolPermissions(read=True, write=True, execute=True)
92
-
93
- def __init__(self):
94
- super().__init__()
95
-
96
- def run(self, {', '.join(param_defs)}) -> str:
97
- kwargs = locals()
98
- sig = inspect.signature(func)
99
-
100
- # Filter kwargs to only include parameters the function accepts
101
- filtered_kwargs = {{}}
102
- for name, param in sig.parameters.items():
103
- if name in kwargs and kwargs[name] is not None:
104
- filtered_kwargs[name] = kwargs[name]
105
-
106
- result = func(**filtered_kwargs)
107
- return str(result) if result is not None else ""
108
- '''
109
-
110
- exec(class_def, exec_globals)
111
- return exec_globals['DynamicTool']
112
-
113
- return DynamicTool
114
-
115
- def initialize(self):
116
- """Initialize the plugin by creating tool classes."""
117
- # Get tools from the module
118
- tools = getattr(self._tools_module, "__plugin_tools__", [])
119
-
120
- self._tool_classes = []
121
- for tool_func in tools:
122
- if callable(tool_func):
123
- tool_class = self._create_tool_class(tool_func)
124
- self._tool_classes.append(tool_class)
125
-
126
-
127
- def create_core_plugin(
128
- plugin_name: str, description: str, tools_module
129
- ) -> CorePluginAdapter:
130
- """Create a core plugin adapter."""
131
- return CorePluginAdapter(plugin_name, description, tools_module)
@@ -1 +0,0 @@
1
- # Together AI provider for Janito
@@ -1,69 +0,0 @@
1
- """
2
- Model specifications for Together AI provider.
3
- """
4
-
5
- MODEL_SPECS = {
6
- "allenai/OLMo-2-0325-32B-Instruct": {
7
- "max_tokens": 32768,
8
- "max_input_tokens": 32768,
9
- "max_output_tokens": 32768,
10
- "description": "OLMo 2 32B Instruct - Fully open language model from AllenAI",
11
- "supports_tools": True,
12
- "supports_system_prompt": True,
13
- "supports_streaming": True,
14
- },
15
- "allenai/OLMo-2-1124-7B-Instruct": {
16
- "max_tokens": 32768,
17
- "max_input_tokens": 32768,
18
- "max_output_tokens": 32768,
19
- "description": "OLMo 2 7B Instruct - Fully open language model from AllenAI",
20
- "supports_tools": True,
21
- "supports_system_prompt": True,
22
- "supports_streaming": True,
23
- },
24
- "allenai/OLMo-2-0425-1B": {
25
- "max_tokens": 32768,
26
- "max_input_tokens": 32768,
27
- "max_output_tokens": 32768,
28
- "description": "OLMo 2 1B - Fully open language model from AllenAI",
29
- "supports_tools": True,
30
- "supports_system_prompt": True,
31
- "supports_streaming": True,
32
- },
33
- "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo": {
34
- "max_tokens": 8192,
35
- "max_input_tokens": 128000,
36
- "max_output_tokens": 8192,
37
- "description": "Llama 3.1 8B Instruct Turbo",
38
- "supports_tools": True,
39
- "supports_system_prompt": True,
40
- "supports_streaming": True,
41
- },
42
- "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo": {
43
- "max_tokens": 8192,
44
- "max_input_tokens": 128000,
45
- "max_output_tokens": 8192,
46
- "description": "Llama 3.1 70B Instruct Turbo",
47
- "supports_tools": True,
48
- "supports_system_prompt": True,
49
- "supports_streaming": True,
50
- },
51
- "mistralai/Mixtral-8x7B-Instruct-v0.1": {
52
- "max_tokens": 32768,
53
- "max_input_tokens": 32768,
54
- "max_output_tokens": 32768,
55
- "description": "Mixtral 8x7B Instruct",
56
- "supports_tools": True,
57
- "supports_system_prompt": True,
58
- "supports_streaming": True,
59
- },
60
- "deepseek-ai/deepseek-llm-67b-chat": {
61
- "max_tokens": 4096,
62
- "max_input_tokens": 4096,
63
- "max_output_tokens": 4096,
64
- "description": "DeepSeek LLM 67B Chat",
65
- "supports_tools": True,
66
- "supports_system_prompt": True,
67
- "supports_streaming": True,
68
- },
69
- }
@@ -1,108 +0,0 @@
1
- from janito.llm.provider import LLMProvider
2
- from janito.llm.model import LLMModelInfo
3
- from janito.llm.auth import LLMAuthManager
4
- from janito.llm.driver_config import LLMDriverConfig
5
- from janito.drivers.openai.driver import OpenAIModelDriver
6
- from janito.tools import get_local_tools_adapter
7
- from janito.providers.registry import LLMProviderRegistry
8
- from .model_info import MODEL_SPECS
9
- from queue import Queue
10
-
11
- available = OpenAIModelDriver.available
12
- unavailable_reason = OpenAIModelDriver.unavailable_reason
13
-
14
-
15
- class TogetherProvider(LLMProvider):
16
- name = 'together'
17
- NAME = 'together'
18
- MAINTAINER = 'Janito Team'
19
- MODEL_SPECS = MODEL_SPECS
20
- DEFAULT_MODEL = 'allenai/OLMo-2-0325-32B-Instruct'
21
-
22
- def __init__(
23
- self, auth_manager: LLMAuthManager = None, config: LLMDriverConfig = None
24
- ):
25
- self._tools_adapter = get_local_tools_adapter()
26
- self._driver = None
27
-
28
- if not self.available:
29
- return
30
-
31
- self._initialize_config(auth_manager, config)
32
- self._setup_model_config()
33
-
34
- def _initialize_config(self, auth_manager, config):
35
- self.auth_manager = auth_manager or LLMAuthManager()
36
- self._api_key = self.auth_manager.get_credentials(type(self).NAME)
37
- if not self._api_key:
38
- from janito.llm.auth_utils import handle_missing_api_key
39
- handle_missing_api_key(self.name, 'TOGETHER_API_KEY')
40
-
41
- self._driver_config = config or LLMDriverConfig(model=None)
42
- if not self._driver_config.model:
43
- self._driver_config.model = self.DEFAULT_MODEL
44
- if not self._driver_config.api_key:
45
- self._driver_config.api_key = self._api_key
46
-
47
- self._driver_config.base_url = 'https://api.together.xyz/v1'
48
-
49
- def _setup_model_config(self):
50
- model_name = self._driver_config.model
51
- model_spec = self.MODEL_SPECS.get(model_name)
52
-
53
- if hasattr(self._driver_config, 'max_tokens'):
54
- self._driver_config.max_tokens = None
55
- if hasattr(self._driver_config, 'max_completion_tokens'):
56
- self._driver_config.max_completion_tokens = None
57
-
58
- if model_spec:
59
- max_tokens = getattr(model_spec, 'max_tokens', None)
60
- if max_tokens and max_tokens != 'N/A':
61
- self._driver_config.max_tokens = int(max_tokens)
62
-
63
- self.fill_missing_device_info(self._driver_config)
64
-
65
- @property
66
- def driver(self) -> OpenAIModelDriver:
67
- if not self.available:
68
- raise ImportError(f'TogetherProvider unavailable: {self.unavailable_reason}')
69
- return self._driver
70
-
71
- @property
72
- def available(self):
73
- return available
74
-
75
- @property
76
- def unavailable_reason(self):
77
- return unavailable_reason
78
-
79
- def create_driver(self):
80
- driver = OpenAIModelDriver(
81
- tools_adapter=self._tools_adapter, provider_name=self.NAME
82
- )
83
- driver.config = self._driver_config
84
- return driver
85
-
86
- def create_agent(self, tools_adapter=None, agent_name: str = None, **kwargs):
87
- from janito.llm.agent import LLMAgent
88
- if tools_adapter is None:
89
- tools_adapter = get_local_tools_adapter()
90
- raise NotImplementedError(
91
- 'create_agent must be constructed via new factory using input/output queues and config.'
92
- )
93
-
94
- @property
95
- def model_name(self):
96
- return self._driver_config.model
97
-
98
- @property
99
- def driver_config(self):
100
- return self._driver_config
101
-
102
- def execute_tool(self, tool_name: str, event_bus, *args, **kwargs):
103
- self._tools_adapter.event_bus = event_bus
104
- return self._tools_adapter.execute_by_name(tool_name, *args, **kwargs)
105
-
106
-
107
- LLMProviderRegistry.register(TogetherProvider.NAME, TogetherProvider)
108
-
File without changes