ailoy-py 0.0.3__cp313-cp313-macosx_14_0_arm64.whl → 0.0.5__cp313-cp313-macosx_14_0_arm64.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.

Potentially problematic release.


This version of ailoy-py might be problematic. Click here for more details.

Binary file
ailoy/agent.py CHANGED
@@ -216,8 +216,11 @@ class ToolParameters(BaseModel):
216
216
  required: Optional[list[str]] = []
217
217
 
218
218
 
219
+ JsonSchemaTypes = Literal["string", "integer", "number", "boolean", "object", "array", "null"]
220
+
221
+
219
222
  class ToolParametersProperty(BaseModel):
220
- type: Literal["string", "number", "boolean", "object", "array", "null"]
223
+ type: JsonSchemaTypes | list[JsonSchemaTypes]
221
224
  description: Optional[str] = None
222
225
  model_config = ConfigDict(extra="allow")
223
226
 
@@ -506,7 +509,9 @@ class Agent:
506
509
  raise RuntimeError("Tool not found")
507
510
  tool_result = tool_.call(**tool_call.function.arguments)
508
511
  return ToolMessage(
509
- content=[TextContent(text=json.dumps(tool_result))],
512
+ content=[
513
+ TextContent(text=tool_result if isinstance(tool_result, str) else json.dumps(tool_result))
514
+ ],
510
515
  tool_call_id=tool_call.id,
511
516
  )
512
517
 
Binary file
ailoy/models/api_model.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Literal, Optional, Self, get_args
1
+ from typing import Literal, Optional, get_args
2
2
 
3
3
  from pydantic import model_validator
4
4
  from pydantic.dataclasses import dataclass
@@ -34,7 +34,20 @@ ClaudeModelId = Literal[
34
34
  "claude-3-haiku-20240307",
35
35
  ]
36
36
 
37
- APIModelProvider = Literal["openai", "gemini", "claude"]
37
+ GrokModelId = Literal[
38
+ "grok-4",
39
+ "grok-4-0709",
40
+ "grok-3",
41
+ "grok-3-fast",
42
+ "grok-3-mini",
43
+ "grok-3-mini-fast",
44
+ "grok-2",
45
+ "grok-2-1212",
46
+ "grok-2-vision-1212",
47
+ "grok-2-image-1212",
48
+ ]
49
+
50
+ APIModelProvider = Literal["openai", "gemini", "claude", "grok"]
38
51
 
39
52
 
40
53
  @dataclass
@@ -44,7 +57,7 @@ class APIModel:
44
57
  provider: Optional[APIModelProvider] = None
45
58
 
46
59
  @model_validator(mode="after")
47
- def validate_provider(self) -> Self:
60
+ def validate_provider(self):
48
61
  if self.provider is None:
49
62
  if self.id in get_args(OpenAIModelId):
50
63
  self.provider = "openai"
@@ -52,6 +65,8 @@ class APIModel:
52
65
  self.provider = "gemini"
53
66
  elif self.id in get_args(ClaudeModelId):
54
67
  self.provider = "claude"
68
+ elif self.id in get_args(GrokModelId):
69
+ self.provider = "grok"
55
70
  else:
