agentic-blocks 0.1.12__py3-none-any.whl → 0.1.14__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.
@@ -18,22 +18,45 @@ def langchain_tool_to_openai_format(tool) -> Dict[str, Any]:
18
18
  """
19
19
  schema = tool.args_schema.model_json_schema()
20
20
 
21
- # Build parameters object, including $defs if present
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
22
49
  parameters = {
23
50
  "type": "object",
24
- "properties": schema.get("properties", {}),
51
+ "properties": resolved_properties,
25
52
  "required": schema.get("required", [])
26
53
  }
27
54
 
28
- # Include $defs if present in the schema
29
- if "$defs" in schema:
30
- parameters["$defs"] = schema["$defs"]
31
-
32
55
  return {
33
56
  "type": "function",
34
57
  "function": {
35
58
  "name": schema.get("title", tool.name),
36
- "description": schema.get("description", ""),
59
+ "description": tool.description or schema.get("description", ""),
37
60
  "parameters": parameters
38
61
  }
39
62
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentic-blocks
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Summary: Simple building blocks for agentic AI systems with MCP client and conversation management
5
5
  Author-email: Magnus Bjelkenhed <bjelkenhed@gmail.com>
6
6
  License: MIT
@@ -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=p1q0qcyQqAEYxoGNbWTRcn4R9CpTH0QkdWOc7OiGveg,5931
6
- agentic_blocks-0.1.12.dist-info/licenses/LICENSE,sha256=r4IcBaAjTv3-yfjXgDPuRD953Qci0Y0nQn5JfHwLyBY,1073
7
- agentic_blocks-0.1.12.dist-info/METADATA,sha256=vcmqy_lp9Nr5jirQeSHwqcx8hOoknXilYiJ9DYvtuxQ,11944
8
- agentic_blocks-0.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- agentic_blocks-0.1.12.dist-info/top_level.txt,sha256=-1a4RAemqicXLU1rRzw4QHV3KlNeQDNxVs3m2gAT238,15
10
- agentic_blocks-0.1.12.dist-info/RECORD,,
5
+ agentic_blocks/utils/tools_utils.py,sha256=eyqPZRNMTAURuau64ohNCsmxlNM2cOmnmTAYGbZYk8A,7003
6
+ agentic_blocks-0.1.14.dist-info/licenses/LICENSE,sha256=r4IcBaAjTv3-yfjXgDPuRD953Qci0Y0nQn5JfHwLyBY,1073
7
+ agentic_blocks-0.1.14.dist-info/METADATA,sha256=8oryqsu3J1qa_H2jsSYczRUuKOvAxqE51TE8dKaXoSg,11944
8
+ agentic_blocks-0.1.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ agentic_blocks-0.1.14.dist-info/top_level.txt,sha256=-1a4RAemqicXLU1rRzw4QHV3KlNeQDNxVs3m2gAT238,15
10
+ agentic_blocks-0.1.14.dist-info/RECORD,,