synth-ai 0.1.4__py3-none-any.whl → 0.1.5__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.
synth_ai/__init__.py CHANGED
@@ -4,5 +4,5 @@ Synth AI - Software for aiding the best and multiplying the will.
4
4
 
5
5
  from synth_ai.zyk import LM # Assuming LM is in zyk.py in the same directory
6
6
 
7
- __version__ = "0.1.4"
7
+ __version__ = "0.1.5"
8
8
  __all__ = ["LM"] # Explicitly define public API
@@ -0,0 +1,3 @@
1
+ from .base import BaseTool
2
+
3
+ __all__ = ["BaseTool"]
@@ -0,0 +1,118 @@
1
+ from typing import Type
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class BaseTool(BaseModel):
7
+ name: str
8
+ arguments: Type[BaseModel]
9
+ description: str = ""
10
+ strict: bool = True
11
+
12
+ def to_openai_tool(self):
13
+ schema = self.arguments.model_json_schema()
14
+ schema["additionalProperties"] = False
15
+
16
+ if "properties" in schema:
17
+ for prop_name, prop_schema in schema["properties"].items():
18
+ if prop_schema.get("type") == "array":
19
+ items_schema = prop_schema.get("items", {})
20
+ if not isinstance(items_schema, dict) or not items_schema.get("type"):
21
+ prop_schema["items"] = {"type": "string"}
22
+
23
+ elif "anyOf" in prop_schema:
24
+ for sub_schema in prop_schema["anyOf"]:
25
+ if isinstance(sub_schema, dict) and sub_schema.get("type") == "array":
26
+ items_schema = sub_schema.get("items", {})
27
+ if not isinstance(items_schema, dict) or not items_schema.get("type"):
28
+ sub_schema["items"] = {"type": "string"}
29
+
30
+ return {
31
+ "type": "function",
32
+ "function": {
33
+ "name": self.name,
34
+ "description": self.description,
35
+ "parameters": schema,
36
+ "strict": self.strict,
37
+ },
38
+ }
39
+
40
+ def to_anthropic_tool(self):
41
+ schema = self.arguments.model_json_schema()
42
+ schema["additionalProperties"] = False
43
+
44
+ return {
45
+ "name": self.name,
46
+ "description": self.description,
47
+ "input_schema": {
48
+ "type": "object",
49
+ "properties": schema["properties"],
50
+ "required": schema.get("required", []),
51
+ },
52
+ }
53
+
54
+ def to_mistral_tool(self):
55
+ schema = self.arguments.model_json_schema()
56
+ properties = {}
57
+ for prop_name, prop in schema.get("properties", {}).items():
58
+ prop_type = prop["type"]
59
+ if prop_type == "array" and "items" in prop:
60
+ properties[prop_name] = {
61
+ "type": "array",
62
+ "items": prop["items"],
63
+ "description": prop.get("description", ""),
64
+ }
65
+ continue
66
+
67
+ properties[prop_name] = {
68
+ "type": prop_type,
69
+ "description": prop.get("description", ""),
70
+ }
71
+ if "enum" in prop:
72
+ properties[prop_name]["enum"] = prop["enum"]
73
+
74
+ parameters = {
75
+ "type": "object",
76
+ "properties": properties,
77
+ "required": schema.get("required", []),
78
+ "additionalProperties": False,
79
+ }
80
+ return {
81
+ "type": "function",
82
+ "function": {
83
+ "name": self.name,
84
+ "description": self.description,
85
+ "parameters": parameters,
86
+ },
87
+ }
88
+
89
+ def to_gemini_tool(self):
90
+ schema = self.arguments.model_json_schema()
91
+ # Convert Pydantic schema types to Gemini schema types
92
+ properties = {}
93
+ for name, prop in schema["properties"].items():
94
+ prop_type = prop.get("type", "string")
95
+ if prop_type == "array" and "items" in prop:
96
+ properties[name] = {
97
+ "type": "array",
98
+ "items": prop["items"],
99
+ "description": prop.get("description", ""),
100
+ }
101
+ continue
102
+
103
+ properties[name] = {
104
+ "type": prop_type,
105
+ "description": prop.get("description", ""),
106
+ }
107
+ if "enum" in prop:
108
+ properties[name]["enum"] = prop["enum"]
109
+
110
+ return {
111
+ "name": self.name,
112
+ "description": self.description,
113
+ "parameters": {
114
+ "type": "object",
115
+ "properties": properties,
116
+ "required": schema.get("required", []),
117
+ },
118
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synth-ai
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Home-page: https://github.com/synth-laboratories/synth-ai
5
5
  Author: Josh Purtell
6
6
  Author-email: josh@usesynth.com
@@ -1,4 +1,4 @@
1
- synth_ai/__init__.py,sha256=06VvZlwVtT7OXvu5iqFvWhLw46BmQsIAYQe8wHNUiB0,225
1
+ synth_ai/__init__.py,sha256=-qLyQqdy3njK2e_kHYslyaPezwEs9XgpovFi4ZyJWBs,225
2
2
  synth_ai/zyk/__init__.py,sha256=kGMD-drlBVdsyT-QFODMwaZUtxPCJ9mg58GKQUvFqo0,134
3
3
  synth_ai/zyk/lms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  synth_ai/zyk/lms/config.py,sha256=UBMi0DIFQDBV_eGPK5vG8R7VwxXcV10BPGq1iV8vVjg,282
@@ -22,6 +22,8 @@ synth_ai/zyk/lms/structured_outputs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
22
22
  synth_ai/zyk/lms/structured_outputs/handler.py,sha256=4DboLNZyXpqNB5YNCSgGHBsNbWqFk-8uwV944nOYNo8,16919
23
23
  synth_ai/zyk/lms/structured_outputs/inject.py,sha256=Fy-zDeleRxOZ8ZRM6IuZ6CP2XZnMe4K2PEn4Q9c_KPY,11777
24
24
  synth_ai/zyk/lms/structured_outputs/rehabilitate.py,sha256=ecKGWrgWYUSplqHzK40KdohwaN8gBV0xl4LUReLN_vg,7910
25
+ synth_ai/zyk/lms/tools/__init__.py,sha256=3JM5vqZqKloaeHaxuO49C8A_0qljys3pQ1yt70WKhho,51
26
+ synth_ai/zyk/lms/tools/base.py,sha256=i-AIVRlitiQ4JMJ_BBFRSpUcWgxWIUYoHxAqfxHN_7E,4056
25
27
  synth_ai/zyk/lms/vendors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
28
  synth_ai/zyk/lms/vendors/base.py,sha256=aK4PEtkMLt_o3qD22kW-x3HJUEKdIk06zlH4kX0VkAE,760
27
29
  synth_ai/zyk/lms/vendors/openai_standard.py,sha256=dgHC7RWrxwaWto6_frKdfEKazKvvAMYJM1YgJgbVpb8,12279
@@ -39,8 +41,8 @@ synth_ai/zyk/lms/vendors/supported/deepseek.py,sha256=BElW0NGpkSA62wOqzzMtDw8XR3
39
41
  synth_ai/zyk/lms/vendors/supported/groq.py,sha256=Fbi7QvhdLx0F-VHO5PY-uIQlPR0bo3C9h1MvIOx8nz0,388
40
42
  synth_ai/zyk/lms/vendors/supported/ollama.py,sha256=K30VBFRTd7NYyPmyBVRZS2sm0UB651AHp9i3wd55W64,469
41
43
  synth_ai/zyk/lms/vendors/supported/together.py,sha256=Ni_jBqqGPN0PkkY-Ew64s3gNKk51k3FCpLSwlNhKbf0,342
42
- synth_ai-0.1.4.dist-info/licenses/LICENSE,sha256=ynhjRQUfqA_RdGRATApfFA_fBAy9cno04sLtLUqxVFM,1069
43
- synth_ai-0.1.4.dist-info/METADATA,sha256=Bz_Gf7gZtnLIJdgjrD17XS_HQNj_oGlXdFufcrLP2Ko,1084
44
- synth_ai-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- synth_ai-0.1.4.dist-info/top_level.txt,sha256=fBmtZyVHuKaGa29oHBaaUkrUIWTqSpoVMPiVdCDP3k8,9
46
- synth_ai-0.1.4.dist-info/RECORD,,
44
+ synth_ai-0.1.5.dist-info/licenses/LICENSE,sha256=ynhjRQUfqA_RdGRATApfFA_fBAy9cno04sLtLUqxVFM,1069
45
+ synth_ai-0.1.5.dist-info/METADATA,sha256=Ip_93PnkbnO2yIKXxg-Pzqi7oBF7s4DrM5UYlXnUSBE,1084
46
+ synth_ai-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ synth_ai-0.1.5.dist-info/top_level.txt,sha256=fBmtZyVHuKaGa29oHBaaUkrUIWTqSpoVMPiVdCDP3k8,9
48
+ synth_ai-0.1.5.dist-info/RECORD,,