56
71
  raise ValueError(
57
72
  f'Failed to infer the model provider based on the model id "{self.id}". '
ailoy/tools.py CHANGED
@@ -5,6 +5,7 @@ import types
5
5
  from typing import (
6
6
  Any,
7
7
  Callable,
8
+ Literal,
8
9
  Optional,
9
10
  Union,
10
11
  get_args,
@@ -41,7 +42,7 @@ class DocstringParsingException(Exception):
41
42
  pass
42
43
 
43
44
 
44
- def _get_json_schema_type(param_type: str) -> dict[str, str]:
45
+ def _get_json_schema_type(param_type: type) -> dict[str, str]:
45
46
  type_mapping = {
46
47
  int: {"type": "integer"},
47
48
  float: {"type": "number"},
@@ -85,6 +86,20 @@ def _parse_type_hint(hint: str) -> dict:
85
86
  return_dict["nullable"] = True
86
87
  return return_dict
87
88
 
89
+ elif origin is Literal and len(args) > 0:
90
+ LITERAL_TYPES = (int, float, str, bool, type(None))
91
+ args_types = []
92
+ for arg in args:
93
+ if type(arg) not in LITERAL_TYPES:
94
+ raise TypeHintParsingException("Only the valid python literals can be listed in typing.Literal.")
95
+ arg_type = _get_json_schema_type(type(arg)).get("type")
96
+ if arg_type is not None and arg_type not in args_types:
97
+ args_types.append(arg_type)
98
+ return {
99
+ "type": args_types.pop() if len(args_types) == 1 else list(args_types),
100
+ "enum": list(args),
101
+ }
102
+
88
103
  elif origin is list:
89
104
  if not args:
90
105
  return {"type": "array"}
@@ -100,13 +115,13 @@ def _parse_type_hint(hint: str) -> dict:
100
115
  f"The type hint {str(hint).replace('typing.', '')} is a Tuple with a single element, which "
101
116
  "we do not automatically convert to JSON schema as it is rarely necessary. If this input can contain "
102
117
  "more than one element, we recommend "
103
- "using a List[] type instead, or if it really is a single element, remove the Tuple[] wrapper and just "
118
+ "using a list[] type instead, or if it really is a single element, remove the tuple[] wrapper and just "
104
119
  "pass the element directly."
105
120
  )
106
121
  if ... in args:
107
122
  raise TypeHintParsingException(
108
123
  "Conversion of '...' is not supported in Tuple type hints. "
109
- "Use List[] types for variable-length"
124
+ "Use list[] types for variable-length"
110
125
  " inputs instead."
111
126
  )
112
127
  return {"type": "array", "prefixItems": [_parse_type_hint(t) for t in args]}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ailoy-py
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Python binding for Ailoy runtime APIs
5
5
  Author-Email: "Brekkylab Inc." <contact@brekkylab.com>
6
6
  License-Expression: Apache-2.0
@@ -1,25 +1,25 @@
1
1
  ailoy/ailoy_py.pyi,sha256=Yf90FEXkslpCpr1r2eqQ3-_1jLo65zmG94bBXDRqinU,991
2
2
  ailoy/vector_store.py,sha256=ZfIuGYKv2dQmjOuDlSKDc-BBPlQ8no_70mZwnPzbBzo,7515
3
- ailoy/ailoy_py.cpython-313-darwin.so,sha256=FG58UO3OQ0Aq-JhSYKuwDdf0mrF4CyUl04vrTqyXpK4,15150112
4
- ailoy/tools.py,sha256=RnTfmWlqYY1q0V377CpAAyAK-yET7k45GgEhgM9G8eI,8207
3
+ ailoy/ailoy_py.cpython-313-darwin.so,sha256=eUBLZigHxAox-Z4x-XLDpcUltiKg_Ui_AGGdkyMU3rc,16572576
4
+ ailoy/tools.py,sha256=hLdKe3TN_yn2qSbNG0uX2extokPIdJ6inLbSbhXdYTo,8861
5
5
  ailoy/__init__.py,sha256=INeFsnHtrqTwkMKUPSdD_9l8DhudnW574e9rsRtrMJc,783
6
6
  ailoy/runtime.py,sha256=-75KawEMQSwxGvX5wtECVCWiTNdcHojsQ1e-OVB4IQ8,10545
7
7
  ailoy/mcp.py,sha256=wVzXfwUh4UcU60PYq17kCFG7ZClmEDBRt8LxetuSkns,6800
8
- ailoy/agent.py,sha256=F15s3FzyrQ3pfNb0ZCLOPV2mrFDNCcFbYFP02hEbAk4,26780
8
+ ailoy/agent.py,sha256=7v2E1ft1Aaufem9lxLEra3S-nX2fzeutJDgT-4LXwL8,26954
9
9
  ailoy/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  ailoy/utils/image.py,sha256=zkufequcQVTmIkArreYUyB8r2nrcOL_8O6KOv5B-yis,288
11
11
  ailoy/models/__init__.py,sha256=1AtlJV9gYThw_3snu0jPEH_aQGI74ip7ZcVJLtN5nMU,117
12
12
  ailoy/models/local_model.py,sha256=Iyur0UEUSbLKzptx9croP_OAF-qh9S-ZDukDthHNz9w,1206
13
- ailoy/models/api_model.py,sha256=_-2TSunBh8kZQOF1CkQXBKi81XNClPWH4U5hQA7ioQ4,1787
13
+ ailoy/models/api_model.py,sha256=kLDD1-R4hjgtTbIQkD-boT-ZK8UocmVyyHkI6tuxiFU,2090
14
14
  ailoy/cli/model.py,sha256=cerCHE-VY9TOwqRcLBtmqnV-5vphpvyhtrfPFZiTKCM,2979
15
15
  ailoy/cli/__main__.py,sha256=HnBVb2em1F2NLPeNX5r3xRndRrnGaXVCduo8WBULAI0,179
16
- ailoy/.dylibs/libomp.dylib,sha256=s963nLMIJ2lfA448nbin9lL52fnoeGySlgLfm4Y3HHs,735616
16
+ ailoy/.dylibs/libomp.dylib,sha256=WYWnZ4ZNA08i3x3QtaLX9j-seoAHIteaFTvQlNHcT68,735616
17
17
  ailoy/.dylibs/libtvm_runtime.dylib,sha256=Fqp5JsiIMAsS7p94oDdxY_-kAqbwGpBGpkS2LhYfhZs,4620384
18
18
  ailoy/presets/tools/tmdb.json,sha256=UGLN5uAJ2b-Hu3nLcW95WXDLB3mfC3rBYfQANp_e8Ps,7046
19
19
  ailoy/presets/tools/calculator.json,sha256=ePnZsjZChnvS08s9eVdIp4Bys_PlJBXPHCCjv6oMvzA,1040
20
20
  ailoy/presets/tools/nytimes.json,sha256=wrfe9bnAlSPzHladoGEX2oCAeE0wed3BvgXQ_Z2PdXg,918
21
21
  ailoy/presets/tools/frankfurter.json,sha256=bZ5vhszf_aR-B_QN4L2xrI5nR-f4AMZk41UUDq1dTXg,1152
22
- ailoy_py-0.0.3.dist-info/RECORD,,
23
- ailoy_py-0.0.3.dist-info/WHEEL,sha256=IauIlnhfSTTHWYl3k448G23nPyWAM0vVFFo6kZ6tZmc,141
24
- ailoy_py-0.0.3.dist-info/entry_points.txt,sha256=gVG45uDE6kef0wm6SEMYSgZgRNNRhSAeP2n2lPR00dI,50
25
- ailoy_py-0.0.3.dist-info/METADATA,sha256=ZvX6pFs2Fb3uBmm_73Cq3rtYs52pfjd5_cEVZSluK68,2053
22
+ ailoy_py-0.0.5.dist-info/RECORD,,
23
+ ailoy_py-0.0.5.dist-info/WHEEL,sha256=IauIlnhfSTTHWYl3k448G23nPyWAM0vVFFo6kZ6tZmc,141
24
+ ailoy_py-0.0.5.dist-info/entry_points.txt,sha256=gVG45uDE6kef0wm6SEMYSgZgRNNRhSAeP2n2lPR00dI,50
25
+ ailoy_py-0.0.5.dist-info/METADATA,sha256=WpOovIib4t4AWYNmIBRRixucdz9-wBetyxyDaLjzOk4,2053