Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve internal documentation of skills system #1585

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion interpreter/core/computer/skills/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,93 @@


class Skills:
"""
Manages access to pre-imported automation skills.

Note: Skills system must be enabled via profile (like 'the01') or by creating
OpenInterpreter with import_skills=True.

Available methods:
- list(): Returns names of available skills
- search(query): Lists available skills (currently same as list())

Usage:
To use a skill, call it directly as a function:
example_skill()

To create a new skill:
computer.skills.new_skill.create()
"""
def __init__(self, computer):
self.computer = computer
self.path = str(Path(oi_dir) / "skills")
self.new_skill = NewSkill(self)

def list(self):
"""
Lists all available skills. Skills are already imported and can be called directly.

Returns:
list[str]: Names of available skills with () to indicate they're callable
"""
if not self.computer.import_skills:
print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, "
"or create an instance of OpenInterpreter with import_skills=True")
return []

if not self.computer._has_imported_skills:
print("Skills have not been imported yet.")
return []

return [
file.replace(".py", "()")
for file in os.listdir(self.path)
if file.endswith(".py")
]

def run(self, skill):
"""
DEPRECATED: Do not use this method.
Skills are already imported - call them directly as functions instead.
"""
print(
"To run a skill, run its name as a function name (it is already imported)."
)

def search(self, query):
"""
This just lists all for now.
Lists available skills (currently same as list()).
Skills are already imported and can be called directly.

Returns:
list[str]: Names of available skills with () to indicate they're callable
"""
if not self.computer.import_skills:
print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, "
"or create an instance of OpenInterpreter with import_skills=True")
return []

if not self.computer._has_imported_skills:
print("Skills have not been imported yet.")
return []

return [
file.replace(".py", "()")
for file in os.listdir(self.path)
if file.endswith(".py")
]

def import_skills(self):
"""
[INTERNAL METHOD - NOT FOR Assistant USE]
System initialization method that imports all Python files from the skills directory.

This method is called automatically during system setup to load available skills.
Assistant should use list(), search(), or call skills directly instead of this method.
"""
if not self.computer.import_skills:
return

previous_save_skills_setting = self.computer.save_skills

self.computer.save_skills = False
Expand Down