add default knowledge source dir

This commit is contained in:
tsukasa
2023-09-28 16:48:07 +08:00
parent 56c0202552
commit ff4875dae5
2 changed files with 9 additions and 3 deletions
+6
View File
@@ -267,6 +267,7 @@ class KnowledgeEmailSource:
class KnowledgeDirSource:
def __init__(self, config):
self.config = config
config["path"] = os.path.abspath(config["path"])
self.config["type"] = "dir"
@classmethod
@@ -342,6 +343,11 @@ class KnowledgePipline:
self.add_email_source(KnowledgeEmailSource(source_config))
if source_config['type'] == 'dir':
self.add_dir_source(KnowledgeDirSource(source_config))
user_data_dir = AIStorage.get_instance().get_myai_dir()
default_dir = os.path.abspath(f"{user_data_dir}/data")
if not os.path.exists(default_dir):
os.makedirs(default_dir)
self.add_dir_source(KnowledgeDirSource({"path": default_dir}))
return True
+3 -3
View File
@@ -319,7 +319,7 @@ class AIOS_Shell:
async def handle_knowledge_commands(self, args):
show_text = FormattedText([("class:title", "sub command not support!\n"
"/knowledge add email | dir\n"
"/knowledge add dir\n"
"/knowledge journal [$topn]\n")])
if len(args) < 1:
return show_text
@@ -585,7 +585,7 @@ def print_welcome_screen():
\033[1;94m\tGive your Agent a Telegram account :\033[0m /connect $agent_name
\033[1;94m\tAdd personal files to the AI Knowledge Base. \033[0m
\t\t1) Copy your file to ~/myai/data
\t\t2) /knowlege add dir
\t\t2) /knowledge add dir
\033[1;94m\tSearch your knowledge base :\033[0m /open Mia
\033[1;94m\tCheck the progress of AI reading personal data :\033[0m /knowledge journal
\033[1;94m\tOpen AI Bash (For Developer Only):\033[0m /open ai_bash
@@ -665,7 +665,7 @@ async def main():
'/history $num $offset',
'/connect $target',
'/contact $name',
'/knowledge add email | dir',
'/knowledge add dir',
'/knowledge journal [$topn]',
'/set_config $key',
'/enable $feature',