@@ -169,13 +169,14 @@ def convert_anthropic_tool_to_databricks_tool(
169
169
if tool is None :
170
170
return None
171
171
172
- kwags = {
173
- "name" :tool ["name" ],
174
- "parameters" :cast (dict , tool .get ("input_schema" ) or {})
172
+ kwags : dict = {
173
+ "name" : tool ["name" ],
174
+ "parameters" : cast (dict , tool .get ("input_schema" ) or {})
175
175
}
176
176
177
- if tool .get ("description" ):
178
- kwags ["description" ] = tool .get ("description" )
177
+ description = tool .get ("description" )
178
+ if description is not None :
179
+ kwags ["description" ] = cast (Union [dict , str ], description )
179
180
180
181
return DatabricksTool (
181
182
type = "function" ,
@@ -336,8 +337,8 @@ def extract_content_str(
336
337
elif isinstance (content , list ):
337
338
content_str = ""
338
339
for item in content :
339
- if item [ "type" ] == "text" :
340
- content_str += item [ "text" ]
340
+ if item . get ( "type" ) == "text" :
341
+ content_str += item . get ( "text" , "" )
341
342
return content_str
342
343
else :
343
344
raise Exception (f"Unsupported content type: { type (content )} " )
@@ -366,8 +367,9 @@ def extract_reasoning_content(
366
367
reasoning_content : Optional [str ] = None
367
368
if isinstance (content , list ):
368
369
for item in content :
369
- if item ["type" ] == "reasoning" :
370
- for sum in item ["summary" ]:
370
+ if item .get ("type" ) == "reasoning" :
371
+ summary_list = item .get ("summary" , [])
372
+ for sum in summary_list :
371
373
if reasoning_content is None :
372
374
reasoning_content = ""
373
375
reasoning_content += sum ["text" ]
0 commit comments