Skip to content

Commit 565ba5f

Browse files
committed
change python mode
1 parent 4edfbad commit 565ba5f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

aipyapp/aipy/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def check_llm(self):
6363
def _init_llm(self):
6464
print(
6565
"""当前环境缺少配置文件,请注册一个trustoken账号,可以使用免费赠送的API账号。
66-
浏览器打开https://api.trustoken.ai/register , 进行账号注册。
66+
浏览器打开 https://api.trustoken.ai/register , 进行账号注册。
6767
注册后进行登录,访问页面顶部的“令牌”页面,或者点击这个地址:https://api.trustoken.ai/token
6868
点击“复制”按钮,复制令牌到剪贴板。
6969
在此执行粘贴。"""
@@ -84,6 +84,9 @@ def _init_llm(self):
8484
continue
8585

8686
self.save_trustoken(user_token)
87+
88+
# reload config
89+
self.config = self._load_config()
8790
break
8891

8992
def save_trustoken(self, token):
@@ -98,8 +101,6 @@ def save_trustoken(self, token):
98101
f.write('model = "deepseek/deepseek-chat-v3-0324"\n')
99102
f.write("default = true\n")
100103
print(f"令牌已保存到 {config_file}")
101-
print("请重新运行程序以加载新的配置。")
102-
sys.exit(0)
103104
except Exception as e:
104105
print(f"保存令牌时出错: {e}")
105106

aipyapp/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from .aipy import Agent
2121
from .aipy.i18n import T
22+
from .aipy.config import ConfigManager
2223

2324
__PACKAGE_NAME__ = "aipyapp"
2425

@@ -38,7 +39,9 @@ def main(args):
3839
console.print("[bold cyan]🚀 Python use - AIPython ([red]Python mode, Quit with 'exit()'[/red])")
3940

4041
path = args.config if args.config else 'aipython.toml'
41-
settings = Dynaconf(settings_files=[get_default_config(), path], envvar_prefix="AIPY", merge_enabled=True)
42+
conf = ConfigManager(get_default_config(), path)
43+
conf.check_config()
44+
settings = conf.get_config()
4245
try:
4346
ai = Agent(settings, console=console)
4447
except Exception as e:

0 commit comments

Comments
 (0)