1) Improve aios_shell experience, 2) Add 2 formula build-in agents
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
instance_id = "Jarvis"
|
||||||
|
fullname = "Jarvis"
|
||||||
|
|
||||||
|
[[prompt]]
|
||||||
|
role = "system"
|
||||||
|
content = "你是我的私人英文老师,和我用地道的美式英语进行交流。你会在和我交流的同时,调整我的输入成为更地道的美式句子,并根据你对我英文水平的预测,对可能发错英的单词标上音标。如果我给你发中文,说明我不知道这句话用美式英语怎么说,你依旧按上述规则回应我。"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
instance_id = "Tracy Wang"
|
||||||
|
fullname = "Tracy Wang"
|
||||||
|
|
||||||
|
[[prompt]]
|
||||||
|
role = "system"
|
||||||
|
content = "你是我的私人英文老师,和我用地道的美式英语进行交流。你会在和我交流的同时,调整我的输入成为更地道的美式句子,并根据你对我英文水平的预测,对可能发错英的单词标上音标。如果我给你发中文,说明我不知道这句话用美式英语怎么说,你依旧按上述规则回应我。"
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
TODO:
|
|
||||||
Embading Pipline
|
|
||||||
Knowlege-Base
|
|
||||||
@@ -84,7 +84,7 @@ class UserConfig:
|
|||||||
if config_item.value is None:
|
if config_item.value is None:
|
||||||
return config_item.default_value
|
return config_item.default_value
|
||||||
|
|
||||||
return config_item.value
|
return config_item.value,config_item
|
||||||
|
|
||||||
def set_user_config(self,key:str,value:Any) -> None:
|
def set_user_config(self,key:str,value:Any) -> None:
|
||||||
config_item = self.config_table.get(key)
|
config_item = self.config_table.get(key)
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ Requests==2.31.0
|
|||||||
stability_sdk
|
stability_sdk
|
||||||
toml==0.10.2
|
toml==0.10.2
|
||||||
|
|
||||||
|
google-cloud-texttospeech
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import toml
|
import toml
|
||||||
|
import shlex
|
||||||
|
|
||||||
from typing import Any, Optional, TypeVar, Tuple, Sequence
|
from typing import Any, Optional, TypeVar, Tuple, Sequence
|
||||||
import argparse
|
import argparse
|
||||||
@@ -141,6 +142,20 @@ class AIOS_Shell:
|
|||||||
show_text = FormattedText([("class:title", f"{self.current_topic}@{self.current_target} >>> "),
|
show_text = FormattedText([("class:title", f"{self.current_topic}@{self.current_target} >>> "),
|
||||||
("class:content", resp)])
|
("class:content", resp)])
|
||||||
return show_text
|
return show_text
|
||||||
|
case 'set_config':
|
||||||
|
show_text = FormattedText([("class:title", f"set config failed!")])
|
||||||
|
if len(args) == 1:
|
||||||
|
key = args[0]
|
||||||
|
old_value,config_item = AIStorage.get_instance().get_user_config().get_user_config(key)
|
||||||
|
if config_item is not None:
|
||||||
|
value = await session.prompt_async(f"{key} : {config_item.desc} \nCurrent : {old_value}\nPlease input new value:",style=shell_style)
|
||||||
|
AIStorage.get_instance().get_user_config().set_user_config(key,value)
|
||||||
|
await AIStorage.get_instance().get_user_config().save_value_to_user_config()
|
||||||
|
show_text = FormattedText([("class:title", f"set {key} to {value} success!")])
|
||||||
|
|
||||||
|
return show_text
|
||||||
|
|
||||||
|
|
||||||
case 'open':
|
case 'open':
|
||||||
if len(args) >= 1:
|
if len(args) >= 1:
|
||||||
target_id = args[0]
|
target_id = args[0]
|
||||||
@@ -190,18 +205,15 @@ history = FileHistory('aios_shell_history.txt')
|
|||||||
session = PromptSession(history=history)
|
session = PromptSession(history=history)
|
||||||
|
|
||||||
def parse_function_call(func_string):
|
def parse_function_call(func_string):
|
||||||
match = re.search(r'\s*(\w+)\s*\(\s*(.*)\s*\)\s*', func_string)
|
if len(func_string) > 2:
|
||||||
if not match:
|
if func_string[0] == '/' and func_string[1] != '/':
|
||||||
|
str_list = shlex.split(func_string[1:])
|
||||||
|
func_name = str_list[0]
|
||||||
|
params = str_list[1:]
|
||||||
|
return func_name, params
|
||||||
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
func_name = match.group(1)
|
|
||||||
params_string = match.group(2).strip()
|
|
||||||
params = re.split(r'\s*,\s*(?=(?:[^"]*"[^"]*")*[^"]*$)', params_string)
|
|
||||||
params = [param.strip('"') for param in params]
|
|
||||||
if len(params[0]) == 0:
|
|
||||||
params = None
|
|
||||||
|
|
||||||
return func_name, params
|
|
||||||
|
|
||||||
async def get_user_config_from_input(check_result:dict) -> bool:
|
async def get_user_config_from_input(check_result:dict) -> bool:
|
||||||
for key,item in check_result.items():
|
for key,item in check_result.items():
|
||||||
@@ -233,6 +245,7 @@ def print_welcome_screen():
|
|||||||
print("\033[0m")
|
print("\033[0m")
|
||||||
|
|
||||||
print("\033[1;32m \t\tWelcome to OpenDAN - Your Personal AI OS\033[0m\n")
|
print("\033[1;32m \t\tWelcome to OpenDAN - Your Personal AI OS\033[0m\n")
|
||||||
|
|
||||||
introduce = """
|
introduce = """
|
||||||
\tThe core goal of version 0.5.1 is to turn the concept of AIOS into code and get it up and running as quickly as possible.
|
\tThe core goal of version 0.5.1 is to turn the concept of AIOS into code and get it up and running as quickly as possible.
|
||||||
\tAfter three weeks of development, our plans have undergone some changes based on the actual progress of the system.
|
\tAfter three weeks of development, our plans have undergone some changes based on the actual progress of the system.
|
||||||
@@ -253,7 +266,7 @@ def print_welcome_screen():
|
|||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
print_welcome_screen()
|
print_welcome_screen()
|
||||||
print("OpenDAN is booting...")
|
print("Booting...")
|
||||||
logging.basicConfig(filename="aios_shell.log",filemode="w",encoding='utf-8',force=True,
|
logging.basicConfig(filename="aios_shell.log",filemode="w",encoding='utf-8',force=True,
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format='[%(asctime)s]%(name)s[%(levelname)s]: %(message)s')
|
format='[%(asctime)s]%(name)s[%(levelname)s]: %(message)s')
|
||||||
@@ -294,14 +307,16 @@ async def main():
|
|||||||
return await main_daemon_loop(shell)
|
return await main_daemon_loop(shell)
|
||||||
|
|
||||||
#TODO: read last input config
|
#TODO: read last input config
|
||||||
completer = WordCompleter(['send($target,$msg,$topic)',
|
completer = WordCompleter(['/send $target $msg $topic',
|
||||||
'open($target,$topic)',
|
'/open $target $topic',
|
||||||
'history($num,$offset)',
|
'/history $num $offset',
|
||||||
'login($username)',
|
'/login $username',
|
||||||
'connect($target)',
|
'/connect $target',
|
||||||
'show()',
|
'/set_config $key',
|
||||||
'exit()',
|
'/list_config',
|
||||||
'help()'], ignore_case=True)
|
'/show',
|
||||||
|
'/exit',
|
||||||
|
'/help'], ignore_case=True)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
user_input = await session.prompt_async(f"{shell.username}<->{shell.current_topic}@{shell.current_target}$",completer=completer,style=shell_style)
|
user_input = await session.prompt_async(f"{shell.username}<->{shell.current_topic}@{shell.current_target}$",completer=completer,style=shell_style)
|
||||||
|
|||||||
Reference in New Issue
Block a user