|
1 |
| -import os |
2 | 1 | import sys
|
3 | 2 |
|
4 | 3 | import rich
|
5 | 4 | import typer
|
6 |
| -from rich.console import Console |
7 | 5 | from yt_dlp.cookies import SUPPORTED_BROWSERS
|
8 | 6 |
|
9 | 7 | from aishell.adapters.openai_cookie_adapter import OpenAICookieAdapter
|
10 | 8 | from aishell.models import RevChatGPTChatbotConfigModel
|
11 | 9 | from aishell.models.aishell_config_model import AiShellConfigModel
|
12 |
| -from aishell.models.language_model import LanguageModel |
13 |
| -from aishell.query_clients import GPT3Client, OfficialChatGPTClient, QueryClient, ReverseEngineeredChatGPTClient |
14 | 10 | from aishell.utils import AiShellConfigManager
|
15 | 11 |
|
16 |
| -cli_app = typer.Typer() |
17 |
| - |
18 | 12 |
|
19 | 13 | def config_aishell():
|
20 | 14 | rich.print('''Hi! 🙌 I am [bold blue]AiShell[/bold blue], [yellow]your powerful terminal assistant[/yellow] 🔥
|
@@ -54,41 +48,3 @@ def config_aishell():
|
54 | 48 |
|
55 | 49 | ''')
|
56 | 50 | return config_manager
|
57 |
| - |
58 |
| - |
59 |
| -@cli_app.command() |
60 |
| -def ask(question: str, language_model: LanguageModel = LanguageModel.REVERSE_ENGINEERED_CHATGPT): |
61 |
| - is_config_file_available = AiShellConfigManager.is_config_file_available(AiShellConfigManager.DEFAULT_CONFIG_PATH) |
62 |
| - config_manager: AiShellConfigManager |
63 |
| - if is_config_file_available: |
64 |
| - config_manager = AiShellConfigManager(load_config=True) |
65 |
| - else: |
66 |
| - config_manager = config_aishell() |
67 |
| - config_manager.config_model.language_model = language_model |
68 |
| - configured_language_model = config_manager.config_model.language_model |
69 |
| - |
70 |
| - query_client: QueryClient |
71 |
| - if configured_language_model == LanguageModel.REVERSE_ENGINEERED_CHATGPT: |
72 |
| - query_client = ReverseEngineeredChatGPTClient(config=config_manager.config_model.chatgpt_config) |
73 |
| - elif configured_language_model == LanguageModel.GPT3: |
74 |
| - query_client = GPT3Client() |
75 |
| - elif configured_language_model == LanguageModel.OFFICIAL_CHATGPT: |
76 |
| - query_client = OfficialChatGPTClient() |
77 |
| - else: |
78 |
| - raise NotImplementedError(f'Language model {configured_language_model} is not implemented yet.') |
79 |
| - |
80 |
| - query_client.query(question) |
81 |
| - |
82 |
| - console = Console() |
83 |
| - with console.status( |
84 |
| - f''' |
85 |
| -[green] AiShell is thinking of `{question}` ...[/green] |
86 |
| -
|
87 |
| -[dim]AiShell is not responsible for any damage caused by the command executed by the user.[/dim]'''.strip(), ): |
88 |
| - response = query_client.query(question) |
89 |
| - console.print(f'AiShell: {response}\n') |
90 |
| - |
91 |
| - will_execute = typer.confirm('Execute this command?') |
92 |
| - |
93 |
| - if will_execute: |
94 |
| - os.system(response) |
0 commit comments