agentic-blocks 0.1.11__py3-none-any.whl → 0.1.13__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.
- agentic_blocks/utils/tools_utils.py +36 -6
- {agentic_blocks-0.1.11.dist-info → agentic_blocks-0.1.13.dist-info}/METADATA +1 -1
- {agentic_blocks-0.1.11.dist-info → agentic_blocks-0.1.13.dist-info}/RECORD +6 -6
- {agentic_blocks-0.1.11.dist-info → agentic_blocks-0.1.13.dist-info}/WHEEL +0 -0
- {agentic_blocks-0.1.11.dist-info → agentic_blocks-0.1.13.dist-info}/licenses/LICENSE +0 -0
- {agentic_blocks-0.1.11.dist-info → agentic_blocks-0.1.13.dist-info}/top_level.txt +0 -0
@@ -18,16 +18,46 @@ def langchain_tool_to_openai_format(tool) -> Dict[str, Any]:
|
|
18
18
|
"""
|
19
19
|
schema = tool.args_schema.model_json_schema()
|
20
20
|
|
21
|
+
# Resolve $ref references by flattening $defs into the schema
|
22
|
+
# OpenAI doesn't support $ref/$defs, so we need to inline all definitions
|
23
|
+
def resolve_refs(obj, defs):
|
24
|
+
if isinstance(obj, dict):
|
25
|
+
if "$ref" in obj:
|
26
|
+
# Extract the reference path (e.g., "#/$defs/Todo" -> "Todo")
|
27
|
+
ref_path = obj["$ref"].split("/")[-1]
|
28
|
+
if ref_path in defs:
|
29
|
+
# Return the resolved definition, recursively resolving any nested refs
|
30
|
+
return resolve_refs(defs[ref_path], defs)
|
31
|
+
else:
|
32
|
+
return obj # Keep unresolvable refs as-is
|
33
|
+
else:
|
34
|
+
# Recursively resolve refs in nested objects
|
35
|
+
return {k: resolve_refs(v, defs) for k, v in obj.items()}
|
36
|
+
elif isinstance(obj, list):
|
37
|
+
# Recursively resolve refs in arrays
|
38
|
+
return [resolve_refs(item, defs) for item in obj]
|
39
|
+
else:
|
40
|
+
return obj
|
41
|
+
|
42
|
+
# Get definitions for reference resolution
|
43
|
+
defs = schema.get("$defs", {})
|
44
|
+
|
45
|
+
# Resolve references in properties
|
46
|
+
resolved_properties = resolve_refs(schema.get("properties", {}), defs)
|
47
|
+
|
48
|
+
# Build parameters object without $defs
|
49
|
+
parameters = {
|
50
|
+
"type": "object",
|
51
|
+
"properties": resolved_properties,
|
52
|
+
"required": schema.get("required", [])
|
53
|
+
}
|
54
|
+
|
21
55
|
return {
|
22
56
|
"type": "function",
|
23
57
|
"function": {
|
24
58
|
"name": schema.get("title", tool.name),
|
25
|
-
"description": schema.get("description", ""),
|
26
|
-
"parameters":
|
27
|
-
"type": "object",
|
28
|
-
"properties": schema.get("properties", {}),
|
29
|
-
"required": schema.get("required", [])
|
30
|
-
}
|
59
|
+
"description": tool.description or schema.get("description", ""),
|
60
|
+
"parameters": parameters
|
31
61
|
}
|
32
62
|
}
|
33
63
|
|
@@ -2,9 +2,9 @@ agentic_blocks/__init__.py,sha256=LJy2tzTwX9ZjPw8dqkXOWiude7ZDDIaBIvaLC8U4d_Y,43
|
|
2
2
|
agentic_blocks/llm.py,sha256=q2Utx2NiffLrp7VHmQIRZtBtrnQSMFtqCeYs9ynj0Ww,5335
|
3
3
|
agentic_blocks/mcp_client.py,sha256=15mIN_Qw0OVNJAvfgO3jVZS4-AU4TtvEQSFDlL9ruqA,9773
|
4
4
|
agentic_blocks/messages.py,sha256=dxaR_-IiH8n7pZygFDiUt8n7mMOm--FRuN-xCQEuewo,11758
|
5
|
-
agentic_blocks/utils/tools_utils.py,sha256=
|
6
|
-
agentic_blocks-0.1.
|
7
|
-
agentic_blocks-0.1.
|
8
|
-
agentic_blocks-0.1.
|
9
|
-
agentic_blocks-0.1.
|
10
|
-
agentic_blocks-0.1.
|
5
|
+
agentic_blocks/utils/tools_utils.py,sha256=eyqPZRNMTAURuau64ohNCsmxlNM2cOmnmTAYGbZYk8A,7003
|
6
|
+
agentic_blocks-0.1.13.dist-info/licenses/LICENSE,sha256=r4IcBaAjTv3-yfjXgDPuRD953Qci0Y0nQn5JfHwLyBY,1073
|
7
|
+
agentic_blocks-0.1.13.dist-info/METADATA,sha256=0l7qEy5vcodKloGqlhpMKMKqAakpjabU7kL0ZM-mOvE,11944
|
8
|
+
agentic_blocks-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
agentic_blocks-0.1.13.dist-info/top_level.txt,sha256=-1a4RAemqicXLU1rRzw4QHV3KlNeQDNxVs3m2gAT238,15
|
10
|
+
agentic_blocks-0.1.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|