flai-ia 0.1.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flai_ia-0.1.11/LICENSE +7 -0
- flai_ia-0.1.11/PKG-INFO +83 -0
- flai_ia-0.1.11/README.md +58 -0
- flai_ia-0.1.11/flai/cli/__init__.py +12 -0
- flai_ia-0.1.11/flai/cli/cli.py +120 -0
- flai_ia-0.1.11/flai/cli/commands/__init__.py +0 -0
- flai_ia-0.1.11/flai/cli/commands/init.py +74 -0
- flai_ia-0.1.11/flai/cli/commands/shell.py +58 -0
- flai_ia-0.1.11/flai/cli/console/__init__.py +46 -0
- flai_ia-0.1.11/flai/cli/console/console.py +126 -0
- flai_ia-0.1.11/flai/cli/console/theme.py +41 -0
- flai_ia-0.1.11/flai/cli/utils/checklist.py +44 -0
- flai_ia-0.1.11/flai/cli/utils/context.py +29 -0
- flai_ia-0.1.11/flai/cli/utils/fs.py +5 -0
- flai_ia-0.1.11/flai/cli/utils/models.py +34 -0
- flai_ia-0.1.11/flai/cli/utils/ollama.py +63 -0
- flai_ia-0.1.11/flai/cli/utils/scanner.py +47 -0
- flai_ia-0.1.11/flai/cli/utils/system.py +17 -0
- flai_ia-0.1.11/pyproject.toml +70 -0
flai_ia-0.1.11/LICENSE
ADDED
flai_ia-0.1.11/PKG-INFO
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flai-ia
|
|
3
|
+
Version: 0.1.11
|
|
4
|
+
Summary: Flai - Framework local para ia
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: ia local,localhost ia,framework de ia local,pip install flai,flai,flet,ollama,llm local,framework,mvc,ui,desktop,mobile,apk,app,android
|
|
8
|
+
Author: Alex Yucra
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Dist: fleting
|
|
15
|
+
Requires-Dist: langchain
|
|
16
|
+
Requires-Dist: psutil
|
|
17
|
+
Requires-Dist: rich
|
|
18
|
+
Requires-Dist: typer
|
|
19
|
+
Project-URL: Documentation, https://github.com/alexyucra/flai/tree/main/docs
|
|
20
|
+
Project-URL: Homepage, https://github.com/alexyucra/flai
|
|
21
|
+
Project-URL: Issues, https://github.com/alexyucra/flai/issues
|
|
22
|
+
Project-URL: Repository, https://github.com/alexyucra/flai
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# FLAI - Framework Local de AI
|
|
26
|
+
|
|
27
|
+
> Sua InteligΓͺncia Artificial Privada para Desenvolvimento de Software
|
|
28
|
+
|
|
29
|
+
## π IntroduΓ§Γ£o
|
|
30
|
+
FLAI (Framework Local de AI) Γ© uma soluΓ§Γ£o revolucionΓ‘ria que traz o poder da inteligΓͺncia artificial diretamente para sua mΓ‘quina local, eliminando a dependΓͺncia de APIs externas e garantindo privacidade total. Desenvolvido especificamente para projetos Fleting (Python + Flet), o FLAI transforma a maneira como vocΓͺ desenvolve, analisa e refatora cΓ³digo.
|
|
31
|
+
|
|
32
|
+
### Por que FLAI?
|
|
33
|
+
|
|
34
|
+
- π 100% Privado: Seus cΓ³digos nunca saem da sua mΓ‘quina
|
|
35
|
+
- β‘ Sem LatΓͺncia: ExecuΓ§Γ£o local elimina delays de rede
|
|
36
|
+
- π° Zero Custos: Nenhuma assinatura ou crΓ©ditos necessΓ‘rios
|
|
37
|
+
- π Offline: Funciona mesmo sem internet
|
|
38
|
+
|
|
39
|
+
## ποΈ Arquitetura TΓ©cnica
|
|
40
|
+
VisΓ£o Geral do Sistema
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
44
|
+
β FLAI Architecture β
|
|
45
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
46
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
47
|
+
β β User βββββΊβ FLAI β β
|
|
48
|
+
β β Interface β β Shell β β
|
|
49
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
50
|
+
β β β β
|
|
51
|
+
β βΌ βΌ β
|
|
52
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
53
|
+
β β Fleting β β Ollama β β
|
|
54
|
+
β β Project β β Manager β β
|
|
55
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
56
|
+
β β β β
|
|
57
|
+
β βββββββββββββββββββββΌββββββββββββββββ
|
|
58
|
+
β βΌ β
|
|
59
|
+
β ββββββββββββββ β
|
|
60
|
+
β β Local β β
|
|
61
|
+
β β LLM β β
|
|
62
|
+
β β ( ) β β
|
|
63
|
+
β ββββββββββββββ β
|
|
64
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Componentes Principais
|
|
68
|
+
1. Ollama Manager
|
|
69
|
+
```py
|
|
70
|
+
class OllamaManager:
|
|
71
|
+
"""
|
|
72
|
+
Gerenciador inteligente que detecta e executa Ollama automaticamente
|
|
73
|
+
Funciona sem necessidade de configurar PATH do sistema
|
|
74
|
+
"""
|
|
75
|
+
- find_ollama(): Busca em mΓΊltiplos locais do sistema
|
|
76
|
+
- start_server(): Inicia servidor em background
|
|
77
|
+
- run_model(): Executa modelos via API local
|
|
78
|
+
- ensure_ready(): Prepara tudo automaticamente
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
flai_ia-0.1.11/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# FLAI - Framework Local de AI
|
|
2
|
+
|
|
3
|
+
> Sua InteligΓͺncia Artificial Privada para Desenvolvimento de Software
|
|
4
|
+
|
|
5
|
+
## π IntroduΓ§Γ£o
|
|
6
|
+
FLAI (Framework Local de AI) Γ© uma soluΓ§Γ£o revolucionΓ‘ria que traz o poder da inteligΓͺncia artificial diretamente para sua mΓ‘quina local, eliminando a dependΓͺncia de APIs externas e garantindo privacidade total. Desenvolvido especificamente para projetos Fleting (Python + Flet), o FLAI transforma a maneira como vocΓͺ desenvolve, analisa e refatora cΓ³digo.
|
|
7
|
+
|
|
8
|
+
### Por que FLAI?
|
|
9
|
+
|
|
10
|
+
- π 100% Privado: Seus cΓ³digos nunca saem da sua mΓ‘quina
|
|
11
|
+
- β‘ Sem LatΓͺncia: ExecuΓ§Γ£o local elimina delays de rede
|
|
12
|
+
- π° Zero Custos: Nenhuma assinatura ou crΓ©ditos necessΓ‘rios
|
|
13
|
+
- π Offline: Funciona mesmo sem internet
|
|
14
|
+
|
|
15
|
+
## ποΈ Arquitetura TΓ©cnica
|
|
16
|
+
VisΓ£o Geral do Sistema
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
20
|
+
β FLAI Architecture β
|
|
21
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
22
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
23
|
+
β β User βββββΊβ FLAI β β
|
|
24
|
+
β β Interface β β Shell β β
|
|
25
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
26
|
+
β β β β
|
|
27
|
+
β βΌ βΌ β
|
|
28
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
29
|
+
β β Fleting β β Ollama β β
|
|
30
|
+
β β Project β β Manager β β
|
|
31
|
+
β ββββββββββββββ ββββββββββββββ β
|
|
32
|
+
β β β β
|
|
33
|
+
β βββββββββββββββββββββΌββββββββββββββββ
|
|
34
|
+
β βΌ β
|
|
35
|
+
β ββββββββββββββ β
|
|
36
|
+
β β Local β β
|
|
37
|
+
β β LLM β β
|
|
38
|
+
β β ( ) β β
|
|
39
|
+
β ββββββββββββββ β
|
|
40
|
+
βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Componentes Principais
|
|
44
|
+
1. Ollama Manager
|
|
45
|
+
```py
|
|
46
|
+
class OllamaManager:
|
|
47
|
+
"""
|
|
48
|
+
Gerenciador inteligente que detecta e executa Ollama automaticamente
|
|
49
|
+
Funciona sem necessidade de configurar PATH do sistema
|
|
50
|
+
"""
|
|
51
|
+
- find_ollama(): Busca em mΓΊltiplos locais do sistema
|
|
52
|
+
- start_server(): Inicia servidor em background
|
|
53
|
+
- run_model(): Executa modelos via API local
|
|
54
|
+
- ensure_ready(): Prepara tudo automaticamente
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# flai/cli/__init__.py
|
|
2
|
+
"""
|
|
3
|
+
FLAI - Framework Local de AI
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
__author__ = "Alex Yucra"
|
|
8
|
+
|
|
9
|
+
# Exportar funΓ§Γ΅es principais
|
|
10
|
+
# from flai.cli.utils2.ollama_manager import run_ollama, get_ollama_manager
|
|
11
|
+
|
|
12
|
+
# __all__ = ['run_ollama', 'get_ollama_manager']
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import typer
|
|
3
|
+
import click
|
|
4
|
+
from flai.cli.commands.init import handle_init
|
|
5
|
+
from flai.cli.commands.shell import handle_shell
|
|
6
|
+
# from flai.cli.commands.init2 import handle_init
|
|
7
|
+
# from flai.cli.commands.shell2 import handle_shell
|
|
8
|
+
from flai.cli.console.console import console
|
|
9
|
+
from flai.cli.console import Table, Panel, Text, box, Rule
|
|
10
|
+
import traceback
|
|
11
|
+
|
|
12
|
+
def print_help():
|
|
13
|
+
console.clear()
|
|
14
|
+
|
|
15
|
+
console.print()
|
|
16
|
+
console.rule("[bold cyan]π Flai CLI[/bold cyan]", style="cyan")
|
|
17
|
+
console.print()
|
|
18
|
+
|
|
19
|
+
console.print(Panel.fit(
|
|
20
|
+
"[bold green]flai <command> [options][/bold green]",
|
|
21
|
+
title="[yellow]π Usage[/yellow]",
|
|
22
|
+
border_style="yellow",
|
|
23
|
+
padding=(1, 2)
|
|
24
|
+
))
|
|
25
|
+
console.print()
|
|
26
|
+
|
|
27
|
+
table = Table(
|
|
28
|
+
show_header=True,
|
|
29
|
+
header_style="bold magenta",
|
|
30
|
+
box=box.ROUNDED,
|
|
31
|
+
border_style="blue",
|
|
32
|
+
padding=(0, 1)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
table.add_column("Command", style="bold green", width=36)
|
|
36
|
+
table.add_column("Description", style="cyan", width=44)
|
|
37
|
+
|
|
38
|
+
# Comandos organizados por categorΓas
|
|
39
|
+
categories = {
|
|
40
|
+
"πΌ Project Commands": [
|
|
41
|
+
("flai init ia", "Setup local AI environment"),
|
|
42
|
+
("flai shell", "Interactive AI shell")
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for category, commands in categories.items():
|
|
47
|
+
# AΓ±adir separador para categorΓas
|
|
48
|
+
if list(categories.keys()).index(category) > 0:
|
|
49
|
+
table.add_row("β" * 36, "β" * 44, style="dim")
|
|
50
|
+
|
|
51
|
+
# AΓ±adir tΓtulo de categorΓa
|
|
52
|
+
table.add_row(
|
|
53
|
+
f"[bold yellow]{category}[/bold yellow]",
|
|
54
|
+
"",
|
|
55
|
+
style="yellow"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# AΓ±adir comandos de la categorΓa
|
|
59
|
+
for cmd, desc in commands:
|
|
60
|
+
table.add_row(f" {cmd}", desc)
|
|
61
|
+
|
|
62
|
+
console.print(table)
|
|
63
|
+
console.print()
|
|
64
|
+
|
|
65
|
+
def show_banner():
|
|
66
|
+
console.print(
|
|
67
|
+
Panel(
|
|
68
|
+
"π [bold cyan]Flai - Framework local de IA[/bold cyan]\n\n"
|
|
69
|
+
"Este projeto Γ© [bold green]opensource[/bold green].\n"
|
|
70
|
+
"VocΓͺ estΓ‘ entre os primeiros usuΓ‘rios.\n"
|
|
71
|
+
"[bold red]Mais VersΓ΅es serΓ£o liberadas[/bold red].\n"
|
|
72
|
+
"[bold yellow]somente apΓ³s 1000 e 2000 inscritos.[/bold yellow].\n\n"
|
|
73
|
+
"π https://www.youtube.com/@LatinDev\n"
|
|
74
|
+
"curso fleting completo: https://youtu.be/sm3jWfd1ceU?si=8xCUIRfYGWkKym7X\n",
|
|
75
|
+
title="Flai",
|
|
76
|
+
border_style="cyan"
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def show_footer():
|
|
81
|
+
console.print(
|
|
82
|
+
Panel(
|
|
83
|
+
"π‘ Curtiu o Flai?\n"
|
|
84
|
+
"Ajude a liberar novas features π\n\n"
|
|
85
|
+
"[bold yellow]Meta: 2000 inscritos[/bold yellow]\n"
|
|
86
|
+
"π https://www.youtube.com/@LatinDev\n",
|
|
87
|
+
border_style="green"
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def main():
|
|
92
|
+
show_banner()
|
|
93
|
+
if len(sys.argv) < 2:
|
|
94
|
+
print_help()
|
|
95
|
+
return
|
|
96
|
+
args = sys.argv[1:]
|
|
97
|
+
|
|
98
|
+
if not args or args[0] in ("-h", "--help"):
|
|
99
|
+
print_help()
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
cmd = args[0]
|
|
103
|
+
subargs = args[1:]
|
|
104
|
+
try:
|
|
105
|
+
if cmd == "init":
|
|
106
|
+
handle_init(subargs)
|
|
107
|
+
elif cmd == "shell":
|
|
108
|
+
handle_shell()
|
|
109
|
+
else:
|
|
110
|
+
print(f"Unknown command: {cmd}")
|
|
111
|
+
except (typer.Exit, click.exceptions.Exit):
|
|
112
|
+
raise
|
|
113
|
+
except Exception as e:
|
|
114
|
+
print("Error executing CLI command:", str(e))
|
|
115
|
+
traceback.print_exc()
|
|
116
|
+
finally:
|
|
117
|
+
show_footer()
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from flai.cli.console.console import console
|
|
5
|
+
from flai.cli.utils.system import analyze_system
|
|
6
|
+
from flai.cli.utils.models import get_laptop_models
|
|
7
|
+
from flai.cli.utils.ollama import install_ollama, pull_model
|
|
8
|
+
from rich.table import Table
|
|
9
|
+
# from flai.core.project import get_project_root
|
|
10
|
+
|
|
11
|
+
app = typer.Typer()
|
|
12
|
+
DEFAULT_PROJECT_NAME = "app"
|
|
13
|
+
|
|
14
|
+
def handle_init(args):
|
|
15
|
+
"""
|
|
16
|
+
Inicializa IA local (LangChain + Ollama) para o projeto Fleting
|
|
17
|
+
"""
|
|
18
|
+
cwd = Path.cwd()
|
|
19
|
+
project_root = cwd / DEFAULT_PROJECT_NAME
|
|
20
|
+
if not project_root:
|
|
21
|
+
console.print("[error]Projeto Fleting nΓ£o encontrado[/error]")
|
|
22
|
+
raise typer.Exit(1)
|
|
23
|
+
|
|
24
|
+
console.print("[bold cyan]Inicializando FLAI (IA Local)[/bold cyan]\n")
|
|
25
|
+
|
|
26
|
+
# 1. Analisar sistema
|
|
27
|
+
system_info = analyze_system()
|
|
28
|
+
|
|
29
|
+
# 2. Mostrar checklist
|
|
30
|
+
console.print("[bold]Checklist do sistema:[/bold]")
|
|
31
|
+
for item, ok in system_info["checklist"].items():
|
|
32
|
+
icon = "β
" if ok else "β"
|
|
33
|
+
console.print(f"{icon} {item}")
|
|
34
|
+
|
|
35
|
+
if not system_info["checklist"]["RAM suficiente"]:
|
|
36
|
+
console.print("[warning]Pouca RAM detectada[/warning]")
|
|
37
|
+
|
|
38
|
+
# 3. Mostrar modelos disponΓveis
|
|
39
|
+
models = get_laptop_models(system_info)
|
|
40
|
+
|
|
41
|
+
table = Table(title="Modelos recomendados para seu laptop")
|
|
42
|
+
|
|
43
|
+
table.add_column("OpΓ§Γ£o", justify="center")
|
|
44
|
+
table.add_column("Modelo")
|
|
45
|
+
table.add_column("RAM mΓnima")
|
|
46
|
+
table.add_column("Uso")
|
|
47
|
+
|
|
48
|
+
for i, model in enumerate(models, start=1):
|
|
49
|
+
table.add_row(
|
|
50
|
+
str(i),
|
|
51
|
+
model["name"],
|
|
52
|
+
model["ram"],
|
|
53
|
+
model["description"]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
console.print(table)
|
|
57
|
+
|
|
58
|
+
# 4. Escolha do usuΓ‘rio
|
|
59
|
+
choice = typer.prompt(
|
|
60
|
+
"Escolha o modelo",
|
|
61
|
+
type=int
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
selected = models[choice - 1]
|
|
65
|
+
|
|
66
|
+
console.print(
|
|
67
|
+
f"[info]Instalando modelo {selected['name']}...[/info]"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# 5. Instalar Ollama + modelo
|
|
71
|
+
install_ollama()
|
|
72
|
+
pull_model(selected["ollama_id"])
|
|
73
|
+
|
|
74
|
+
console.print("[success]IA local instalada com sucesso![/success]")
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from flai.cli.console.console import console
|
|
5
|
+
from flai.cli.utils.scanner import scan_project
|
|
6
|
+
from flai.cli.utils.context import build_context_map
|
|
7
|
+
from flai.cli.utils.checklist import create_checklist
|
|
8
|
+
from flai.cli.utils.ollama import run_ollama
|
|
9
|
+
# from flai.core.project import get_project_root
|
|
10
|
+
|
|
11
|
+
DEFAULT_PROJECT_NAME = "app"
|
|
12
|
+
|
|
13
|
+
app = typer.Typer()
|
|
14
|
+
|
|
15
|
+
def handle_shell():
|
|
16
|
+
"""
|
|
17
|
+
Abre o FLAI Shell e analisa o projeto Fleting
|
|
18
|
+
"""
|
|
19
|
+
cwd = Path.cwd()
|
|
20
|
+
project_root = cwd / DEFAULT_PROJECT_NAME
|
|
21
|
+
|
|
22
|
+
if not project_root:
|
|
23
|
+
console.print("[error]No Fleting projects found.[/error]")
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
console.print("[bold cyan]FLAI Shell iniciado[/bold cyan]")
|
|
27
|
+
|
|
28
|
+
# 1. Scan
|
|
29
|
+
scan = scan_project(project_root)
|
|
30
|
+
|
|
31
|
+
# 2. Context Map
|
|
32
|
+
context_map = build_context_map(scan)
|
|
33
|
+
|
|
34
|
+
# 3. Checklist
|
|
35
|
+
checklist_file = create_checklist(project_root)
|
|
36
|
+
|
|
37
|
+
console.print(f"[success]Checklist criado em {checklist_file}[/success]")
|
|
38
|
+
|
|
39
|
+
# 4. Prompt base
|
|
40
|
+
prompt = f"""
|
|
41
|
+
VocΓͺ Γ© um arquiteto de software especialista em Python e Flet.
|
|
42
|
+
|
|
43
|
+
Analise o seguinte projeto Fleting:
|
|
44
|
+
|
|
45
|
+
{context_map}
|
|
46
|
+
|
|
47
|
+
Gere sugestΓ΅es objetivas de melhoria,
|
|
48
|
+
sem reescrever cΓ³digo.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
console.print("[info]Analisando projeto com IA...[/info]")
|
|
52
|
+
|
|
53
|
+
response = run_ollama("deepseek-coder:1.3b", prompt)
|
|
54
|
+
|
|
55
|
+
console.print("\n[bold]SugestΓ΅es iniciais:[/bold]\n")
|
|
56
|
+
console.print(response)
|
|
57
|
+
|
|
58
|
+
console.print("\nDigite 'exit' para sair")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# cli/console/__init__.py
|
|
2
|
+
from .console import (
|
|
3
|
+
console,
|
|
4
|
+
Console,
|
|
5
|
+
Table,
|
|
6
|
+
Panel,
|
|
7
|
+
Columns,
|
|
8
|
+
Text,
|
|
9
|
+
box,
|
|
10
|
+
Rule,
|
|
11
|
+
Syntax,
|
|
12
|
+
Markdown,
|
|
13
|
+
Progress,
|
|
14
|
+
SpinnerColumn,
|
|
15
|
+
TextColumn,
|
|
16
|
+
Prompt,
|
|
17
|
+
Confirm,
|
|
18
|
+
Tree,
|
|
19
|
+
create_table,
|
|
20
|
+
print_pages_table,
|
|
21
|
+
print_routes_table,
|
|
22
|
+
print_simple_table,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
'console',
|
|
27
|
+
'Console',
|
|
28
|
+
'Table',
|
|
29
|
+
'Panel',
|
|
30
|
+
'Columns',
|
|
31
|
+
'Text',
|
|
32
|
+
'box',
|
|
33
|
+
'Rule',
|
|
34
|
+
'Syntax',
|
|
35
|
+
'Markdown',
|
|
36
|
+
'Progress',
|
|
37
|
+
'SpinnerColumn',
|
|
38
|
+
'TextColumn',
|
|
39
|
+
'Prompt',
|
|
40
|
+
'Confirm',
|
|
41
|
+
'Tree',
|
|
42
|
+
'create_table',
|
|
43
|
+
'print_pages_table',
|
|
44
|
+
'print_routes_table',
|
|
45
|
+
'print_simple_table',
|
|
46
|
+
]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# cli/console/console.py
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
from rich.table import Table
|
|
4
|
+
from rich.panel import Panel
|
|
5
|
+
from rich.columns import Columns
|
|
6
|
+
from rich.text import Text
|
|
7
|
+
from rich import box
|
|
8
|
+
from rich.rule import Rule
|
|
9
|
+
from rich.syntax import Syntax
|
|
10
|
+
from rich.markdown import Markdown
|
|
11
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
12
|
+
from rich.prompt import Prompt, Confirm
|
|
13
|
+
from rich.tree import Tree
|
|
14
|
+
from fleting.cli.console.themes import THEMES
|
|
15
|
+
|
|
16
|
+
console = Console(theme=THEMES)
|
|
17
|
+
|
|
18
|
+
def create_table(title: str = "", columns: list = None, min_width: int = 30) -> Table:
|
|
19
|
+
"""Create a table with Fleting stile"""
|
|
20
|
+
table = Table(
|
|
21
|
+
show_header=True,
|
|
22
|
+
header_style="bold cyan",
|
|
23
|
+
box=box.ROUNDED,
|
|
24
|
+
border_style="blue",
|
|
25
|
+
padding=(0, 1),
|
|
26
|
+
min_width=min_width,
|
|
27
|
+
expand=True
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if title:
|
|
31
|
+
table.title = f"[bold yellow]{title}[/bold yellow]"
|
|
32
|
+
|
|
33
|
+
if columns:
|
|
34
|
+
for col in columns:
|
|
35
|
+
if isinstance(col, tuple):
|
|
36
|
+
table.add_column(col[0], style=col[1], width=col[2] if len(col) > 2 else None)
|
|
37
|
+
else:
|
|
38
|
+
table.add_column(col, style="cyan")
|
|
39
|
+
|
|
40
|
+
return table
|
|
41
|
+
|
|
42
|
+
def print_simple_table(headers: list, rows: list, title: str = ""):
|
|
43
|
+
"""Print a simple table with styled rows"""
|
|
44
|
+
table = create_table(title, headers)
|
|
45
|
+
|
|
46
|
+
for row in rows:
|
|
47
|
+
styled_row = []
|
|
48
|
+
for cell in row:
|
|
49
|
+
cell_str = str(cell)
|
|
50
|
+
# Apply styles based on content
|
|
51
|
+
if cell_str in ["β", "β
", "β"]:
|
|
52
|
+
styled_cell = "[green]β[/green]"
|
|
53
|
+
elif cell_str in ["β", "β", "β"]:
|
|
54
|
+
styled_cell = "[dim]β[/dim]"
|
|
55
|
+
elif "bytes" in cell_str.lower():
|
|
56
|
+
styled_cell = f"[dim]{cell_str}[/dim]"
|
|
57
|
+
else:
|
|
58
|
+
styled_cell = f"[cyan]{cell_str}[/cyan]"
|
|
59
|
+
styled_row.append(styled_cell)
|
|
60
|
+
|
|
61
|
+
table.add_row(*styled_row)
|
|
62
|
+
|
|
63
|
+
console.print()
|
|
64
|
+
console.print(table)
|
|
65
|
+
console.print()
|
|
66
|
+
|
|
67
|
+
def print_pages_table(headers: list, rows: list):
|
|
68
|
+
"""print page tables with specific colors"""
|
|
69
|
+
table = create_table("π Pages Overview", headers, min_width=50)
|
|
70
|
+
|
|
71
|
+
for row in rows:
|
|
72
|
+
styled_row = []
|
|
73
|
+
for i, cell in enumerate(row):
|
|
74
|
+
if i == 0: # page name
|
|
75
|
+
styled_cell = f"[bold cyan]{cell}[/bold cyan]"
|
|
76
|
+
elif cell == "β":
|
|
77
|
+
styled_cell = "[green]β[/green]"
|
|
78
|
+
elif cell == "β":
|
|
79
|
+
styled_cell = "[dim red]β[/dim red]"
|
|
80
|
+
else:
|
|
81
|
+
styled_cell = f"[yellow]{cell}[/yellow]"
|
|
82
|
+
styled_row.append(styled_cell)
|
|
83
|
+
|
|
84
|
+
table.add_row(*styled_row)
|
|
85
|
+
|
|
86
|
+
console.print()
|
|
87
|
+
console.print(table)
|
|
88
|
+
console.print(f"[dim]Legend: [green]β[/green] = Present | [dim red]β[/dim red] = Missing[/dim]")
|
|
89
|
+
console.print()
|
|
90
|
+
|
|
91
|
+
def print_routes_table(headers: list, rows: list):
|
|
92
|
+
"""Print routes table with especial style"""
|
|
93
|
+
table = create_table("π£οΈ Routes", headers, min_width=40)
|
|
94
|
+
|
|
95
|
+
for row in rows:
|
|
96
|
+
styled_row = []
|
|
97
|
+
styled_row.append(f"[bold green]{row[0]}[/bold green]") # Route
|
|
98
|
+
styled_row.append(f"[cyan]{row[1]}[/cyan]") # View
|
|
99
|
+
table.add_row(*styled_row)
|
|
100
|
+
|
|
101
|
+
console.print()
|
|
102
|
+
console.print(table)
|
|
103
|
+
|
|
104
|
+
__all__ = [
|
|
105
|
+
'console',
|
|
106
|
+
'Console',
|
|
107
|
+
'Table',
|
|
108
|
+
'Panel',
|
|
109
|
+
'Columns',
|
|
110
|
+
'Text',
|
|
111
|
+
'box',
|
|
112
|
+
'Rule',
|
|
113
|
+
'Syntax',
|
|
114
|
+
'Markdown',
|
|
115
|
+
'Progress',
|
|
116
|
+
'SpinnerColumn',
|
|
117
|
+
'TextColumn',
|
|
118
|
+
'Prompt',
|
|
119
|
+
'Confirm',
|
|
120
|
+
'Tree',
|
|
121
|
+
'create_table',
|
|
122
|
+
'print_simple_table',
|
|
123
|
+
'print_pages_table',
|
|
124
|
+
'print_routes_table',
|
|
125
|
+
]
|
|
126
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from rich.theme import Theme
|
|
2
|
+
|
|
3
|
+
THEMES = Theme({
|
|
4
|
+
# Main states - matching current CLI emoji style
|
|
5
|
+
"success": "green1 bold",
|
|
6
|
+
"error": "red1 bold",
|
|
7
|
+
"warning": "yellow1 bold",
|
|
8
|
+
"info": "cyan bold",
|
|
9
|
+
|
|
10
|
+
# Soft variants
|
|
11
|
+
"success.dim": "green3",
|
|
12
|
+
"error.dim": "red3",
|
|
13
|
+
"warning.dim": "yellow3",
|
|
14
|
+
"info.dim": "cyan3",
|
|
15
|
+
|
|
16
|
+
# UX / hints
|
|
17
|
+
"suggestion": "magenta italic",
|
|
18
|
+
"hint": "bright_black italic",
|
|
19
|
+
"muted": "bright_black",
|
|
20
|
+
|
|
21
|
+
# Structure
|
|
22
|
+
"title": "bold white underline",
|
|
23
|
+
"subtitle": "bold white",
|
|
24
|
+
"label": "bold blue",
|
|
25
|
+
"value": "white",
|
|
26
|
+
|
|
27
|
+
# Debug / dev stuff
|
|
28
|
+
"debug": "dim cyan",
|
|
29
|
+
"trace": "dim bright_black",
|
|
30
|
+
|
|
31
|
+
# Fancy extras
|
|
32
|
+
"highlight": "black on yellow",
|
|
33
|
+
"important": "bold white on red",
|
|
34
|
+
|
|
35
|
+
# CLI specific themes
|
|
36
|
+
"command": "bold green",
|
|
37
|
+
"description": "white",
|
|
38
|
+
"header": "bold cyan",
|
|
39
|
+
"table.border": "blue",
|
|
40
|
+
"table.header": "bold blue"
|
|
41
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from flai.cli.utils.fs import write_utf8, read_utf8
|
|
3
|
+
|
|
4
|
+
CHECKLIST_TEMPLATE = """# Checklist do Projeto Fleting
|
|
5
|
+
|
|
6
|
+
## Estrutura
|
|
7
|
+
- [x] Pasta app encontrada
|
|
8
|
+
- [ ] MVC bem definido
|
|
9
|
+
- [ ] SeparaΓ§Γ£o clara entre UI e lΓ³gica
|
|
10
|
+
|
|
11
|
+
## Models
|
|
12
|
+
- [ ] Tipagem adequada
|
|
13
|
+
- [ ] ValidaΓ§Γ΅es de dados
|
|
14
|
+
- [ ] RepositΓ³rios isolados
|
|
15
|
+
|
|
16
|
+
## Controllers
|
|
17
|
+
- [ ] Controllers finos
|
|
18
|
+
- [ ] Tratamento de erros
|
|
19
|
+
- [ ] Sem lΓ³gica de UI
|
|
20
|
+
|
|
21
|
+
## Views (Flet)
|
|
22
|
+
- [ ] Componentes reutilizΓ‘veis
|
|
23
|
+
- [ ] Layouts organizados
|
|
24
|
+
|
|
25
|
+
## ConfiguraΓ§Γ΅es
|
|
26
|
+
- [ ] configs por ambiente
|
|
27
|
+
- [ ] Segredos fora do cΓ³digo
|
|
28
|
+
|
|
29
|
+
## PrΓ³ximos Passos
|
|
30
|
+
- [ ] Criar service layer
|
|
31
|
+
- [ ] Adicionar testes
|
|
32
|
+
- [ ] Automatizar migrations
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def create_checklist(project_root: Path):
|
|
36
|
+
checklist_dir = project_root / "checklist"
|
|
37
|
+
checklist_dir.mkdir(exist_ok=True)
|
|
38
|
+
|
|
39
|
+
checklist_file = checklist_dir / "checklists.md"
|
|
40
|
+
|
|
41
|
+
if not checklist_file.exists():
|
|
42
|
+
write_utf8(checklist_file, CHECKLIST_TEMPLATE)
|
|
43
|
+
|
|
44
|
+
return checklist_file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
def build_context_map(scan_result: dict) -> str:
|
|
2
|
+
lines = []
|
|
3
|
+
|
|
4
|
+
lines.append("Projeto Fleting - Contexto Geral\n")
|
|
5
|
+
|
|
6
|
+
if "app" in scan_result:
|
|
7
|
+
lines.append("Estrutura app/:")
|
|
8
|
+
lines.extend(render_tree(scan_result["app"], indent=2))
|
|
9
|
+
|
|
10
|
+
if scan_result.get("configs"):
|
|
11
|
+
lines.append("\nConfigs:")
|
|
12
|
+
for cfg in scan_result["configs"]:
|
|
13
|
+
lines.append(f" - {cfg}")
|
|
14
|
+
|
|
15
|
+
return "\n".join(lines)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def render_tree(tree: dict, indent=0):
|
|
19
|
+
lines = []
|
|
20
|
+
space = " " * indent
|
|
21
|
+
|
|
22
|
+
for key, value in tree.items():
|
|
23
|
+
if isinstance(value, dict):
|
|
24
|
+
lines.append(f"{space}- {key}/")
|
|
25
|
+
lines.extend(render_tree(value, indent + 2))
|
|
26
|
+
else:
|
|
27
|
+
lines.append(f"{space}- {key}")
|
|
28
|
+
|
|
29
|
+
return lines
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
def get_laptop_models(system_info):
|
|
2
|
+
ram = system_info["ram_gb"]
|
|
3
|
+
|
|
4
|
+
models = [
|
|
5
|
+
{
|
|
6
|
+
"name": "DeepSeek-Coder 1.3B",
|
|
7
|
+
"ollama_id": "deepseek-coder:1.3b",
|
|
8
|
+
"ram": "2 GB",
|
|
9
|
+
"description": "Especialista em cΓ³digo, ultra leve, ideal para hardware limitado e anΓ‘lise de Python/Flet"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Llama 3.2 3B",
|
|
13
|
+
"ollama_id": "llama3.2:3b",
|
|
14
|
+
"ram": "8 GB",
|
|
15
|
+
"description": "Leve, rΓ‘pido, ideal para cΓ³digo"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Phi-3 Mini",
|
|
19
|
+
"ollama_id": "phi3:mini",
|
|
20
|
+
"ram": "8 GB",
|
|
21
|
+
"description": "Muito rΓ‘pido, bom para anΓ‘lise"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Code Llama 7B",
|
|
25
|
+
"ollama_id": "codellama:7b",
|
|
26
|
+
"ram": "16 GB",
|
|
27
|
+
"description": "Excelente para projetos grandes"
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
if ram < 16:
|
|
32
|
+
return models[:2]
|
|
33
|
+
|
|
34
|
+
return models
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import subprocess
|
|
3
|
+
import platform
|
|
4
|
+
from flai.cli.console.console import console
|
|
5
|
+
|
|
6
|
+
def install_ollama():
|
|
7
|
+
if shutil.which("ollama"):
|
|
8
|
+
console.print("[info]Ollama jΓ‘ instalado[/info]")
|
|
9
|
+
return
|
|
10
|
+
|
|
11
|
+
os_type = platform.system()
|
|
12
|
+
console.print(f"[info]Instalando Ollama para {os_type}...[/info]")
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
if os_type == "Windows":
|
|
16
|
+
ps_command = (
|
|
17
|
+
"$url = 'https://ollama.com/download/OllamaSetup.exe'; "
|
|
18
|
+
"$out = \"$env:TEMP\\OllamaSetup.exe\"; "
|
|
19
|
+
"Invoke-WebRequest -Uri $url -OutFile $out; "
|
|
20
|
+
"Start-Process -FilePath $out -ArgumentList '/silent' -Wait; "
|
|
21
|
+
"Remove-Item $out"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
console.print("[info]Baixando e instalando silenciosamente (aguarde)...[/info]")
|
|
25
|
+
|
|
26
|
+
subprocess.run(
|
|
27
|
+
["powershell", "-Command", ps_command],
|
|
28
|
+
check=True
|
|
29
|
+
)
|
|
30
|
+
console.print("[success]Ollama instalado com sucesso via PowerShell![/success]")
|
|
31
|
+
|
|
32
|
+
elif os_type in ["Linux", "Darwin"]:
|
|
33
|
+
subprocess.run(
|
|
34
|
+
"curl -fsSL https://ollama.com/install.sh | sh",
|
|
35
|
+
shell=True,
|
|
36
|
+
check=True
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
except subprocess.CalledProcessError as e:
|
|
40
|
+
console.print(f"[error]Falha en la instalaciΓ³n automΓ‘tica: {e}[/error]")
|
|
41
|
+
console.print("[yellow]Intente instalar manualmente em: https://ollama.com[/yellow]")
|
|
42
|
+
raise
|
|
43
|
+
|
|
44
|
+
def pull_model(model_id: str):
|
|
45
|
+
subprocess.run(
|
|
46
|
+
["ollama", "pull", model_id],
|
|
47
|
+
check=True
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def run_ollama(model: str, prompt: str) -> str:
|
|
51
|
+
process = subprocess.run(
|
|
52
|
+
["ollama", "run", model],
|
|
53
|
+
input=prompt,
|
|
54
|
+
text=True,
|
|
55
|
+
encoding="utf-8", # β ESSENCIAL
|
|
56
|
+
errors="replace", # β evita crash
|
|
57
|
+
capture_output=True
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if process.returncode != 0:
|
|
61
|
+
raise RuntimeError(process.stderr)
|
|
62
|
+
|
|
63
|
+
return process.stdout.strip()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
IGNORED_DIRS = {".venv", "__pycache__", ".git"}
|
|
4
|
+
|
|
5
|
+
def scan_project(project_root: Path):
|
|
6
|
+
result = {
|
|
7
|
+
"app": {},
|
|
8
|
+
"configs": [],
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
app_dir = project_root / "app"
|
|
12
|
+
configs_dir = project_root / "configs"
|
|
13
|
+
|
|
14
|
+
if app_dir.exists():
|
|
15
|
+
result["app"] = scan_dir(app_dir)
|
|
16
|
+
|
|
17
|
+
if configs_dir.exists():
|
|
18
|
+
result["configs"] = list_files(configs_dir)
|
|
19
|
+
|
|
20
|
+
return result
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def scan_dir(base: Path):
|
|
24
|
+
structure = {}
|
|
25
|
+
|
|
26
|
+
for item in base.iterdir():
|
|
27
|
+
if item.name in IGNORED_DIRS:
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
if item.is_dir():
|
|
31
|
+
structure[item.name] = scan_dir(item)
|
|
32
|
+
else:
|
|
33
|
+
structure[item.name] = summarize_file(item)
|
|
34
|
+
|
|
35
|
+
return structure
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def list_files(base: Path):
|
|
39
|
+
return [f.name for f in base.glob("*") if f.is_file()]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def summarize_file(path: Path, max_lines=30):
|
|
43
|
+
try:
|
|
44
|
+
lines = path.read_text(errors="ignore").splitlines()
|
|
45
|
+
return "\n".join(lines[:max_lines])
|
|
46
|
+
except Exception:
|
|
47
|
+
return ""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import psutil
|
|
2
|
+
import platform
|
|
3
|
+
|
|
4
|
+
def analyze_system():
|
|
5
|
+
ram_gb = round(psutil.virtual_memory().total / 1024**3)
|
|
6
|
+
|
|
7
|
+
checklist = {
|
|
8
|
+
"Sistema suportado": platform.system() in ["Linux", "Darwin", "Windows"],
|
|
9
|
+
"RAM suficiente": ram_gb >= 8,
|
|
10
|
+
"Python >= 3.10": True,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
"ram_gb": ram_gb,
|
|
15
|
+
"os": platform.system(),
|
|
16
|
+
"checklist": checklist,
|
|
17
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "flai-ia"
|
|
3
|
+
version = "0.1.11"
|
|
4
|
+
description = "Flai - Framework local para ia"
|
|
5
|
+
readme = "./README.md"
|
|
6
|
+
license = { text = "MIT" }
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Alex Yucra" }
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
keywords = [
|
|
14
|
+
"ia local",
|
|
15
|
+
"localhost ia",
|
|
16
|
+
"framework de ia local",
|
|
17
|
+
"pip install flai",
|
|
18
|
+
"flai",
|
|
19
|
+
"flet",
|
|
20
|
+
"ollama",
|
|
21
|
+
"llm local",
|
|
22
|
+
"framework",
|
|
23
|
+
"mvc",
|
|
24
|
+
"ui",
|
|
25
|
+
"desktop",
|
|
26
|
+
"mobile",
|
|
27
|
+
"apk",
|
|
28
|
+
"app",
|
|
29
|
+
"android"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
classifiers = [
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"License :: OSI Approved :: MIT License",
|
|
36
|
+
"Operating System :: OS Independent"
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
dependencies = [
|
|
40
|
+
"fleting",
|
|
41
|
+
"rich",
|
|
42
|
+
"typer",
|
|
43
|
+
"psutil",
|
|
44
|
+
"langchain"
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
# ------------------------
|
|
48
|
+
# CLI ENTRY POINT
|
|
49
|
+
# ------------------------
|
|
50
|
+
[project.scripts]
|
|
51
|
+
flai = "flai.cli.cli:main"
|
|
52
|
+
|
|
53
|
+
# ------------------------
|
|
54
|
+
# URLs (PyPI)
|
|
55
|
+
# ------------------------
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/alexyucra/flai"
|
|
58
|
+
Documentation = "https://github.com/alexyucra/flai/tree/main/docs"
|
|
59
|
+
Repository = "https://github.com/alexyucra/flai"
|
|
60
|
+
Issues = "https://github.com/alexyucra/flai/issues"
|
|
61
|
+
|
|
62
|
+
# ------------------------
|
|
63
|
+
# BUILD SYSTEM (Poetry)
|
|
64
|
+
# ------------------------
|
|
65
|
+
[build-system]
|
|
66
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
67
|
+
build-backend = "poetry.core.masonry.api"
|
|
68
|
+
|
|
69
|
+
[tool.poetry]
|
|
70
|
+
packages = [{ include = "flai" }]
|