-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (29 loc) · 999 Bytes
/
app.py
File metadata and controls
39 lines (29 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
from core import CodeExplainer, LLMService, PromptManager, FileManager
from enums.models import OllamaModel
import questionary # type: ignore
def model_switcher() -> OllamaModel:
escolhas = [model.value for model in OllamaModel]
resposta = questionary.select(
"🧠 Selecione o modelo desejado:",
choices=escolhas
).ask()
for model in OllamaModel:
if model.value == resposta:
return model
return OllamaModel.CODELLAMA_LATEST
def app():
if len(sys.argv) != 2:
print("Uso: python main.py <arquivo>")
sys.exit(1)
file_path = sys.argv[1]
code = FileManager.read_file(file_path)
modelo_escolhido = model_switcher()
print(f"\n✅ Modelo selecionado: {modelo_escolhido.value}\n")
explainer = CodeExplainer(
llm_service=LLMService(model_name=modelo_escolhido.value),
prompt_manager=PromptManager()
)
explainer.explain_code(code)
if __name__ == "__main__":
app()