Skip to content

Commit 68de996

Browse files
authored
Plugin Framework (#19)
* lots of changes, mostly cleaning, but also plugins * replace magic values * plugin examples wip * character distinction in history * better plugin examples * better default character showcasing plugins * modified defaults for clarity * prepare for additional ai modules * fix yaml * more cleanup * docstrings, bug fixes, and improvements * separate core from modules
1 parent 8581138 commit 68de996

69 files changed

Lines changed: 925 additions & 1174 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,18 @@ cython_debug/
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
.idea/
161161

162-
# Custom
162+
# Mac
163+
.DS_Store
164+
165+
# Sierra
163166
temp/*
164-
*.sierra
167+
**/*.sierra
165168
**/secrets.yaml
166-
**/user_token.json
167-
.DS_Store
169+
170+
# Prefix characters and tasks with . to avoid git tracking
171+
play/characters/!*
172+
play/tasks/!*
173+
174+
ai/*/
175+
input/*/
176+
plugins/*/

ai/__init__.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,35 @@
66

77

88
class Function(Enum):
9+
"""
10+
The different functions that can be called on an AI.
11+
"""
912
CHAT = "Chat"
1013
SPEAK = "Speak"
1114
TRANSCRIBE = "Transcribe"
1215

1316

1417
class Role(Enum):
18+
"""
19+
The different roles that an AI can have.
20+
"""
1521
ASSISTANT = "assistant"
1622
USER = "user"
1723
SYSTEM = "system"
1824

1925

20-
modules = {}
26+
ai = {}
2127
for ai_glob in glob(path.join('ai', '*')):
22-
if isdir(ai_glob):
23-
modules[path.split(ai_glob)[-1]] = import_module('.'.join(path.split(ai_glob)))
28+
if isdir(ai_glob) and not ai_glob.startswith('_'):
29+
if path.exists(path.join(ai_glob, '__init__.py')):
30+
ai[path.split(ai_glob)[-1]] = import_module('.'.join(path.split(ai_glob)))
2431

2532

2633
def load(name, function):
27-
return getattr(modules.get(name), function.value)
34+
"""
35+
`load` function to load a function from an AI.
36+
:param name:
37+
:param function:
38+
:return:
39+
"""
40+
return getattr(ai.get(name), function.value)

ai/elevenlabs/__init__.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

ai/elevenlabs/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

ai/elevenlabs/settings.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ai/input.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
class Input:
1+
from uuid import uuid4
2+
23

4+
class Input:
5+
"""
6+
`Input` class to represent an input.
7+
"""
38
def __init__(self, json):
4-
self.character = json.get("character", None)
5-
self.message = json.get("message", None)
9+
"""
10+
:param json: dict
11+
"""
12+
self.id = uuid4()
13+
self.character = json.get('character', None)
14+
self.message = json.get('message', None)
15+
self.source = json.get('source', None)

ai/modules.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
git@github.com:point-and-click/elevenlabs.git
2+
git@github.com:point-and-click/open_ai.git
3+
git@github.com:point-and-click/play_ht.git

ai/open_ai/__init__.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

ai/open_ai/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

ai/open_ai/settings.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)