From 2ad57dad65f7ba9fc16400cbd252c502910c72ae Mon Sep 17 00:00:00 2001 From: Choonho Son Date: Fri, 27 Oct 2023 12:03:26 -0700 Subject: [PATCH] Add Jelly Signed-off-by: Choonho Son --- requirements.txt | 2 ++ src/jellys/Belty/CHARACTER.yml | 5 +++++ src/main.py | 31 +++++++++++++++++++++++++++---- src/persona.py | 16 ++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/jellys/Belty/CHARACTER.yml create mode 100644 src/persona.py diff --git a/requirements.txt b/requirements.txt index e69de29..4c59edf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,2 @@ +llama-cpp-python +langchain diff --git a/src/jellys/Belty/CHARACTER.yml b/src/jellys/Belty/CHARACTER.yml new file mode 100644 index 0000000..eb3125e --- /dev/null +++ b/src/jellys/Belty/CHARACTER.yml @@ -0,0 +1,5 @@ +--- +name: Belty +role: Stock Analyst + + diff --git a/src/main.py b/src/main.py index 12d7647..cb66c7f 100644 --- a/src/main.py +++ b/src/main.py @@ -1,10 +1,33 @@ # This is main function import os +import persona -persona = os.environ.get('PERSONA') +persona_name = os.environ.get('PERSONA', 'Wonny') + +def _list_all_jellys(): + directory_path = './jellys' + contents = os.listdir(directory_path) + result = [] + for item in contents: + result.append(item) + return result + +def _run_jelly(persona_name): + try: + print(f"Run {persona_name} jelly...") + persona.main(persona_name) + except Exception as e: + print(e) + +def main(persona_name): + if persona_name == 'Wonny': + jellys = _list_all_jellys() + else: + jellys = [persona_name] + + for jelly in jellys: + _run_jelly(jelly) -def main(persona): - print(f"Run {persona} function...") if __name__ == "__main__": - main(persona) + main(persona_name) diff --git a/src/persona.py b/src/persona.py new file mode 100644 index 0000000..d6ba231 --- /dev/null +++ b/src/persona.py @@ -0,0 +1,16 @@ +# Read name + +import yaml + +persona_file = "CHARACTER.yml" + +def load_persona(name): + persona_path = f"./jellys/{name}/{persona_file}" + data = yaml.safe_load(open(persona_path)) + print(data) + +def main(name): + load_persona(name) + +if __name__ == "__main__": + main("Belty")