@@ -804,7 +804,22 @@ def convert_to_oci_tool(
804804 Raises:
805805 ValueError: If the tool type is not supported.
806806 """
807- if isinstance (tool , BaseTool ):
807+ if (isinstance (tool , type ) and issubclass (tool , BaseModel )) or callable (tool ):
808+ as_json_schema_function = convert_to_openai_function (tool )
809+ parameters = as_json_schema_function .get ("parameters" , {})
810+ return self .oci_function_definition (
811+ name = as_json_schema_function .get ("name" ),
812+ description = as_json_schema_function .get (
813+ "description" ,
814+ as_json_schema_function .get ("name" ),
815+ ),
816+ parameters = {
817+ "type" : "object" ,
818+ "properties" : parameters .get ("properties" , {}),
819+ "required" : parameters .get ("required" , []),
820+ },
821+ )
822+ elif isinstance (tool , BaseTool ):
808823 return self .oci_function_definition (
809824 name = tool .name ,
810825 description = OCIUtils .remove_signature_from_tool_description (
@@ -826,21 +841,6 @@ def convert_to_oci_tool(
826841 ],
827842 },
828843 )
829- elif (isinstance (tool , type ) and issubclass (tool , BaseModel )) or callable (tool ):
830- as_json_schema_function = convert_to_openai_function (tool )
831- parameters = as_json_schema_function .get ("parameters" , {})
832- return self .oci_function_definition (
833- name = as_json_schema_function .get ("name" ),
834- description = as_json_schema_function .get (
835- "description" ,
836- as_json_schema_function .get ("name" ),
837- ),
838- parameters = {
839- "type" : "object" ,
840- "properties" : parameters .get ("properties" , {}),
841- "required" : parameters .get ("required" , []),
842- },
843- )
844844 raise ValueError (
845845 f"Unsupported tool type { type (tool )} . "
846846 "Tool must be passed in as a BaseTool "
0 commit comments