janito 2.6.0__py3-none-any.whl → 2.6.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/__init__.py +7 -6
- janito/__main__.py +5 -4
- janito/_version.py +58 -57
- janito/agent/setup_agent.py +13 -3
- janito/cli/__init__.py +10 -9
- janito/cli/chat_mode/bindings.py +38 -37
- janito/cli/chat_mode/chat_entry.py +23 -22
- janito/cli/chat_mode/prompt_style.py +25 -24
- janito/cli/chat_mode/script_runner.py +154 -153
- janito/cli/chat_mode/session.py +282 -282
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/METADATA +14 -9
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/RECORD +17 -17
- /janito/agent/templates/profiles/{system_prompt_template_software_developer.txt.j2 → system_prompt_template_software developer.txt.j2} +0 -0
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/WHEEL +0 -0
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/entry_points.txt +0 -0
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/licenses/LICENSE +0 -0
- {janito-2.6.0.dist-info → janito-2.6.1.dist-info}/top_level.txt +0 -0
janito/__init__.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
"""
|
2
|
-
janito: A Python package for managing and interacting with Large Language Model (LLM) providers and their APIs.
|
3
|
-
Provides a CLI for credential management and an extensible driver system for LLMs.
|
4
|
-
"""
|
5
|
-
|
6
|
-
from ._version import __version__
|
1
|
+
"""
|
2
|
+
janito: A Python package for managing and interacting with Large Language Model (LLM) providers and their APIs.
|
3
|
+
Provides a CLI for credential management and an extensible driver system for LLMs.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from ._version import __version__
|
7
|
+
|
janito/__main__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
from .cli.main import main
|
2
|
-
|
3
|
-
if __name__ == "__main__":
|
4
|
-
main()
|
1
|
+
from .cli.main import main
|
2
|
+
|
3
|
+
if __name__ == "__main__":
|
4
|
+
main()
|
5
|
+
|
janito/_version.py
CHANGED
@@ -1,57 +1,58 @@
|
|
1
|
-
"""Version handling for Janito.
|
2
|
-
Attempts to obtain the package version in the following order:
|
3
|
-
1. If a janito.version module exists (generated when the package is built with
|
4
|
-
setuptools-scm), use the version attribute from that module.
|
5
|
-
2. Ask importlib.metadata for the installed distribution version – works for
|
6
|
-
both regular and editable installs handled by pip.
|
7
|
-
3. Fall back to calling setuptools_scm.get_version() directly, using the git
|
8
|
-
repository when running from source without an installed distribution.
|
9
|
-
4. If everything else fails, return the literal string ``"unknown"`` so that
|
10
|
-
the application continues to work even when the version cannot be
|
11
|
-
determined.
|
12
|
-
|
13
|
-
This layered approach guarantees that a meaningful version string is returned
|
14
|
-
in most development and production scenarios while keeping Janito free from
|
15
|
-
hard-coded version numbers.
|
16
|
-
"""
|
17
|
-
|
18
|
-
from __future__ import annotations
|
19
|
-
|
20
|
-
import pathlib
|
21
|
-
from importlib import metadata as importlib_metadata
|
22
|
-
|
23
|
-
__all__ = ["__version__"]
|
24
|
-
|
25
|
-
|
26
|
-
# 1. "janito.version" (generated at build time by setuptools-scm)
|
27
|
-
try:
|
28
|
-
from . import version as _generated_version # type: ignore
|
29
|
-
|
30
|
-
__version__: str = _generated_version.version # pytype: disable=module-attr
|
31
|
-
except ImportError: # pragma: no cover – not available in editable installs
|
32
|
-
|
33
|
-
def _resolve_version() -> str:
|
34
|
-
"""Resolve the version string using several fallbacks."""
|
35
|
-
|
36
|
-
# 2. importlib.metadata – works for both regular and `pip install -e`.
|
37
|
-
try:
|
38
|
-
return importlib_metadata.version("janito")
|
39
|
-
except importlib_metadata.PackageNotFoundError:
|
40
|
-
pass # Not installed – probably running from a source checkout.
|
41
|
-
|
42
|
-
# 3. setuptools_scm – query the VCS metadata directly.
|
43
|
-
try:
|
44
|
-
from setuptools_scm import get_version # Imported lazily.
|
45
|
-
|
46
|
-
package_root = pathlib.Path(__file__).resolve().parent.parent
|
47
|
-
return get_version(root=str(package_root), relative_to=__file__)
|
48
|
-
except Exception: # pragma: no cover – any failure here falls through
|
49
|
-
# Either setuptools_scm is not available or this is not a git repo.
|
50
|
-
pass
|
51
|
-
|
52
|
-
# 4. Ultimate fallback – return a placeholder.
|
53
|
-
return "unknown"
|
54
|
-
|
55
|
-
__version__ = _resolve_version()
|
56
|
-
|
57
|
-
|
1
|
+
"""Version handling for Janito.
|
2
|
+
Attempts to obtain the package version in the following order:
|
3
|
+
1. If a janito.version module exists (generated when the package is built with
|
4
|
+
setuptools-scm), use the version attribute from that module.
|
5
|
+
2. Ask importlib.metadata for the installed distribution version – works for
|
6
|
+
both regular and editable installs handled by pip.
|
7
|
+
3. Fall back to calling setuptools_scm.get_version() directly, using the git
|
8
|
+
repository when running from source without an installed distribution.
|
9
|
+
4. If everything else fails, return the literal string ``"unknown"`` so that
|
10
|
+
the application continues to work even when the version cannot be
|
11
|
+
determined.
|
12
|
+
|
13
|
+
This layered approach guarantees that a meaningful version string is returned
|
14
|
+
in most development and production scenarios while keeping Janito free from
|
15
|
+
hard-coded version numbers.
|
16
|
+
"""
|
17
|
+
|
18
|
+
from __future__ import annotations
|
19
|
+
|
20
|
+
import pathlib
|
21
|
+
from importlib import metadata as importlib_metadata
|
22
|
+
|
23
|
+
__all__ = ["__version__"]
|
24
|
+
|
25
|
+
|
26
|
+
# 1. "janito.version" (generated at build time by setuptools-scm)
|
27
|
+
try:
|
28
|
+
from . import version as _generated_version # type: ignore
|
29
|
+
|
30
|
+
__version__: str = _generated_version.version # pytype: disable=module-attr
|
31
|
+
except ImportError: # pragma: no cover – not available in editable installs
|
32
|
+
|
33
|
+
def _resolve_version() -> str:
|
34
|
+
"""Resolve the version string using several fallbacks."""
|
35
|
+
|
36
|
+
# 2. importlib.metadata – works for both regular and `pip install -e`.
|
37
|
+
try:
|
38
|
+
return importlib_metadata.version("janito")
|
39
|
+
except importlib_metadata.PackageNotFoundError:
|
40
|
+
pass # Not installed – probably running from a source checkout.
|
41
|
+
|
42
|
+
# 3. setuptools_scm – query the VCS metadata directly.
|
43
|
+
try:
|
44
|
+
from setuptools_scm import get_version # Imported lazily.
|
45
|
+
|
46
|
+
package_root = pathlib.Path(__file__).resolve().parent.parent
|
47
|
+
return get_version(root=str(package_root), relative_to=__file__)
|
48
|
+
except Exception: # pragma: no cover – any failure here falls through
|
49
|
+
# Either setuptools_scm is not available or this is not a git repo.
|
50
|
+
pass
|
51
|
+
|
52
|
+
# 4. Ultimate fallback – return a placeholder.
|
53
|
+
return "unknown"
|
54
|
+
|
55
|
+
__version__ = _resolve_version()
|
56
|
+
|
57
|
+
|
58
|
+
|
janito/agent/setup_agent.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
import importlib.resources
|
2
2
|
import re
|
3
|
+
import os
|
3
4
|
import sys
|
4
5
|
import time
|
5
6
|
import warnings
|
6
7
|
import threading
|
7
8
|
from pathlib import Path
|
8
9
|
from jinja2 import Template
|
9
|
-
from
|
10
|
+
from pathlib import Path
|
10
11
|
from queue import Queue
|
12
|
+
from rich import print as rich_print
|
11
13
|
from janito.tools import get_local_tools_adapter
|
12
14
|
from janito.llm.agent import LLMAgent
|
13
15
|
from janito.drivers.driver_registry import get_driver_class
|
@@ -15,11 +17,13 @@ from janito.platform_discovery import PlatformDiscovery
|
|
15
17
|
from janito.tools.tool_base import ToolPermissions
|
16
18
|
from janito.tools.permissions import get_global_allowed_permissions
|
17
19
|
|
18
|
-
|
19
20
|
def _load_template_content(profile, templates_dir):
|
20
21
|
"""
|
21
22
|
Loads the template content for the given profile from the specified directory or package resources.
|
23
|
+
If the profile template is not found in the default locations, tries to load from the user profiles directory ~/.janito/profiles.
|
22
24
|
"""
|
25
|
+
|
26
|
+
|
23
27
|
template_filename = f"system_prompt_template_{profile}.txt.j2"
|
24
28
|
template_path = templates_dir / template_filename
|
25
29
|
if template_path.exists():
|
@@ -32,8 +36,14 @@ def _load_template_content(profile, templates_dir):
|
|
32
36
|
).open("r", encoding="utf-8") as file:
|
33
37
|
return file.read(), template_path
|
34
38
|
except (FileNotFoundError, ModuleNotFoundError, AttributeError):
|
39
|
+
# Try user profiles directory
|
40
|
+
user_profiles_dir = Path(os.path.expanduser("~/.janito/profiles"))
|
41
|
+
user_template_path = user_profiles_dir / profile
|
42
|
+
if user_template_path.exists():
|
43
|
+
with open(user_template_path, "r", encoding="utf-8") as file:
|
44
|
+
return file.read(), user_template_path
|
35
45
|
raise FileNotFoundError(
|
36
|
-
f"[janito] Could not find profile-specific template '{template_filename}' in {template_path} nor in janito.agent.templates.profiles package."
|
46
|
+
f"[janito] Could not find profile-specific template '{template_filename}' in {template_path} nor in janito.agent.templates.profiles package nor in user profiles directory {user_template_path}."
|
37
47
|
)
|
38
48
|
|
39
49
|
|
janito/cli/__init__.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
# janito.cli package
|
2
|
-
from .utils import format_tokens, format_generation_time
|
3
|
-
|
4
|
-
__all__ = [
|
5
|
-
"setup_provider",
|
6
|
-
"setup_agent",
|
7
|
-
"format_tokens",
|
8
|
-
"format_generation_time",
|
9
|
-
]
|
1
|
+
# janito.cli package
|
2
|
+
from .utils import format_tokens, format_generation_time
|
3
|
+
|
4
|
+
__all__ = [
|
5
|
+
"setup_provider",
|
6
|
+
"setup_agent",
|
7
|
+
"format_tokens",
|
8
|
+
"format_generation_time",
|
9
|
+
]
|
10
|
+
|
janito/cli/chat_mode/bindings.py
CHANGED
@@ -1,37 +1,38 @@
|
|
1
|
-
"""
|
2
|
-
Key bindings for Janito Chat CLI.
|
3
|
-
"""
|
4
|
-
|
5
|
-
from prompt_toolkit.key_binding import KeyBindings
|
6
|
-
from janito.tools.permissions import get_global_allowed_permissions
|
7
|
-
|
8
|
-
class KeyBindingsFactory:
|
9
|
-
@staticmethod
|
10
|
-
def create():
|
11
|
-
bindings = KeyBindings()
|
12
|
-
|
13
|
-
@bindings.add("c-y")
|
14
|
-
def _(event):
|
15
|
-
buf = event.app.current_buffer
|
16
|
-
buf.text = "Yes"
|
17
|
-
buf.validate_and_handle()
|
18
|
-
|
19
|
-
@bindings.add("c-n")
|
20
|
-
def _(event):
|
21
|
-
buf = event.app.current_buffer
|
22
|
-
buf.text = "No"
|
23
|
-
buf.validate_and_handle()
|
24
|
-
|
25
|
-
@bindings.add("f2")
|
26
|
-
def _(event):
|
27
|
-
buf = event.app.current_buffer
|
28
|
-
buf.text = "/restart"
|
29
|
-
buf.validate_and_handle()
|
30
|
-
|
31
|
-
@bindings.add("f12")
|
32
|
-
def _(event):
|
33
|
-
buf = event.app.current_buffer
|
34
|
-
buf.text = "Do It"
|
35
|
-
buf.validate_and_handle()
|
36
|
-
|
37
|
-
return bindings
|
1
|
+
"""
|
2
|
+
Key bindings for Janito Chat CLI.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from prompt_toolkit.key_binding import KeyBindings
|
6
|
+
from janito.tools.permissions import get_global_allowed_permissions
|
7
|
+
|
8
|
+
class KeyBindingsFactory:
|
9
|
+
@staticmethod
|
10
|
+
def create():
|
11
|
+
bindings = KeyBindings()
|
12
|
+
|
13
|
+
@bindings.add("c-y")
|
14
|
+
def _(event):
|
15
|
+
buf = event.app.current_buffer
|
16
|
+
buf.text = "Yes"
|
17
|
+
buf.validate_and_handle()
|
18
|
+
|
19
|
+
@bindings.add("c-n")
|
20
|
+
def _(event):
|
21
|
+
buf = event.app.current_buffer
|
22
|
+
buf.text = "No"
|
23
|
+
buf.validate_and_handle()
|
24
|
+
|
25
|
+
@bindings.add("f2")
|
26
|
+
def _(event):
|
27
|
+
buf = event.app.current_buffer
|
28
|
+
buf.text = "/restart"
|
29
|
+
buf.validate_and_handle()
|
30
|
+
|
31
|
+
@bindings.add("f12")
|
32
|
+
def _(event):
|
33
|
+
buf = event.app.current_buffer
|
34
|
+
buf.text = "Do It"
|
35
|
+
buf.validate_and_handle()
|
36
|
+
|
37
|
+
return bindings
|
38
|
+
|
@@ -1,22 +1,23 @@
|
|
1
|
-
"""
|
2
|
-
Main entry point for the Janito Chat CLI.
|
3
|
-
Handles the interactive chat loop and session startup.
|
4
|
-
"""
|
5
|
-
|
6
|
-
from rich.console import Console
|
7
|
-
from prompt_toolkit.formatted_text import HTML
|
8
|
-
from janito.cli.chat_mode.session import ChatSession
|
9
|
-
|
10
|
-
|
11
|
-
def main(args=None):
|
12
|
-
console = Console()
|
13
|
-
console.clear()
|
14
|
-
from janito.version import __version__
|
15
|
-
|
16
|
-
|
17
|
-
session = ChatSession(console, args=args)
|
18
|
-
session.run()
|
19
|
-
|
20
|
-
|
21
|
-
if __name__ == "__main__":
|
22
|
-
main()
|
1
|
+
"""
|
2
|
+
Main entry point for the Janito Chat CLI.
|
3
|
+
Handles the interactive chat loop and session startup.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from rich.console import Console
|
7
|
+
from prompt_toolkit.formatted_text import HTML
|
8
|
+
from janito.cli.chat_mode.session import ChatSession
|
9
|
+
|
10
|
+
|
11
|
+
def main(args=None):
|
12
|
+
console = Console()
|
13
|
+
console.clear()
|
14
|
+
from janito.version import __version__
|
15
|
+
|
16
|
+
|
17
|
+
session = ChatSession(console, args=args)
|
18
|
+
session.run()
|
19
|
+
|
20
|
+
|
21
|
+
if __name__ == "__main__":
|
22
|
+
main()
|
23
|
+
|
@@ -1,24 +1,25 @@
|
|
1
|
-
from prompt_toolkit.styles import Style
|
2
|
-
|
3
|
-
chat_shell_style = Style.from_dict(
|
4
|
-
{
|
5
|
-
"prompt": "bg:#2323af #ffffff bold",
|
6
|
-
"": "bg:#005fdd #ffffff", # blue background for input area
|
7
|
-
"bottom-toolbar": "fg:#2323af bg:yellow",
|
8
|
-
"key-label": "bg:#ff9500 fg:#232323 bold",
|
9
|
-
"provider": "fg:#117fbf",
|
10
|
-
"model": "fg:#1f5fa9",
|
11
|
-
"role": "fg:#e87c32 bold",
|
12
|
-
"msg_count": "fg:#5454dd",
|
13
|
-
"session_id": "fg:#704ab9",
|
14
|
-
"tokens_total": "fg:#a022c7",
|
15
|
-
"tokens_in": "fg:#00af5f",
|
16
|
-
"tokens_out": "fg:#01814a",
|
17
|
-
"max-tokens": "fg:#888888",
|
18
|
-
|
19
|
-
|
20
|
-
"key-toggle-on": "bg:#ffd700 fg:#232323 bold",
|
21
|
-
"key-toggle-off": "bg:#444444 fg:#ffffff bold",
|
22
|
-
"cmd-label": "bg:#ff9500 fg:#232323 bold",
|
23
|
-
}
|
24
|
-
)
|
1
|
+
from prompt_toolkit.styles import Style
|
2
|
+
|
3
|
+
chat_shell_style = Style.from_dict(
|
4
|
+
{
|
5
|
+
"prompt": "bg:#2323af #ffffff bold",
|
6
|
+
"": "bg:#005fdd #ffffff", # blue background for input area
|
7
|
+
"bottom-toolbar": "fg:#2323af bg:yellow",
|
8
|
+
"key-label": "bg:#ff9500 fg:#232323 bold",
|
9
|
+
"provider": "fg:#117fbf",
|
10
|
+
"model": "fg:#1f5fa9",
|
11
|
+
"role": "fg:#e87c32 bold",
|
12
|
+
"msg_count": "fg:#5454dd",
|
13
|
+
"session_id": "fg:#704ab9",
|
14
|
+
"tokens_total": "fg:#a022c7",
|
15
|
+
"tokens_in": "fg:#00af5f",
|
16
|
+
"tokens_out": "fg:#01814a",
|
17
|
+
"max-tokens": "fg:#888888",
|
18
|
+
|
19
|
+
|
20
|
+
"key-toggle-on": "bg:#ffd700 fg:#232323 bold",
|
21
|
+
"key-toggle-off": "bg:#444444 fg:#ffffff bold",
|
22
|
+
"cmd-label": "bg:#ff9500 fg:#232323 bold",
|
23
|
+
}
|
24
|
+
)
|
25
|
+
|