|
94 | 94 | (doseq [[nm edn-schema] properties] |
95 | 95 | (.addProperty obj-build (name nm) (edn->sch edn-schema))) |
96 | 96 | (.build obj-build))) |
97 | | - |
98 | | -(comment |
99 | | - (edn->sch {:type :string |
100 | | - :description "Hello"}) |
101 | | - (edn->sch {:type :integer |
102 | | - :description "Hello"}) |
103 | | - (edn->sch {:type :number |
104 | | - :description "Hello"}) |
105 | | - (edn->sch {:type :boolean |
106 | | - :description "Hello"}) |
107 | | - |
108 | | - (edn->sch {:enum ["a"]}) |
109 | | - |
110 | | - ;; Mixed types example |
111 | | - (edn->sch {:type ["string" "number"] |
112 | | - :description "Can be string or number"}) |
113 | | - |
114 | | - (edn->sch {:type :array |
115 | | - :items {:type :integer |
116 | | - :description "Hello"}}) |
117 | | - |
118 | | - ;; Array with mixed types |
119 | | - (edn->sch {:type :array |
120 | | - :items {:type ["string" "number"]}}) |
121 | | - |
122 | | - ;; Complete example: Creating a ToolSpecification |
123 | | - (import '[dev.langchain4j.agent.tool ToolSpecification]) |
124 | | - |
125 | | - (let [schema {:type :object |
126 | | - :properties {:op {:enum ["set_path" "get_path" "delete_path" "inspect"]} |
127 | | - :path {:type :array |
128 | | - :items {:type ["string" "number"]}} |
129 | | - :value {:type ["object" "array" "string" "number" "boolean"]} |
130 | | - :explanation {:type :string}} |
131 | | - :required [:op :explanation]} |
132 | | - params (edn->sch schema)] |
133 | | - (-> (ToolSpecification/builder) |
134 | | - (.name "scratch_pad") |
135 | | - (.description "Persistent data storage") |
136 | | - (.parameters params) |
137 | | - .build)) |
138 | | - |
139 | | - (edn->sch {:type :object |
140 | | - :description "HOWDy" |
141 | | - :properties {:name {:type :string |
142 | | - :description "The name"} |
143 | | - :path {:type :array |
144 | | - :items {:type ["string" "number"] |
145 | | - :description "Can be string or number key"}} |
146 | | - :value {:type ["object" "array" "string" "number" "boolean" "null"] |
147 | | - :description "Any JSON value"} |
148 | | - :edits {:type :array |
149 | | - :items {:type :object |
150 | | - :properties {:old {:type :string |
151 | | - :description "The name"} |
152 | | - :new {:type :string |
153 | | - :description "The name"}} |
154 | | - :required [:old :new]}}}})) |
155 | | - |
0 commit comments