qtype 0.0.3__tar.gz → 0.0.4__tar.gz
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.
- {qtype-0.0.3/qtype.egg-info → qtype-0.0.4}/PKG-INFO +1 -1
- {qtype-0.0.3 → qtype-0.0.4}/pyproject.toml +1 -1
- qtype-0.0.4/qtype/cli.py +142 -0
- {qtype-0.0.3 → qtype-0.0.4/qtype.egg-info}/PKG-INFO +1 -1
- qtype-0.0.3/qtype/cli.py +0 -73
- {qtype-0.0.3 → qtype-0.0.4}/LICENSE +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/README.md +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commands/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commands/convert.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commands/generate.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commands/run.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commands/validate.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commons/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commons/generate.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/commons/tools.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/converters/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/converters/tools_from_api.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/converters/tools_from_module.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/converters/types.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/base_types.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/document.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/domain_types.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/model.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/dsl/validator.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/api.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/conversions.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/exceptions.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/flow.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/resource_cache.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/step.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/agent.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/condition.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/decoder.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/llm_inference.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/prompt_template.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/search.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/steps/tool.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/telemetry.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/interpreter/typing.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/loader.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/__init__.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/base_types.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/errors.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/generate.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/model.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype/semantic/resolver.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype.egg-info/SOURCES.txt +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype.egg-info/dependency_links.txt +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype.egg-info/entry_points.txt +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype.egg-info/requires.txt +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/qtype.egg-info/top_level.txt +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/setup.cfg +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/tests/test_dsl_loader.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/tests/test_dsl_validation.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/tests/test_semantic_resolver.py +0 -0
- {qtype-0.0.3 → qtype-0.0.4}/tests/test_tool_provider_python_module.py +0 -0
qtype-0.0.4/qtype/cli.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""
|
|
2
|
+
QType CLI entry point for generating schemas and validating QType specs.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import importlib
|
|
7
|
+
import logging
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
from importlib.metadata import entry_points
|
|
12
|
+
except ImportError:
|
|
13
|
+
# Fallback for Python < 3.10 (though you require 3.10+)
|
|
14
|
+
from importlib_metadata import entry_points # type: ignore[no-redef]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _discover_commands(subparsers: argparse._SubParsersAction) -> None:
|
|
18
|
+
"""Automatically discover and register command modules.
|
|
19
|
+
|
|
20
|
+
This function discovers commands from two sources:
|
|
21
|
+
1. Built-in commands from the local commands directory
|
|
22
|
+
2. Plugin commands from entry points defined by third-party packages
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
subparsers: The subparsers object to add commands to.
|
|
26
|
+
"""
|
|
27
|
+
# First, discover built-in commands from the local commands directory
|
|
28
|
+
_discover_local_commands(subparsers)
|
|
29
|
+
|
|
30
|
+
# Then, discover plugin commands from entry points
|
|
31
|
+
_discover_plugin_commands(subparsers)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _discover_local_commands(subparsers: argparse._SubParsersAction) -> None:
|
|
35
|
+
"""Discover and register built-in command modules from the local commands directory.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
subparsers: The subparsers object to add commands to.
|
|
39
|
+
"""
|
|
40
|
+
commands_dir = Path(__file__).parent / "commands"
|
|
41
|
+
|
|
42
|
+
for py_file in commands_dir.glob("*.py"):
|
|
43
|
+
# Skip __init__.py and other private files
|
|
44
|
+
if py_file.name.startswith("_"):
|
|
45
|
+
continue
|
|
46
|
+
|
|
47
|
+
module_name = f"qtype.commands.{py_file.stem}"
|
|
48
|
+
try:
|
|
49
|
+
module = importlib.import_module(module_name)
|
|
50
|
+
# Call the parser function to set up the subparser
|
|
51
|
+
if hasattr(module, "parser"):
|
|
52
|
+
module.parser(subparsers)
|
|
53
|
+
else:
|
|
54
|
+
logging.warning(
|
|
55
|
+
f"Built-in command module {module_name} does not have a 'parser' function"
|
|
56
|
+
)
|
|
57
|
+
except Exception as e:
|
|
58
|
+
logging.error(
|
|
59
|
+
f"Failed to load built-in command module {module_name}: {e}",
|
|
60
|
+
exc_info=True,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _discover_plugin_commands(subparsers: argparse._SubParsersAction) -> None:
|
|
65
|
+
"""Discover and register plugin command modules from entry points.
|
|
66
|
+
|
|
67
|
+
Third-party packages can register commands by defining entry points in their
|
|
68
|
+
setup.py or pyproject.toml file like this:
|
|
69
|
+
|
|
70
|
+
[project.entry-points."qtype.commands"]
|
|
71
|
+
my-command = "my_package.qtype_commands:my_command_parser"
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
subparsers: The subparsers object to add commands to.
|
|
75
|
+
"""
|
|
76
|
+
try:
|
|
77
|
+
# Get all entry points for the 'qtype.commands' group
|
|
78
|
+
eps = entry_points(group="qtype.commands")
|
|
79
|
+
|
|
80
|
+
for entry_point in eps:
|
|
81
|
+
try:
|
|
82
|
+
# Load the parser function from the entry point
|
|
83
|
+
parser_func = entry_point.load()
|
|
84
|
+
|
|
85
|
+
# Call the parser function to set up the subparser
|
|
86
|
+
if callable(parser_func):
|
|
87
|
+
parser_func(subparsers)
|
|
88
|
+
logging.debug(
|
|
89
|
+
f"Successfully loaded plugin command '{entry_point.name}' "
|
|
90
|
+
f"from {entry_point.value}"
|
|
91
|
+
)
|
|
92
|
+
else:
|
|
93
|
+
logging.warning(
|
|
94
|
+
f"Plugin entry point '{entry_point.name}' "
|
|
95
|
+
f"({entry_point.value}) is not callable"
|
|
96
|
+
)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logging.error(
|
|
99
|
+
f"Failed to load plugin command '{entry_point.name}' "
|
|
100
|
+
f"from {entry_point.value}: {e}",
|
|
101
|
+
exc_info=True,
|
|
102
|
+
)
|
|
103
|
+
except Exception as e:
|
|
104
|
+
logging.error(
|
|
105
|
+
f"Failed to discover plugin commands: {e}",
|
|
106
|
+
exc_info=True,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main() -> None:
|
|
111
|
+
"""
|
|
112
|
+
Main entry point for the QType CLI.
|
|
113
|
+
Sets up argument parsing and dispatches to the appropriate subcommand.
|
|
114
|
+
"""
|
|
115
|
+
parser = argparse.ArgumentParser(
|
|
116
|
+
description="QType CLI: Generate schema, validate, or run QType specs."
|
|
117
|
+
)
|
|
118
|
+
parser.add_argument(
|
|
119
|
+
"--log-level",
|
|
120
|
+
default="INFO",
|
|
121
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
122
|
+
help="Set the logging level (default: INFO)",
|
|
123
|
+
)
|
|
124
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
125
|
+
|
|
126
|
+
# Auto-discover and register commands
|
|
127
|
+
_discover_commands(subparsers)
|
|
128
|
+
|
|
129
|
+
args = parser.parse_args()
|
|
130
|
+
|
|
131
|
+
# Set logging level based on user input
|
|
132
|
+
logging.basicConfig(
|
|
133
|
+
level=getattr(logging, args.log_level),
|
|
134
|
+
format="%(levelname)s: %(message)s",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Dispatch to the selected subcommand
|
|
138
|
+
args.func(args)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if __name__ == "__main__":
|
|
142
|
+
main()
|
qtype-0.0.3/qtype/cli.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
QType CLI entry point for generating schemas and validating QType specs.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import argparse
|
|
6
|
-
import importlib
|
|
7
|
-
import logging
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def _discover_commands(subparsers: argparse._SubParsersAction) -> None:
|
|
12
|
-
"""Automatically discover and register command modules.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
subparsers: The subparsers object to add commands to.
|
|
16
|
-
"""
|
|
17
|
-
commands_dir = Path(__file__).parent / "commands"
|
|
18
|
-
|
|
19
|
-
for py_file in commands_dir.glob("*.py"):
|
|
20
|
-
# Skip __init__.py and other private files
|
|
21
|
-
if py_file.name.startswith("_"):
|
|
22
|
-
continue
|
|
23
|
-
|
|
24
|
-
module_name = f"qtype.commands.{py_file.stem}"
|
|
25
|
-
try:
|
|
26
|
-
module = importlib.import_module(module_name)
|
|
27
|
-
# Call the parser function to set up the subparser
|
|
28
|
-
if hasattr(module, "parser"):
|
|
29
|
-
module.parser(subparsers)
|
|
30
|
-
else:
|
|
31
|
-
logging.warning(
|
|
32
|
-
f"Command module {module_name} does not have a 'parser' function"
|
|
33
|
-
)
|
|
34
|
-
except Exception as e:
|
|
35
|
-
logging.error(
|
|
36
|
-
f"Failed to load command module {module_name}: {e}",
|
|
37
|
-
exc_info=True,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def main() -> None:
|
|
42
|
-
"""
|
|
43
|
-
Main entry point for the QType CLI.
|
|
44
|
-
Sets up argument parsing and dispatches to the appropriate subcommand.
|
|
45
|
-
"""
|
|
46
|
-
parser = argparse.ArgumentParser(
|
|
47
|
-
description="QType CLI: Generate schema, validate, or run QType specs."
|
|
48
|
-
)
|
|
49
|
-
parser.add_argument(
|
|
50
|
-
"--log-level",
|
|
51
|
-
default="INFO",
|
|
52
|
-
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
53
|
-
help="Set the logging level (default: INFO)",
|
|
54
|
-
)
|
|
55
|
-
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
56
|
-
|
|
57
|
-
# Auto-discover and register commands
|
|
58
|
-
_discover_commands(subparsers)
|
|
59
|
-
|
|
60
|
-
args = parser.parse_args()
|
|
61
|
-
|
|
62
|
-
# Set logging level based on user input
|
|
63
|
-
logging.basicConfig(
|
|
64
|
-
level=getattr(logging, args.log_level),
|
|
65
|
-
format="%(levelname)s: %(message)s",
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
# Dispatch to the selected subcommand
|
|
69
|
-
args.func(args)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if __name__ == "__main__":
|
|
73
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|