fix(core): make `convert_to_openai_function` handle callables and non-dict mappings (#39750)