@@ -1248,6 +1248,77 @@ func TestTranslateOpenAItoAnthropicTools(t *testing.T) {
12481248 },
12491249 expectErr : true ,
12501250 },
1251+ {
1252+ name : "nested schema in tool's defintions" ,
1253+ openAIReq : & openai.ChatCompletionRequest {
1254+ Tools : []openai.Tool {
1255+ {
1256+ Type : "function" ,
1257+ Function : & openai.FunctionDefinition {
1258+ Name : "get_weather" ,
1259+ Description : "Get the weather without type" ,
1260+ Parameters : map [string ]any {
1261+ "properties" : map [string ]any {
1262+ "location" : map [string ]any {"type" : "string" },
1263+ },
1264+ "required" : []any {"location" },
1265+ "$defs" : map [string ]any {
1266+ "ReferencePassage" : map [string ]any {
1267+ "properties" : map [string ]any {
1268+ "url" : map [string ]any {
1269+ "title" : "Url" ,
1270+ "type" : "string" ,
1271+ },
1272+ "passage_id" : map [string ]any {
1273+ "title" : "Passage Id" ,
1274+ "type" : "string" ,
1275+ },
1276+ },
1277+ "required" : []string {"url" , "passage_id" },
1278+ "title" : "ReferencePassage" ,
1279+ "type" : "object" ,
1280+ },
1281+ },
1282+ },
1283+ },
1284+ },
1285+ },
1286+ },
1287+ expectedTools : []anthropic.ToolUnionParam {
1288+ {
1289+ OfTool : & anthropic.ToolParam {
1290+ Name : "get_weather" ,
1291+ Description : anthropic .String ("Get the weather without type" ),
1292+ InputSchema : anthropic.ToolInputSchemaParam {
1293+ Type : "" ,
1294+ Properties : map [string ]any {
1295+ "location" : map [string ]any {"type" : "string" },
1296+ },
1297+ Required : []string {"location" },
1298+ ExtraFields : map [string ]any {
1299+ "$defs" : map [string ]any {
1300+ "ReferencePassage" : map [string ]any {
1301+ "properties" : map [string ]any {
1302+ "url" : map [string ]any {
1303+ "title" : "Url" ,
1304+ "type" : "string" ,
1305+ },
1306+ "passage_id" : map [string ]any {
1307+ "title" : "Passage Id" ,
1308+ "type" : "string" ,
1309+ },
1310+ },
1311+ "required" : []string {"url" , "passage_id" },
1312+ "title" : "ReferencePassage" ,
1313+ "type" : "object" ,
1314+ },
1315+ },
1316+ },
1317+ },
1318+ },
1319+ },
1320+ },
1321+ },
12511322 }
12521323
12531324 for _ , tt := range tests {
0 commit comments