11
11
12
12
13
13
def config_aishell ():
14
- rich .print ('''Hi! 🙌 I am [bold blue]AiShell[/bold blue], [yellow]your powerful terminal assistant[/yellow] 🔥
14
+ rich .print ('''
15
+ Hi! 🙌 I am [bold blue]AiShell[/bold blue], [yellow]your powerful terminal assistant[/yellow] 🔥
15
16
I am here to assist you with configuring AiShell. 💪
16
17
17
18
Please make sure that you have logged into chat.openai.com on your browser before we continue. 🗝️
18
19
19
- ''' )
20
+ ''' [ 1 :] )
20
21
typer .confirm ('Are you ready to proceed? 🚀' , abort = True )
21
22
22
- rich .print (f'''Which browser did you use to log in to chat.openai.com?
23
+ rich .print (f'''
24
+ Which browser did you use to log in to chat.openai.com?
23
25
24
- We support the following browsers: [{ SUPPORTED_BROWSERS } ]''' )
26
+ We support the following browsers: [{ SUPPORTED_BROWSERS } ]''' [ 1 :] )
25
27
browser_name = typer .prompt ('Please enter your choice here: ' )
26
28
if browser_name not in SUPPORTED_BROWSERS :
27
29
rich .print (f'Browser { browser_name } is not supported. Supported browsers are: { SUPPORTED_BROWSERS } ' )
@@ -33,18 +35,33 @@ def config_aishell():
33
35
rich .print ('Failed to get session token. 😓 Can you check if you are logged in to https://chat.openai.com?' )
34
36
sys .exit (1 )
35
37
36
- is_paid = typer . confirm ( "It's my last question! 🤩 Are you a PLUS user?" )
38
+ config_manager = save_config ( session_token )
37
39
38
- chatgpt_config = RevChatGPTChatbotConfigModel (session_token = session_token , paid = is_paid )
39
- aishell_config = AiShellConfigModel (chatgpt_config = chatgpt_config )
40
- config_manager = AiShellConfigManager (config_model = aishell_config )
41
- config_manager .save_config ()
42
-
43
- rich .print (f'''[green bold]Excellent![/green bold] You are now ready to use [bold blue]AiShell[/bold blue] 🚀
40
+ rich .print (f'''
41
+ [green bold]Excellent![/green bold] You are now ready to use [bold blue]AiShell[/bold blue] 🚀
44
42
45
43
Enjoy your AI powered terminal assistant! 🎉
46
44
47
45
[dim]To check your settings file, it's at: { config_manager .config_path } [/dim]
48
46
49
- ''' )
47
+ ''' [1 :])
48
+ return config_manager
49
+
50
+
51
+ def save_config (session_token : str ):
52
+ is_config_file_available = AiShellConfigManager .is_config_file_available (AiShellConfigManager .DEFAULT_CONFIG_PATH )
53
+ if is_config_file_available :
54
+ config_manager = AiShellConfigManager (load_config = True )
55
+ is_chatgpt_config_available = config_manager .config_model .chatgpt_config is not None
56
+ if is_chatgpt_config_available :
57
+ assert config_manager .config_model .chatgpt_config # for type hinting
58
+ config_manager .config_model .chatgpt_config .session_token = session_token
59
+ else :
60
+ config_manager .config_model .chatgpt_config = RevChatGPTChatbotConfigModel (session_token = session_token )
61
+ else :
62
+ chatgpt_config = RevChatGPTChatbotConfigModel (session_token = session_token )
63
+ aishell_config = AiShellConfigModel (chatgpt_config = chatgpt_config )
64
+ config_manager = AiShellConfigManager (config_model = aishell_config )
65
+
66
+ config_manager .save_config ()
50
67
return config_manager
0 commit comments