|
21 | 21 |
|
22 | 22 |
|
23 | 23 | class Skills: |
| 24 | + """ |
| 25 | + Manages access to pre-imported automation skills. |
| 26 | +
|
| 27 | + Note: Skills system must be enabled via profile (like 'the01') or by creating |
| 28 | + OpenInterpreter with import_skills=True. |
| 29 | +
|
| 30 | + Available methods: |
| 31 | + - list(): Returns names of available skills |
| 32 | + - search(query): Lists available skills (currently same as list()) |
| 33 | +
|
| 34 | + Usage: |
| 35 | + To use a skill, call it directly as a function: |
| 36 | + example_skill() |
| 37 | +
|
| 38 | + To create a new skill: |
| 39 | + computer.skills.new_skill.create() |
| 40 | + """ |
24 | 41 | def __init__(self, computer): |
25 | 42 | self.computer = computer |
26 | 43 | self.path = str(Path(oi_dir) / "skills") |
27 | 44 | self.new_skill = NewSkill(self) |
28 | 45 |
|
29 | 46 | def list(self): |
| 47 | + """ |
| 48 | + Lists all available skills. Skills are already imported and can be called directly. |
| 49 | +
|
| 50 | + Returns: |
| 51 | + list[str]: Names of available skills with () to indicate they're callable |
| 52 | + """ |
| 53 | + if not self.computer.import_skills: |
| 54 | + print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, " |
| 55 | + "or create an instance of OpenInterpreter with import_skills=True") |
| 56 | + return [] |
| 57 | + |
| 58 | + if not self.computer._has_imported_skills: |
| 59 | + print("Skills have not been imported yet.") |
| 60 | + return [] |
| 61 | + |
30 | 62 | return [ |
31 | 63 | file.replace(".py", "()") |
32 | 64 | for file in os.listdir(self.path) |
33 | 65 | if file.endswith(".py") |
34 | 66 | ] |
35 | 67 |
|
36 | 68 | def run(self, skill): |
| 69 | + """ |
| 70 | + DEPRECATED: Do not use this method. |
| 71 | + Skills are already imported - call them directly as functions instead. |
| 72 | + """ |
37 | 73 | print( |
38 | 74 | "To run a skill, run its name as a function name (it is already imported)." |
39 | 75 | ) |
40 | 76 |
|
41 | 77 | def search(self, query): |
42 | 78 | """ |
43 | | - This just lists all for now. |
| 79 | + Lists available skills (currently same as list()). |
| 80 | + Skills are already imported and can be called directly. |
| 81 | +
|
| 82 | + Returns: |
| 83 | + list[str]: Names of available skills with () to indicate they're callable |
44 | 84 | """ |
| 85 | + if not self.computer.import_skills: |
| 86 | + print("Skills are disabled. To enable skills, either use a profile like 'the01' that supports skills, " |
| 87 | + "or create an instance of OpenInterpreter with import_skills=True") |
| 88 | + return [] |
| 89 | + |
| 90 | + if not self.computer._has_imported_skills: |
| 91 | + print("Skills have not been imported yet.") |
| 92 | + return [] |
| 93 | + |
45 | 94 | return [ |
46 | 95 | file.replace(".py", "()") |
47 | 96 | for file in os.listdir(self.path) |
48 | 97 | if file.endswith(".py") |
49 | 98 | ] |
50 | 99 |
|
51 | 100 | def import_skills(self): |
| 101 | + """ |
| 102 | + [INTERNAL METHOD - NOT FOR Assistant USE] |
| 103 | + System initialization method that imports all Python files from the skills directory. |
| 104 | +
|
| 105 | + This method is called automatically during system setup to load available skills. |
| 106 | + Assistant should use list(), search(), or call skills directly instead of this method. |
| 107 | + """ |
| 108 | + if not self.computer.import_skills: |
| 109 | + return |
| 110 | + |
52 | 111 | previous_save_skills_setting = self.computer.save_skills |
53 | 112 |
|
54 | 113 | self.computer.save_skills = False |
|
0 commit comments