agentskills.py 927 B

12345678910111213141516171819202122232425
  1. from inspect import signature
  2. from openhands.runtime.plugins.agent_skills import file_ops, file_reader
  3. from openhands.runtime.plugins.agent_skills.utils.dependency import import_functions
  4. import_functions(
  5. module=file_ops, function_names=file_ops.__all__, target_globals=globals()
  6. )
  7. import_functions(
  8. module=file_reader, function_names=file_reader.__all__, target_globals=globals()
  9. )
  10. __all__ = file_ops.__all__ + file_reader.__all__
  11. DOCUMENTATION = ''
  12. for func_name in __all__:
  13. func = globals()[func_name]
  14. cur_doc = func.__doc__
  15. # remove indentation from docstring and extra empty lines
  16. cur_doc = '\n'.join(filter(None, map(lambda x: x.strip(), cur_doc.split('\n'))))
  17. # now add a consistent 4 indentation
  18. cur_doc = '\n'.join(map(lambda x: ' ' * 4 + x, cur_doc.split('\n')))
  19. fn_signature = f'{func.__name__}' + str(signature(func))
  20. DOCUMENTATION += f'{fn_signature}:\n{cur_doc}\n\n'