janito 3.12.0__py3-none-any.whl → 3.12.1__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.
- janito/README.md +191 -191
- janito/_version.py +55 -55
- janito/cli/cli_commands/list_drivers.py +162 -162
- janito/cli/console.py +3 -3
- janito/cli/rich_terminal_reporter.py +2 -4
- janito/docs/GETTING_STARTED.md +189 -189
- janito/plugins/discovery.py +289 -289
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/METADATA +5 -4
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/RECORD +13 -14
- janito/mkdocs.yml +0 -40
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/WHEEL +0 -0
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/entry_points.txt +0 -0
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/licenses/LICENSE +0 -0
- {janito-3.12.0.dist-info → janito-3.12.1.dist-info}/top_level.txt +0 -0
@@ -1,162 +1,162 @@
|
|
1
|
-
"""
|
2
|
-
CLI Command: List available LLM drivers and their dependencies
|
3
|
-
"""
|
4
|
-
|
5
|
-
import importlib
|
6
|
-
import sys
|
7
|
-
from pathlib import Path
|
8
|
-
from rich.console import Console
|
9
|
-
from rich.table import Table
|
10
|
-
from rich.panel import Panel
|
11
|
-
from rich.text import Text
|
12
|
-
|
13
|
-
console = Console()
|
14
|
-
|
15
|
-
|
16
|
-
def _detect_dependencies_from_content(content, class_name):
|
17
|
-
"""Detect dependencies from module content."""
|
18
|
-
dependencies = []
|
19
|
-
|
20
|
-
if "import openai" in content or "from openai" in content:
|
21
|
-
dependencies.append("openai")
|
22
|
-
if "import zai" in content or "from zai" in content:
|
23
|
-
dependencies.append("zai")
|
24
|
-
if "import anthropic" in content or "from anthropic" in content:
|
25
|
-
dependencies.append("anthropic")
|
26
|
-
if "import google" in content or "from google" in content:
|
27
|
-
dependencies.append("google-generativeai")
|
28
|
-
|
29
|
-
# Remove openai from zai driver dependencies
|
30
|
-
if "ZAIModelDriver" in class_name and "openai" in dependencies:
|
31
|
-
dependencies.remove("openai")
|
32
|
-
|
33
|
-
return dependencies
|
34
|
-
|
35
|
-
|
36
|
-
def _check_dependency_status(dependencies):
|
37
|
-
"""Check if dependencies are available."""
|
38
|
-
if not dependencies:
|
39
|
-
return ["No external dependencies"]
|
40
|
-
|
41
|
-
dep_status = []
|
42
|
-
for dep in dependencies:
|
43
|
-
try:
|
44
|
-
importlib.import_module(dep)
|
45
|
-
dep_status.append(f"✅ {dep}")
|
46
|
-
except ImportError:
|
47
|
-
dep_status.append(f"❌ {dep}")
|
48
|
-
|
49
|
-
return dep_status
|
50
|
-
|
51
|
-
|
52
|
-
def _get_single_driver_info(module_path, class_name):
|
53
|
-
"""Get information for a single driver."""
|
54
|
-
try:
|
55
|
-
module = importlib.import_module(module_path)
|
56
|
-
driver_class = getattr(module, class_name)
|
57
|
-
|
58
|
-
available = getattr(driver_class, "available", True)
|
59
|
-
unavailable_reason = getattr(driver_class, "unavailable_reason", None)
|
60
|
-
|
61
|
-
# Read module file to detect imports
|
62
|
-
module_file = Path(module.__file__)
|
63
|
-
with open(module_file, "r", encoding="utf-8") as f:
|
64
|
-
content = f.read()
|
65
|
-
|
66
|
-
dependencies = _detect_dependencies_from_content(content, class_name)
|
67
|
-
dep_status = _check_dependency_status(dependencies)
|
68
|
-
|
69
|
-
return {
|
70
|
-
"name": class_name,
|
71
|
-
"available": available,
|
72
|
-
"reason": unavailable_reason,
|
73
|
-
"dependencies": dep_status,
|
74
|
-
}
|
75
|
-
|
76
|
-
except (ImportError, AttributeError) as e:
|
77
|
-
return {
|
78
|
-
"name": class_name,
|
79
|
-
"module": module_path,
|
80
|
-
"available": False,
|
81
|
-
"reason": str(e),
|
82
|
-
"dependencies": ["❌ Module not found"],
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
def get_driver_info():
|
87
|
-
"""Get information about all available drivers."""
|
88
|
-
drivers = []
|
89
|
-
|
90
|
-
# Define known driver modules
|
91
|
-
driver_modules = [
|
92
|
-
("janito.drivers.openai.driver", "OpenAIModelDriver"),
|
93
|
-
("janito.drivers.azure_openai.driver", "AzureOpenAIModelDriver"),
|
94
|
-
("janito.drivers.zai.driver", "ZAIModelDriver"),
|
95
|
-
("janito.drivers.cerebras.driver", "CerebrasModelDriver"),
|
96
|
-
]
|
97
|
-
|
98
|
-
for module_path, class_name in driver_modules:
|
99
|
-
driver_info = _get_single_driver_info(module_path, class_name)
|
100
|
-
drivers.append(driver_info)
|
101
|
-
|
102
|
-
return drivers
|
103
|
-
|
104
|
-
|
105
|
-
def _create_driver_table(drivers):
|
106
|
-
"""Create and populate the drivers table."""
|
107
|
-
table = Table(title="Available LLM Drivers")
|
108
|
-
table.add_column("Driver", style="cyan", no_wrap=True)
|
109
|
-
table.add_column("Status", style="bold")
|
110
|
-
table.add_column("Dependencies", style="yellow")
|
111
|
-
|
112
|
-
for driver in drivers:
|
113
|
-
name = driver["name"]
|
114
|
-
|
115
|
-
if driver["available"]:
|
116
|
-
status = "[green]✅ Available[/green]"
|
117
|
-
if driver["reason"]:
|
118
|
-
status = f"[yellow]⚠️ Available ({driver['reason']})[/yellow]"
|
119
|
-
else:
|
120
|
-
status = f"[red]❌ Unavailable[/red]"
|
121
|
-
if driver["reason"]:
|
122
|
-
status = f"[red]❌ {driver['reason']}[/red]"
|
123
|
-
|
124
|
-
deps = "\n".join(driver["dependencies"])
|
125
|
-
table.add_row(name, status, deps)
|
126
|
-
|
127
|
-
return table
|
128
|
-
|
129
|
-
|
130
|
-
def _get_missing_dependencies(drivers):
|
131
|
-
"""Get list of missing dependencies."""
|
132
|
-
missing_deps = []
|
133
|
-
for driver in drivers:
|
134
|
-
for dep_status in driver["dependencies"]:
|
135
|
-
if dep_status.startswith("❌"):
|
136
|
-
dep_name = dep_status.split()[1]
|
137
|
-
if dep_name not in missing_deps:
|
138
|
-
missing_deps.append(dep_name)
|
139
|
-
return missing_deps
|
140
|
-
|
141
|
-
|
142
|
-
def handle_list_drivers(args=None):
|
143
|
-
"""List all available LLM drivers with their status and dependencies."""
|
144
|
-
drivers = get_driver_info()
|
145
|
-
|
146
|
-
if not drivers:
|
147
|
-
console.print("[red]No drivers found[/red]")
|
148
|
-
return
|
149
|
-
|
150
|
-
table = _create_driver_table(drivers)
|
151
|
-
console.print(table)
|
152
|
-
|
153
|
-
# Installation help - only show for missing dependencies
|
154
|
-
missing_deps = _get_missing_dependencies(drivers)
|
155
|
-
if missing_deps:
|
156
|
-
console.print(
|
157
|
-
f"\n[dim]💡 Install missing deps: pip install {' '.join(missing_deps)}[/dim]"
|
158
|
-
)
|
159
|
-
|
160
|
-
|
161
|
-
if __name__ == "__main__":
|
162
|
-
handle_list_drivers()
|
1
|
+
"""
|
2
|
+
CLI Command: List available LLM drivers and their dependencies
|
3
|
+
"""
|
4
|
+
|
5
|
+
import importlib
|
6
|
+
import sys
|
7
|
+
from pathlib import Path
|
8
|
+
from rich.console import Console
|
9
|
+
from rich.table import Table
|
10
|
+
from rich.panel import Panel
|
11
|
+
from rich.text import Text
|
12
|
+
|
13
|
+
console = Console()
|
14
|
+
|
15
|
+
|
16
|
+
def _detect_dependencies_from_content(content, class_name):
|
17
|
+
"""Detect dependencies from module content."""
|
18
|
+
dependencies = []
|
19
|
+
|
20
|
+
if "import openai" in content or "from openai" in content:
|
21
|
+
dependencies.append("openai")
|
22
|
+
if "import zai" in content or "from zai" in content:
|
23
|
+
dependencies.append("zai")
|
24
|
+
if "import anthropic" in content or "from anthropic" in content:
|
25
|
+
dependencies.append("anthropic")
|
26
|
+
if "import google" in content or "from google" in content:
|
27
|
+
dependencies.append("google-generativeai")
|
28
|
+
|
29
|
+
# Remove openai from zai driver dependencies
|
30
|
+
if "ZAIModelDriver" in class_name and "openai" in dependencies:
|
31
|
+
dependencies.remove("openai")
|
32
|
+
|
33
|
+
return dependencies
|
34
|
+
|
35
|
+
|
36
|
+
def _check_dependency_status(dependencies):
|
37
|
+
"""Check if dependencies are available."""
|
38
|
+
if not dependencies:
|
39
|
+
return ["No external dependencies"]
|
40
|
+
|
41
|
+
dep_status = []
|
42
|
+
for dep in dependencies:
|
43
|
+
try:
|
44
|
+
importlib.import_module(dep)
|
45
|
+
dep_status.append(f"✅ {dep}")
|
46
|
+
except ImportError:
|
47
|
+
dep_status.append(f"❌ {dep}")
|
48
|
+
|
49
|
+
return dep_status
|
50
|
+
|
51
|
+
|
52
|
+
def _get_single_driver_info(module_path, class_name):
|
53
|
+
"""Get information for a single driver."""
|
54
|
+
try:
|
55
|
+
module = importlib.import_module(module_path)
|
56
|
+
driver_class = getattr(module, class_name)
|
57
|
+
|
58
|
+
available = getattr(driver_class, "available", True)
|
59
|
+
unavailable_reason = getattr(driver_class, "unavailable_reason", None)
|
60
|
+
|
61
|
+
# Read module file to detect imports
|
62
|
+
module_file = Path(module.__file__)
|
63
|
+
with open(module_file, "r", encoding="utf-8") as f:
|
64
|
+
content = f.read()
|
65
|
+
|
66
|
+
dependencies = _detect_dependencies_from_content(content, class_name)
|
67
|
+
dep_status = _check_dependency_status(dependencies)
|
68
|
+
|
69
|
+
return {
|
70
|
+
"name": class_name,
|
71
|
+
"available": available,
|
72
|
+
"reason": unavailable_reason,
|
73
|
+
"dependencies": dep_status,
|
74
|
+
}
|
75
|
+
|
76
|
+
except (ImportError, AttributeError) as e:
|
77
|
+
return {
|
78
|
+
"name": class_name,
|
79
|
+
"module": module_path,
|
80
|
+
"available": False,
|
81
|
+
"reason": str(e),
|
82
|
+
"dependencies": ["❌ Module not found"],
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
def get_driver_info():
|
87
|
+
"""Get information about all available drivers."""
|
88
|
+
drivers = []
|
89
|
+
|
90
|
+
# Define known driver modules
|
91
|
+
driver_modules = [
|
92
|
+
("janito.drivers.openai.driver", "OpenAIModelDriver"),
|
93
|
+
("janito.drivers.azure_openai.driver", "AzureOpenAIModelDriver"),
|
94
|
+
("janito.drivers.zai.driver", "ZAIModelDriver"),
|
95
|
+
("janito.drivers.cerebras.driver", "CerebrasModelDriver"),
|
96
|
+
]
|
97
|
+
|
98
|
+
for module_path, class_name in driver_modules:
|
99
|
+
driver_info = _get_single_driver_info(module_path, class_name)
|
100
|
+
drivers.append(driver_info)
|
101
|
+
|
102
|
+
return drivers
|
103
|
+
|
104
|
+
|
105
|
+
def _create_driver_table(drivers):
|
106
|
+
"""Create and populate the drivers table."""
|
107
|
+
table = Table(title="Available LLM Drivers")
|
108
|
+
table.add_column("Driver", style="cyan", no_wrap=True)
|
109
|
+
table.add_column("Status", style="bold")
|
110
|
+
table.add_column("Dependencies", style="yellow")
|
111
|
+
|
112
|
+
for driver in drivers:
|
113
|
+
name = driver["name"]
|
114
|
+
|
115
|
+
if driver["available"]:
|
116
|
+
status = "[green]✅ Available[/green]"
|
117
|
+
if driver["reason"]:
|
118
|
+
status = f"[yellow]⚠️ Available ({driver['reason']})[/yellow]"
|
119
|
+
else:
|
120
|
+
status = f"[red]❌ Unavailable[/red]"
|
121
|
+
if driver["reason"]:
|
122
|
+
status = f"[red]❌ {driver['reason']}[/red]"
|
123
|
+
|
124
|
+
deps = "\n".join(driver["dependencies"])
|
125
|
+
table.add_row(name, status, deps)
|
126
|
+
|
127
|
+
return table
|
128
|
+
|
129
|
+
|
130
|
+
def _get_missing_dependencies(drivers):
|
131
|
+
"""Get list of missing dependencies."""
|
132
|
+
missing_deps = []
|
133
|
+
for driver in drivers:
|
134
|
+
for dep_status in driver["dependencies"]:
|
135
|
+
if dep_status.startswith("❌"):
|
136
|
+
dep_name = dep_status.split()[1]
|
137
|
+
if dep_name not in missing_deps:
|
138
|
+
missing_deps.append(dep_name)
|
139
|
+
return missing_deps
|
140
|
+
|
141
|
+
|
142
|
+
def handle_list_drivers(args=None):
|
143
|
+
"""List all available LLM drivers with their status and dependencies."""
|
144
|
+
drivers = get_driver_info()
|
145
|
+
|
146
|
+
if not drivers:
|
147
|
+
console.print("[red]No drivers found[/red]")
|
148
|
+
return
|
149
|
+
|
150
|
+
table = _create_driver_table(drivers)
|
151
|
+
console.print(table)
|
152
|
+
|
153
|
+
# Installation help - only show for missing dependencies
|
154
|
+
missing_deps = _get_missing_dependencies(drivers)
|
155
|
+
if missing_deps:
|
156
|
+
console.print(
|
157
|
+
f"\n[dim]💡 Install missing deps: uv pip install {' '.join(missing_deps)}[/dim]"
|
158
|
+
)
|
159
|
+
|
160
|
+
|
161
|
+
if __name__ == "__main__":
|
162
|
+
handle_list_drivers()
|
janito/cli/console.py
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
from rich.console import Console
|
2
|
-
|
3
|
-
shared_console = Console()
|
1
|
+
from rich.console import Console
|
2
|
+
|
3
|
+
shared_console = Console(file=None)
|
@@ -160,11 +160,9 @@ class RichTerminalReporter(EventHandlerBase):
|
|
160
160
|
self.console.print(msg)
|
161
161
|
self.console.file.flush()
|
162
162
|
elif subtype == ReportSubtype.STDOUT:
|
163
|
-
|
164
|
-
self.console.file.flush()
|
163
|
+
print(msg)
|
165
164
|
elif subtype == ReportSubtype.STDERR:
|
166
|
-
|
167
|
-
self.console.file.flush()
|
165
|
+
print(msg, file=sys.stderr)
|
168
166
|
else:
|
169
167
|
self.console.print(msg)
|
170
168
|
self.console.file.flush()
|