qtype 0.1.9__py3-none-any.whl → 0.1.10__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.
- qtype/application/converters/tools_from_module.py +15 -0
- qtype/commands/convert.py +3 -0
- qtype/dsl/model.py +28 -4
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/METADATA +1 -1
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/RECORD +9 -9
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/WHEEL +0 -0
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/entry_points.txt +0 -0
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/licenses/LICENSE +0 -0
- {qtype-0.1.9.dist-info → qtype-0.1.10.dist-info}/top_level.txt +0 -0
|
@@ -144,6 +144,11 @@ def _create_tool_from_function(
|
|
|
144
144
|
for p in func_info["parameters"]
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
# # quick hack
|
|
148
|
+
# for k, v in inputs.items():
|
|
149
|
+
# if inspect.isclass(v.type) and issubclass(v.type, BaseModel):
|
|
150
|
+
# v.type = str(v.type.__name__)
|
|
151
|
+
|
|
147
152
|
# Create output parameter based on return type
|
|
148
153
|
tool_id = func_info["module"] + "." + func_name
|
|
149
154
|
|
|
@@ -152,6 +157,7 @@ def _create_tool_from_function(
|
|
|
152
157
|
)
|
|
153
158
|
|
|
154
159
|
outputs = {"result": ToolParameter(type=output_type, optional=False)}
|
|
160
|
+
# outputs['result'].type =
|
|
155
161
|
|
|
156
162
|
return PythonFunctionTool(
|
|
157
163
|
id=tool_id,
|
|
@@ -264,6 +270,15 @@ def _map_python_type_to_variable_type(
|
|
|
264
270
|
elif python_type in get_args(VariableType):
|
|
265
271
|
# If it's a domain type, return its name
|
|
266
272
|
return python_type # type: ignore[no-any-return]
|
|
273
|
+
elif any(
|
|
274
|
+
[
|
|
275
|
+
(python_type is get_args(t)[0])
|
|
276
|
+
for t in get_args(VariableType)
|
|
277
|
+
if get_origin(t) is type
|
|
278
|
+
]
|
|
279
|
+
):
|
|
280
|
+
# It's the domain type, but the actual class (the user imported it)
|
|
281
|
+
return python_type.__name__
|
|
267
282
|
elif inspect.isclass(python_type) and issubclass(python_type, BaseModel):
|
|
268
283
|
# If it's a Pydantic model, create or retrieve its CustomType definition
|
|
269
284
|
return _pydantic_to_custom_types(python_type, custom_types)
|
qtype/commands/convert.py
CHANGED
|
@@ -23,6 +23,9 @@ def _convert_to_yaml(doc: Application | ToolList) -> str:
|
|
|
23
23
|
else:
|
|
24
24
|
wrapped = doc
|
|
25
25
|
|
|
26
|
+
import pprint
|
|
27
|
+
|
|
28
|
+
pprint.pprint(wrapped)
|
|
26
29
|
# NOTE: We use exclude_none but NOT exclude_unset because discriminator
|
|
27
30
|
# fields like 'type' have default values and must be included in output
|
|
28
31
|
return to_yaml_str(wrapped, exclude_none=True)
|
qtype/dsl/model.py
CHANGED
|
@@ -12,6 +12,7 @@ from pydantic import (
|
|
|
12
12
|
Field,
|
|
13
13
|
RootModel,
|
|
14
14
|
ValidationInfo,
|
|
15
|
+
model_serializer,
|
|
15
16
|
model_validator,
|
|
16
17
|
)
|
|
17
18
|
|
|
@@ -27,11 +28,15 @@ from qtype.base.types import (
|
|
|
27
28
|
)
|
|
28
29
|
from qtype.base.ui_shapes import UI_INPUT_TO_TYPE, UIType
|
|
29
30
|
from qtype.dsl.domain_types import (
|
|
31
|
+
AggregateStats,
|
|
30
32
|
ChatContent,
|
|
31
33
|
ChatMessage,
|
|
32
34
|
Embedding,
|
|
35
|
+
MessageRole,
|
|
33
36
|
RAGChunk,
|
|
34
37
|
RAGDocument,
|
|
38
|
+
RAGSearchResult,
|
|
39
|
+
SearchResult,
|
|
35
40
|
)
|
|
36
41
|
|
|
37
42
|
DOMAIN_CLASSES = {
|
|
@@ -269,6 +274,21 @@ class ToolParameter(BaseModel):
|
|
|
269
274
|
"""Resolve string-based type references using the shared validator."""
|
|
270
275
|
return _resolve_type_field_validator(data, info)
|
|
271
276
|
|
|
277
|
+
@staticmethod
|
|
278
|
+
def _serialize_type(value):
|
|
279
|
+
if isinstance(value, type):
|
|
280
|
+
return value.__name__
|
|
281
|
+
elif hasattr(value, "__name__"):
|
|
282
|
+
return value.__name__
|
|
283
|
+
return value
|
|
284
|
+
|
|
285
|
+
@model_serializer
|
|
286
|
+
def _model_serializer(self):
|
|
287
|
+
# Use the default serialization, but ensure 'type' is a string
|
|
288
|
+
data = self.model_dump()
|
|
289
|
+
data["type"] = self._serialize_type(data.get("type"))
|
|
290
|
+
return data
|
|
291
|
+
|
|
272
292
|
|
|
273
293
|
class ListType(BaseModel):
|
|
274
294
|
"""Represents a list type with a specific element type."""
|
|
@@ -288,12 +308,16 @@ class ListType(BaseModel):
|
|
|
288
308
|
|
|
289
309
|
VariableType = (
|
|
290
310
|
PrimitiveTypeEnum
|
|
291
|
-
| Type[
|
|
292
|
-
| Type[ChatMessage]
|
|
293
|
-
| Type[ChatContent]
|
|
311
|
+
| Type[AggregateStats]
|
|
294
312
|
| Type[BaseModel]
|
|
295
|
-
| Type[
|
|
313
|
+
| Type[ChatContent]
|
|
314
|
+
| Type[ChatMessage]
|
|
315
|
+
| Type[Embedding]
|
|
316
|
+
| Type[MessageRole]
|
|
296
317
|
| Type[RAGChunk]
|
|
318
|
+
| Type[RAGDocument]
|
|
319
|
+
| Type[RAGSearchResult]
|
|
320
|
+
| Type[SearchResult]
|
|
297
321
|
| ListType
|
|
298
322
|
)
|
|
299
323
|
|
|
@@ -7,7 +7,7 @@ qtype/application/commons/__init__.py,sha256=QyWAB2cvimM4DxNo2oBFCGkfBikH-ZeMBMG
|
|
|
7
7
|
qtype/application/commons/tools.py,sha256=U_jJdVN2NO5v9b3qb6dPIiVykfal6tp6NvcLGWR6HC8,5035
|
|
8
8
|
qtype/application/converters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
qtype/application/converters/tools_from_api.py,sha256=h1g4nOLEpLPqbXAtqSLPA1WuRELMOMsI392kA61nsxc,16831
|
|
10
|
-
qtype/application/converters/tools_from_module.py,sha256=
|
|
10
|
+
qtype/application/converters/tools_from_module.py,sha256=7pR0oA4xeWQchclWYu3sa5760NJoms9y-aQd1GLDj7M,9526
|
|
11
11
|
qtype/application/converters/types.py,sha256=OsJQ2fmgQm5NaxgS9cvHER9anfv3qttbt7co3f-MxPE,440
|
|
12
12
|
qtype/base/__init__.py,sha256=4jwcB8cDHzDNF3NBv8WqHNk3sDZDNvUFNjx2CKZ-pyY,283
|
|
13
13
|
qtype/base/exceptions.py,sha256=NR6-p6FnIabFPid9xIUTTeNhCYoIw8sbxEzaWQ11a4o,1155
|
|
@@ -15,7 +15,7 @@ qtype/base/logging.py,sha256=eqStjILlmhNryYRqUiyTdDHoUoiLKSY8J0GevvzvTKQ,1075
|
|
|
15
15
|
qtype/base/types.py,sha256=Z-x9ytcmPPCmtkzu_JAn9wBdBiaUKqPpmVzgUIB_SaM,6676
|
|
16
16
|
qtype/base/ui_shapes.py,sha256=FkziyJ8VKqimpDepTK6tlZ47HQzNwJUeKARAM2qOYKo,921
|
|
17
17
|
qtype/commands/__init__.py,sha256=Qo4M07zm5I63r8STxDjvt5fhP1jygdXTsExNGELkefc,257
|
|
18
|
-
qtype/commands/convert.py,sha256=
|
|
18
|
+
qtype/commands/convert.py,sha256=tIzi31q8f3quIzLGsNVx8P467JCRK4MpRpx2hjk9j64,4682
|
|
19
19
|
qtype/commands/generate.py,sha256=OQEkuh3dTVu6ZUNAuH_HkU-9YktYySL0qjTdrz28FY8,7285
|
|
20
20
|
qtype/commands/run.py,sha256=rDIiDioWU-dNuw39F12Bb6buknsNGzzVhd41i9Yms8Y,6633
|
|
21
21
|
qtype/commands/serve.py,sha256=lb5akSZ8fYLlCl8u8HDFFk6kyCHHwSRnP5wNzZry8sg,3216
|
|
@@ -26,7 +26,7 @@ qtype/dsl/custom_types.py,sha256=N3qswimv0foH40YDubHaTZ3HYF9RUbZ2x5eQ4i798Ko,290
|
|
|
26
26
|
qtype/dsl/domain_types.py,sha256=-pX74DKwrRanoXBxYqAdN_f44ike6ssRV3tZ20R2PhQ,4319
|
|
27
27
|
qtype/dsl/linker.py,sha256=c7PPTULy7_z_9u_qeseIaomR_B8kBa9YzOhQpjeGaSM,12975
|
|
28
28
|
qtype/dsl/loader.py,sha256=mht0BqfmyTNHIEDaF3iTEmYQLJBP5GIZULwexxw9Dpg,9771
|
|
29
|
-
qtype/dsl/model.py,sha256=
|
|
29
|
+
qtype/dsl/model.py,sha256=GS3_I4AAq3bIQJn9Nr2M834xa4SqmVddCqGAJ_ZeBOk,42250
|
|
30
30
|
qtype/dsl/parser.py,sha256=Ww32bLQ2vGOObsA-vWjaMh4TOKRwEA7FAt9U6wjKZkw,5490
|
|
31
31
|
qtype/dsl/types.py,sha256=k6cgThA287bZ_pvTKQvxWhatcYCPNne8zpqOYOvLvOg,1687
|
|
32
32
|
qtype/interpreter/__init__.py,sha256=IaRF90JLFbsTLKz9LTOMI_Pz4xwVaEyXPNaXV7sLou8,43
|
|
@@ -134,9 +134,9 @@ qtype/semantic/loader.py,sha256=QRhTc_AJfsWSMn8ThaW60GmIGjFMN-3bBUy4pktFjz4,3041
|
|
|
134
134
|
qtype/semantic/model.py,sha256=eUPmdYgtRxx2U3zcC4thjh52-vHuNQAKS10hCRGjr14,28724
|
|
135
135
|
qtype/semantic/resolver.py,sha256=bWPCSB8KJpVqN_n41U_r-qzUiT8vAMBOD3pOGmxL6TY,4618
|
|
136
136
|
qtype/semantic/visualize.py,sha256=thjrZcfQuZJWrZ9EMAPhAa2kNikR5rLIJrfcD3hJ8XY,17426
|
|
137
|
-
qtype-0.1.
|
|
138
|
-
qtype-0.1.
|
|
139
|
-
qtype-0.1.
|
|
140
|
-
qtype-0.1.
|
|
141
|
-
qtype-0.1.
|
|
142
|
-
qtype-0.1.
|
|
137
|
+
qtype-0.1.10.dist-info/licenses/LICENSE,sha256=1KA5EgYBSR0O6nCH2HEvk6Di53YKJ9r_VCR7G8G8qAY,11341
|
|
138
|
+
qtype-0.1.10.dist-info/METADATA,sha256=EwAyMpRp7sop4mRZOATAM9ccOv2RqzFEKBPWC3py4EE,5658
|
|
139
|
+
qtype-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
140
|
+
qtype-0.1.10.dist-info/entry_points.txt,sha256=5y4vj8RLvgl2tXSj-Hm7v5-Tn3kP4-UonjNoN-mfaQE,41
|
|
141
|
+
qtype-0.1.10.dist-info/top_level.txt,sha256=ONroH5B0mZ51jr7NSWCK0weFwwCO7wBLmyVS1YqNU14,6
|
|
142
|
+
qtype-0.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|