@@ -267,12 +267,19 @@ public enum AnthropicInputContent: Encodable {
267
267
case image( mediaType: AnthropicImageMediaType , data: String )
268
268
case pdf( data: String )
269
269
case text( String )
270
+ case toolUse( id: String , name: String , input: [ String : AIProxyJSONValue ] )
271
+ case toolResult( toolUseId: String , content: String )
270
272
271
273
private enum CodingKeys : String , CodingKey {
272
274
case image
273
275
case source
274
276
case text
275
277
case type
278
+ case id
279
+ case name
280
+ case input
281
+ case toolUseId = " tool_use_id "
282
+ case content
276
283
}
277
284
278
285
private enum SourceCodingKeys : String , CodingKey {
@@ -299,6 +306,15 @@ public enum AnthropicInputContent: Encodable {
299
306
case . text( let txt) :
300
307
try container. encode ( " text " , forKey: . type)
301
308
try container. encode ( txt, forKey: . text)
309
+ case . toolUse( id: let id, name: let name, input: let input) :
310
+ try container. encode ( " tool_use " , forKey: . type)
311
+ try container. encode ( id, forKey: . id)
312
+ try container. encode ( name, forKey: . name)
313
+ try container. encode ( input, forKey: . input)
314
+ case . toolResult( toolUseId: let toolUseId, content: let content) :
315
+ try container. encode ( " tool_result " , forKey: . type)
316
+ try container. encode ( toolUseId, forKey: . toolUseId)
317
+ try container. encode ( content, forKey: . content)
302
318
}
303
319
}
304
320
}
@@ -344,6 +360,25 @@ public enum AnthropicToolChoice: Encodable {
344
360
case any
345
361
case auto
346
362
case tool( name: String )
363
+
364
+ public func encode( to encoder: Encoder ) throws {
365
+ var container = encoder. container ( keyedBy: CodingKeys . self)
366
+
367
+ switch self {
368
+ case . auto:
369
+ try container. encode ( " auto " , forKey: . type)
370
+ case . any:
371
+ try container. encode ( " any " , forKey: . type)
372
+ case . tool( let name) :
373
+ try container. encode ( " tool " , forKey: . type)
374
+ try container. encode ( name, forKey: . name)
375
+ }
376
+ }
377
+
378
+ private enum CodingKeys : String , CodingKey {
379
+ case type
380
+ case name
381
+ }
347
382
}
348
383
349
384
0 commit comments