zrb 1.1.0__py3-none-any.whl → 1.2.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.
- zrb/builtin/git.py +8 -8
- zrb/builtin/llm/llm_chat.py +3 -3
- zrb/builtin/project/add/fastapp/fastapp_input.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_task.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/add_column_task.py +40 -40
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/add_column_util.py +6 -10
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +76 -56
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py +3 -3
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +16 -10
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/logger_factory.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_util.py +6 -2
- zrb/builtin/project/create/project_task.py +2 -2
- zrb/builtin/random.py +3 -3
- zrb/builtin/setup/common_input.py +5 -5
- zrb/builtin/setup/tmux/tmux.py +1 -1
- zrb/builtin/setup/zsh/zsh.py +1 -1
- zrb/builtin/todo.py +4 -4
- zrb/input/base_input.py +17 -12
- zrb/input/bool_input.py +12 -5
- zrb/input/float_input.py +12 -5
- zrb/input/int_input.py +12 -5
- zrb/input/option_input.py +5 -5
- zrb/input/password_input.py +5 -5
- zrb/input/text_input.py +4 -4
- {zrb-1.1.0.dist-info → zrb-1.2.1.dist-info}/METADATA +2 -3
- {zrb-1.1.0.dist-info → zrb-1.2.1.dist-info}/RECORD +28 -29
- zrb/util/llm/tool.py +0 -87
- {zrb-1.1.0.dist-info → zrb-1.2.1.dist-info}/WHEEL +0 -0
- {zrb-1.1.0.dist-info → zrb-1.2.1.dist-info}/entry_points.txt +0 -0
zrb/util/llm/tool.py
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
import inspect
|
2
|
-
from collections.abc import Callable
|
3
|
-
from typing import Annotated, Any, Literal, get_type_hints
|
4
|
-
|
5
|
-
|
6
|
-
def callable_to_tool_schema(callable_obj: Callable) -> dict[str, Any]:
|
7
|
-
"""
|
8
|
-
Convert a callable into a tool schema dictionary by deriving the parameter schema.
|
9
|
-
|
10
|
-
:param callable_obj: The callable object (e.g., a function).
|
11
|
-
:return: A dictionary representing the tool schema.
|
12
|
-
"""
|
13
|
-
if not callable(callable_obj):
|
14
|
-
raise ValueError("Provided object is not callable")
|
15
|
-
# Derive name and description
|
16
|
-
name = callable_obj.__name__
|
17
|
-
description = (callable_obj.__doc__ or "").strip()
|
18
|
-
# Get function signature
|
19
|
-
sig = inspect.signature(callable_obj)
|
20
|
-
hints = get_type_hints(callable_obj)
|
21
|
-
# Build parameter schema
|
22
|
-
param_schema = {"type": "object", "properties": {}, "required": []}
|
23
|
-
for param_name, param in sig.parameters.items():
|
24
|
-
# Get the type hint or default to str
|
25
|
-
param_type = hints.get(param_name, str)
|
26
|
-
|
27
|
-
# Handle annotated types (e.g., Annotated[str, "description"])
|
28
|
-
json_type, param_metadata = _process_type_annotation(param_type)
|
29
|
-
param_schema["properties"][param_name] = param_metadata
|
30
|
-
|
31
|
-
# Mark required parameters
|
32
|
-
if param.default is inspect.Parameter.empty:
|
33
|
-
param_schema["required"].append(param_name)
|
34
|
-
return {
|
35
|
-
"type": "function",
|
36
|
-
"function": {
|
37
|
-
"name": name,
|
38
|
-
"description": description,
|
39
|
-
"parameters": param_schema,
|
40
|
-
},
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
def _process_type_annotation(py_type: Any) -> tuple[str, dict]:
|
45
|
-
"""
|
46
|
-
Process type annotations and return the JSON Schema type and metadata.
|
47
|
-
|
48
|
-
:param py_type: The type annotation.
|
49
|
-
:return: A tuple of (JSON type, parameter metadata).
|
50
|
-
"""
|
51
|
-
if hasattr(py_type, "__origin__") and py_type.__origin__ is Literal:
|
52
|
-
# Handle Literal (enum)
|
53
|
-
enum_values = list(py_type.__args__)
|
54
|
-
return "string", {"type": "string", "enum": enum_values}
|
55
|
-
|
56
|
-
if hasattr(py_type, "__origin__") and py_type.__origin__ is Annotated:
|
57
|
-
# Handle Annotated types
|
58
|
-
base_type = py_type.__args__[0]
|
59
|
-
description = py_type.__args__[1]
|
60
|
-
json_type = _python_type_to_json_type(base_type)
|
61
|
-
return json_type, {"type": json_type, "description": description}
|
62
|
-
|
63
|
-
# Fallback to basic type conversion
|
64
|
-
json_type = _python_type_to_json_type(py_type)
|
65
|
-
return json_type, {"type": json_type}
|
66
|
-
|
67
|
-
|
68
|
-
def _python_type_to_json_type(py_type):
|
69
|
-
"""
|
70
|
-
Map Python types to JSON Schema types.
|
71
|
-
"""
|
72
|
-
if py_type is str:
|
73
|
-
return "string"
|
74
|
-
elif py_type is int:
|
75
|
-
return "integer"
|
76
|
-
elif py_type is float:
|
77
|
-
return "number"
|
78
|
-
elif py_type is bool:
|
79
|
-
return "boolean"
|
80
|
-
elif py_type is list:
|
81
|
-
return "array"
|
82
|
-
elif py_type is dict:
|
83
|
-
return "object"
|
84
|
-
elif py_type in {None, type(None)}:
|
85
|
-
return "null"
|
86
|
-
else:
|
87
|
-
return "string" # Default to string for unsupported types
|
File without changes
|
File without changes
|