docs-cli 0.1.0__tar.gz → 0.1.1__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.
- docs_cli-0.1.1/PKG-INFO +162 -0
- docs_cli-0.1.1/README.md +142 -0
- docs_cli-0.1.1/docs_cli.egg-info/PKG-INFO +162 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_cli.egg-info/entry_points.txt +1 -1
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_tc.py +72 -4
- {docs_cli-0.1.0 → docs_cli-0.1.1}/generate_embeddings.py +16 -6
- {docs_cli-0.1.0 → docs_cli-0.1.1}/pyproject.toml +3 -4
- docs_cli-0.1.0/PKG-INFO +0 -223
- docs_cli-0.1.0/README.md +0 -202
- docs_cli-0.1.0/docs_cli.egg-info/PKG-INFO +0 -223
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_cli.egg-info/SOURCES.txt +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_cli.egg-info/dependency_links.txt +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_cli.egg-info/requires.txt +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/docs_cli.egg-info/top_level.txt +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/evaluate_coverage.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/extract_data_from_markdown.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/generate_report.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/generate_report_html.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/limpa_csv.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/merge_markdown.py +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/setup.cfg +0 -0
- {docs_cli-0.1.0 → docs_cli-0.1.1}/setup.py +0 -0
docs_cli-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: docs-cli
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Um toolkit para processamento e avaliação de documentação.
|
|
5
|
+
Author-email: Paulo Guilherme Pilott <seuemail@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Documentation
|
|
12
|
+
Classifier: Topic :: Utilities
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: google-generativeai
|
|
17
|
+
Requires-Dist: python-dotenv
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: pandas
|
|
20
|
+
|
|
21
|
+
# Docs CLI Toolkit
|
|
22
|
+
|
|
23
|
+
Uma ferramenta de linha de comando para processamento e análise de documentação, com suporte a geração de embeddings usando a API do Google Gemini.
|
|
24
|
+
|
|
25
|
+
## Instalação
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install docs-cli-toolkit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuração da API do Google Gemini
|
|
32
|
+
|
|
33
|
+
A ferramenta oferece três maneiras de configurar a chave da API do Google Gemini:
|
|
34
|
+
|
|
35
|
+
1. **Configuração Global (Recomendada)**:
|
|
36
|
+
```bash
|
|
37
|
+
docs-cli api "sua-chave-api"
|
|
38
|
+
```
|
|
39
|
+
Para verificar a chave configurada (parcialmente mascarada):
|
|
40
|
+
```bash
|
|
41
|
+
docs-cli api --show
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. **Via Linha de Comando**:
|
|
45
|
+
```bash
|
|
46
|
+
docs-cli --api "sua-chave-api" generate_embeddings input.json output.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **Via Variável de Ambiente**:
|
|
50
|
+
Crie um arquivo `.env` no diretório do projeto:
|
|
51
|
+
```
|
|
52
|
+
GOOGLE_API_KEY=sua-chave-api
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Comandos Disponíveis
|
|
56
|
+
|
|
57
|
+
### 1. Merge de Documentos
|
|
58
|
+
Consolida múltiplos arquivos Markdown em um único arquivo:
|
|
59
|
+
```bash
|
|
60
|
+
docs-cli merge <diretório_entrada> [--output_file arquivo_saída.md]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Extração de Dados
|
|
64
|
+
Extrai dados estruturados do Markdown consolidado:
|
|
65
|
+
```bash
|
|
66
|
+
docs-cli extract [--input_file arquivo_entrada.md] [--output_file arquivo_saída.json]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Geração de Embeddings
|
|
70
|
+
Gera embeddings para os documentos processados:
|
|
71
|
+
```bash
|
|
72
|
+
docs-cli generate_embeddings [--input_file arquivo_entrada.json] [--output_file arquivo_saída.json]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Limpeza de CSV
|
|
76
|
+
Limpa e processa arquivos CSV de perguntas e respostas:
|
|
77
|
+
```bash
|
|
78
|
+
docs-cli clean_csv <arquivo_entrada.csv> [--output_file arquivo_saída.csv]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 5. Avaliação de Cobertura
|
|
82
|
+
Avalia a cobertura da documentação:
|
|
83
|
+
```bash
|
|
84
|
+
docs-cli evaluate <arquivo_qa.csv> <arquivo_embeddings.json> [-k N] [-o arquivo_saída.json]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 6. Geração de Relatórios
|
|
88
|
+
Gera relatórios em Markdown e HTML:
|
|
89
|
+
```bash
|
|
90
|
+
# Relatório em Markdown
|
|
91
|
+
docs-cli report_md [--input_file arquivo_entrada.json] [--output_file relatório.md] [--top_k_chunks N]
|
|
92
|
+
|
|
93
|
+
# Relatório em HTML
|
|
94
|
+
docs-cli report_html [--input_file arquivo_entrada.json] [--output_file relatório.html] [--top_k_chunks N]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 7. Fluxo Completo
|
|
98
|
+
Executa todo o pipeline de processamento:
|
|
99
|
+
```bash
|
|
100
|
+
docs-cli full_flow <diretório_docs> <arquivo_qa.csv> [--eval_top_k N]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 8. Fluxo Customizado
|
|
104
|
+
Executa uma sequência personalizada de etapas:
|
|
105
|
+
```bash
|
|
106
|
+
docs-cli custom_flow <etapas...>
|
|
107
|
+
```
|
|
108
|
+
Etapas disponíveis: `merge`, `extract`, `generate_embeddings`, `clean_csv`, `evaluate`, `report_md`, `report_html`
|
|
109
|
+
|
|
110
|
+
## Exemplos de Uso
|
|
111
|
+
|
|
112
|
+
### Processamento Básico
|
|
113
|
+
```bash
|
|
114
|
+
# Configurar a API (uma única vez)
|
|
115
|
+
docs-cli api "sua-chave-api"
|
|
116
|
+
|
|
117
|
+
# Processar documentação
|
|
118
|
+
docs-cli full_flow docs/ qa-data.csv
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Fluxo Customizado
|
|
122
|
+
```bash
|
|
123
|
+
# Executar apenas merge e extração
|
|
124
|
+
docs-cli custom_flow merge extract
|
|
125
|
+
|
|
126
|
+
# Executar geração de embeddings com chave API temporária
|
|
127
|
+
docs-cli --api "chave-temporária" custom_flow generate_embeddings
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Geração de Relatórios
|
|
131
|
+
```bash
|
|
132
|
+
# Gerar relatório em Markdown
|
|
133
|
+
docs-cli report_md --input_file evaluation_results.json --output_file coverage.md
|
|
134
|
+
|
|
135
|
+
# Gerar relatório em HTML
|
|
136
|
+
docs-cli report_html --input_file evaluation_results.json --output_file coverage.html
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Arquivos Intermediários
|
|
140
|
+
|
|
141
|
+
A ferramenta utiliza os seguintes arquivos intermediários por padrão:
|
|
142
|
+
- `corpus_consolidated.md`: Documentos Markdown consolidados
|
|
143
|
+
- `raw_docs.json`: Dados estruturados extraídos
|
|
144
|
+
- `embeddings.json`: Embeddings gerados
|
|
145
|
+
- `gartner_filtrado_processed.csv`: CSV processado
|
|
146
|
+
- `evaluation_results.json`: Resultados da avaliação
|
|
147
|
+
- `coverage_report.md`: Relatório em Markdown
|
|
148
|
+
- `coverage_report.html`: Relatório em HTML
|
|
149
|
+
|
|
150
|
+
## Requisitos
|
|
151
|
+
|
|
152
|
+
- Python 3.8+
|
|
153
|
+
- Google Gemini API Key
|
|
154
|
+
- Dependências listadas em `pyproject.toml`
|
|
155
|
+
|
|
156
|
+
## Contribuindo
|
|
157
|
+
|
|
158
|
+
Contribuições são bem-vindas! Por favor, sinta-se à vontade para enviar um Pull Request.
|
|
159
|
+
|
|
160
|
+
## Licença
|
|
161
|
+
|
|
162
|
+
Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.
|
docs_cli-0.1.1/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Docs CLI Toolkit
|
|
2
|
+
|
|
3
|
+
Uma ferramenta de linha de comando para processamento e análise de documentação, com suporte a geração de embeddings usando a API do Google Gemini.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install docs-cli-toolkit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuração da API do Google Gemini
|
|
12
|
+
|
|
13
|
+
A ferramenta oferece três maneiras de configurar a chave da API do Google Gemini:
|
|
14
|
+
|
|
15
|
+
1. **Configuração Global (Recomendada)**:
|
|
16
|
+
```bash
|
|
17
|
+
docs-cli api "sua-chave-api"
|
|
18
|
+
```
|
|
19
|
+
Para verificar a chave configurada (parcialmente mascarada):
|
|
20
|
+
```bash
|
|
21
|
+
docs-cli api --show
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **Via Linha de Comando**:
|
|
25
|
+
```bash
|
|
26
|
+
docs-cli --api "sua-chave-api" generate_embeddings input.json output.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Via Variável de Ambiente**:
|
|
30
|
+
Crie um arquivo `.env` no diretório do projeto:
|
|
31
|
+
```
|
|
32
|
+
GOOGLE_API_KEY=sua-chave-api
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Comandos Disponíveis
|
|
36
|
+
|
|
37
|
+
### 1. Merge de Documentos
|
|
38
|
+
Consolida múltiplos arquivos Markdown em um único arquivo:
|
|
39
|
+
```bash
|
|
40
|
+
docs-cli merge <diretório_entrada> [--output_file arquivo_saída.md]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Extração de Dados
|
|
44
|
+
Extrai dados estruturados do Markdown consolidado:
|
|
45
|
+
```bash
|
|
46
|
+
docs-cli extract [--input_file arquivo_entrada.md] [--output_file arquivo_saída.json]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Geração de Embeddings
|
|
50
|
+
Gera embeddings para os documentos processados:
|
|
51
|
+
```bash
|
|
52
|
+
docs-cli generate_embeddings [--input_file arquivo_entrada.json] [--output_file arquivo_saída.json]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 4. Limpeza de CSV
|
|
56
|
+
Limpa e processa arquivos CSV de perguntas e respostas:
|
|
57
|
+
```bash
|
|
58
|
+
docs-cli clean_csv <arquivo_entrada.csv> [--output_file arquivo_saída.csv]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 5. Avaliação de Cobertura
|
|
62
|
+
Avalia a cobertura da documentação:
|
|
63
|
+
```bash
|
|
64
|
+
docs-cli evaluate <arquivo_qa.csv> <arquivo_embeddings.json> [-k N] [-o arquivo_saída.json]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 6. Geração de Relatórios
|
|
68
|
+
Gera relatórios em Markdown e HTML:
|
|
69
|
+
```bash
|
|
70
|
+
# Relatório em Markdown
|
|
71
|
+
docs-cli report_md [--input_file arquivo_entrada.json] [--output_file relatório.md] [--top_k_chunks N]
|
|
72
|
+
|
|
73
|
+
# Relatório em HTML
|
|
74
|
+
docs-cli report_html [--input_file arquivo_entrada.json] [--output_file relatório.html] [--top_k_chunks N]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 7. Fluxo Completo
|
|
78
|
+
Executa todo o pipeline de processamento:
|
|
79
|
+
```bash
|
|
80
|
+
docs-cli full_flow <diretório_docs> <arquivo_qa.csv> [--eval_top_k N]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 8. Fluxo Customizado
|
|
84
|
+
Executa uma sequência personalizada de etapas:
|
|
85
|
+
```bash
|
|
86
|
+
docs-cli custom_flow <etapas...>
|
|
87
|
+
```
|
|
88
|
+
Etapas disponíveis: `merge`, `extract`, `generate_embeddings`, `clean_csv`, `evaluate`, `report_md`, `report_html`
|
|
89
|
+
|
|
90
|
+
## Exemplos de Uso
|
|
91
|
+
|
|
92
|
+
### Processamento Básico
|
|
93
|
+
```bash
|
|
94
|
+
# Configurar a API (uma única vez)
|
|
95
|
+
docs-cli api "sua-chave-api"
|
|
96
|
+
|
|
97
|
+
# Processar documentação
|
|
98
|
+
docs-cli full_flow docs/ qa-data.csv
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Fluxo Customizado
|
|
102
|
+
```bash
|
|
103
|
+
# Executar apenas merge e extração
|
|
104
|
+
docs-cli custom_flow merge extract
|
|
105
|
+
|
|
106
|
+
# Executar geração de embeddings com chave API temporária
|
|
107
|
+
docs-cli --api "chave-temporária" custom_flow generate_embeddings
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Geração de Relatórios
|
|
111
|
+
```bash
|
|
112
|
+
# Gerar relatório em Markdown
|
|
113
|
+
docs-cli report_md --input_file evaluation_results.json --output_file coverage.md
|
|
114
|
+
|
|
115
|
+
# Gerar relatório em HTML
|
|
116
|
+
docs-cli report_html --input_file evaluation_results.json --output_file coverage.html
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Arquivos Intermediários
|
|
120
|
+
|
|
121
|
+
A ferramenta utiliza os seguintes arquivos intermediários por padrão:
|
|
122
|
+
- `corpus_consolidated.md`: Documentos Markdown consolidados
|
|
123
|
+
- `raw_docs.json`: Dados estruturados extraídos
|
|
124
|
+
- `embeddings.json`: Embeddings gerados
|
|
125
|
+
- `gartner_filtrado_processed.csv`: CSV processado
|
|
126
|
+
- `evaluation_results.json`: Resultados da avaliação
|
|
127
|
+
- `coverage_report.md`: Relatório em Markdown
|
|
128
|
+
- `coverage_report.html`: Relatório em HTML
|
|
129
|
+
|
|
130
|
+
## Requisitos
|
|
131
|
+
|
|
132
|
+
- Python 3.8+
|
|
133
|
+
- Google Gemini API Key
|
|
134
|
+
- Dependências listadas em `pyproject.toml`
|
|
135
|
+
|
|
136
|
+
## Contribuindo
|
|
137
|
+
|
|
138
|
+
Contribuições são bem-vindas! Por favor, sinta-se à vontade para enviar um Pull Request.
|
|
139
|
+
|
|
140
|
+
## Licença
|
|
141
|
+
|
|
142
|
+
Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: docs-cli
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Um toolkit para processamento e avaliação de documentação.
|
|
5
|
+
Author-email: Paulo Guilherme Pilott <seuemail@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Documentation
|
|
12
|
+
Classifier: Topic :: Utilities
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: google-generativeai
|
|
17
|
+
Requires-Dist: python-dotenv
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: pandas
|
|
20
|
+
|
|
21
|
+
# Docs CLI Toolkit
|
|
22
|
+
|
|
23
|
+
Uma ferramenta de linha de comando para processamento e análise de documentação, com suporte a geração de embeddings usando a API do Google Gemini.
|
|
24
|
+
|
|
25
|
+
## Instalação
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install docs-cli-toolkit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuração da API do Google Gemini
|
|
32
|
+
|
|
33
|
+
A ferramenta oferece três maneiras de configurar a chave da API do Google Gemini:
|
|
34
|
+
|
|
35
|
+
1. **Configuração Global (Recomendada)**:
|
|
36
|
+
```bash
|
|
37
|
+
docs-cli api "sua-chave-api"
|
|
38
|
+
```
|
|
39
|
+
Para verificar a chave configurada (parcialmente mascarada):
|
|
40
|
+
```bash
|
|
41
|
+
docs-cli api --show
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. **Via Linha de Comando**:
|
|
45
|
+
```bash
|
|
46
|
+
docs-cli --api "sua-chave-api" generate_embeddings input.json output.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **Via Variável de Ambiente**:
|
|
50
|
+
Crie um arquivo `.env` no diretório do projeto:
|
|
51
|
+
```
|
|
52
|
+
GOOGLE_API_KEY=sua-chave-api
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Comandos Disponíveis
|
|
56
|
+
|
|
57
|
+
### 1. Merge de Documentos
|
|
58
|
+
Consolida múltiplos arquivos Markdown em um único arquivo:
|
|
59
|
+
```bash
|
|
60
|
+
docs-cli merge <diretório_entrada> [--output_file arquivo_saída.md]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Extração de Dados
|
|
64
|
+
Extrai dados estruturados do Markdown consolidado:
|
|
65
|
+
```bash
|
|
66
|
+
docs-cli extract [--input_file arquivo_entrada.md] [--output_file arquivo_saída.json]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Geração de Embeddings
|
|
70
|
+
Gera embeddings para os documentos processados:
|
|
71
|
+
```bash
|
|
72
|
+
docs-cli generate_embeddings [--input_file arquivo_entrada.json] [--output_file arquivo_saída.json]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Limpeza de CSV
|
|
76
|
+
Limpa e processa arquivos CSV de perguntas e respostas:
|
|
77
|
+
```bash
|
|
78
|
+
docs-cli clean_csv <arquivo_entrada.csv> [--output_file arquivo_saída.csv]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 5. Avaliação de Cobertura
|
|
82
|
+
Avalia a cobertura da documentação:
|
|
83
|
+
```bash
|
|
84
|
+
docs-cli evaluate <arquivo_qa.csv> <arquivo_embeddings.json> [-k N] [-o arquivo_saída.json]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 6. Geração de Relatórios
|
|
88
|
+
Gera relatórios em Markdown e HTML:
|
|
89
|
+
```bash
|
|
90
|
+
# Relatório em Markdown
|
|
91
|
+
docs-cli report_md [--input_file arquivo_entrada.json] [--output_file relatório.md] [--top_k_chunks N]
|
|
92
|
+
|
|
93
|
+
# Relatório em HTML
|
|
94
|
+
docs-cli report_html [--input_file arquivo_entrada.json] [--output_file relatório.html] [--top_k_chunks N]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 7. Fluxo Completo
|
|
98
|
+
Executa todo o pipeline de processamento:
|
|
99
|
+
```bash
|
|
100
|
+
docs-cli full_flow <diretório_docs> <arquivo_qa.csv> [--eval_top_k N]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 8. Fluxo Customizado
|
|
104
|
+
Executa uma sequência personalizada de etapas:
|
|
105
|
+
```bash
|
|
106
|
+
docs-cli custom_flow <etapas...>
|
|
107
|
+
```
|
|
108
|
+
Etapas disponíveis: `merge`, `extract`, `generate_embeddings`, `clean_csv`, `evaluate`, `report_md`, `report_html`
|
|
109
|
+
|
|
110
|
+
## Exemplos de Uso
|
|
111
|
+
|
|
112
|
+
### Processamento Básico
|
|
113
|
+
```bash
|
|
114
|
+
# Configurar a API (uma única vez)
|
|
115
|
+
docs-cli api "sua-chave-api"
|
|
116
|
+
|
|
117
|
+
# Processar documentação
|
|
118
|
+
docs-cli full_flow docs/ qa-data.csv
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Fluxo Customizado
|
|
122
|
+
```bash
|
|
123
|
+
# Executar apenas merge e extração
|
|
124
|
+
docs-cli custom_flow merge extract
|
|
125
|
+
|
|
126
|
+
# Executar geração de embeddings com chave API temporária
|
|
127
|
+
docs-cli --api "chave-temporária" custom_flow generate_embeddings
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Geração de Relatórios
|
|
131
|
+
```bash
|
|
132
|
+
# Gerar relatório em Markdown
|
|
133
|
+
docs-cli report_md --input_file evaluation_results.json --output_file coverage.md
|
|
134
|
+
|
|
135
|
+
# Gerar relatório em HTML
|
|
136
|
+
docs-cli report_html --input_file evaluation_results.json --output_file coverage.html
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Arquivos Intermediários
|
|
140
|
+
|
|
141
|
+
A ferramenta utiliza os seguintes arquivos intermediários por padrão:
|
|
142
|
+
- `corpus_consolidated.md`: Documentos Markdown consolidados
|
|
143
|
+
- `raw_docs.json`: Dados estruturados extraídos
|
|
144
|
+
- `embeddings.json`: Embeddings gerados
|
|
145
|
+
- `gartner_filtrado_processed.csv`: CSV processado
|
|
146
|
+
- `evaluation_results.json`: Resultados da avaliação
|
|
147
|
+
- `coverage_report.md`: Relatório em Markdown
|
|
148
|
+
- `coverage_report.html`: Relatório em HTML
|
|
149
|
+
|
|
150
|
+
## Requisitos
|
|
151
|
+
|
|
152
|
+
- Python 3.8+
|
|
153
|
+
- Google Gemini API Key
|
|
154
|
+
- Dependências listadas em `pyproject.toml`
|
|
155
|
+
|
|
156
|
+
## Contribuindo
|
|
157
|
+
|
|
158
|
+
Contribuições são bem-vindas! Por favor, sinta-se à vontade para enviar um Pull Request.
|
|
159
|
+
|
|
160
|
+
## Licença
|
|
161
|
+
|
|
162
|
+
Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.
|
|
@@ -3,7 +3,7 @@ docs-cli = docs_tc:main
|
|
|
3
3
|
docs-tc-clean-csv = limpa_csv:cli_main
|
|
4
4
|
docs-tc-evaluate-coverage = evaluate_coverage:cli_main
|
|
5
5
|
docs-tc-extract-data = extract_data_from_markdown:cli_main
|
|
6
|
-
docs-tc-generate-embeddings =
|
|
6
|
+
docs-tc-generate-embeddings = generate_embeddings:cli_main
|
|
7
7
|
docs-tc-generate-report-html = generate_report_html:cli_main
|
|
8
8
|
docs-tc-generate-report-md = generate_report:cli_main
|
|
9
9
|
docs-tc-merge-markdown = merge_markdown:cli_main
|
|
@@ -5,6 +5,8 @@ import argparse
|
|
|
5
5
|
import subprocess
|
|
6
6
|
import sys
|
|
7
7
|
import os
|
|
8
|
+
import json
|
|
9
|
+
from pathlib import Path
|
|
8
10
|
|
|
9
11
|
# Nomes de arquivo padrão intermediários e finais
|
|
10
12
|
DEFAULT_CORPUS_CONSOLIDATED = "corpus_consolidated.md"
|
|
@@ -15,6 +17,31 @@ DEFAULT_QA_PROCESSED = "gartner_filtrado_processed.csv" # Saída do limpa_csv e
|
|
|
15
17
|
DEFAULT_MD_REPORT = "coverage_report.md"
|
|
16
18
|
DEFAULT_HTML_REPORT = "coverage_report.html"
|
|
17
19
|
|
|
20
|
+
# Configuração da API
|
|
21
|
+
CONFIG_DIR = Path.home() / ".docs-cli"
|
|
22
|
+
CONFIG_FILE = CONFIG_DIR / "config.json"
|
|
23
|
+
|
|
24
|
+
def ensure_config_dir():
|
|
25
|
+
"""Garante que o diretório de configuração existe."""
|
|
26
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
27
|
+
|
|
28
|
+
def load_config():
|
|
29
|
+
"""Carrega a configuração do arquivo config.json."""
|
|
30
|
+
ensure_config_dir()
|
|
31
|
+
if CONFIG_FILE.exists():
|
|
32
|
+
try:
|
|
33
|
+
with open(CONFIG_FILE, 'r') as f:
|
|
34
|
+
return json.load(f)
|
|
35
|
+
except json.JSONDecodeError:
|
|
36
|
+
return {}
|
|
37
|
+
return {}
|
|
38
|
+
|
|
39
|
+
def save_config(config):
|
|
40
|
+
"""Salva a configuração no arquivo config.json."""
|
|
41
|
+
ensure_config_dir()
|
|
42
|
+
with open(CONFIG_FILE, 'w') as f:
|
|
43
|
+
json.dump(config, f, indent=4)
|
|
44
|
+
|
|
18
45
|
def run_script(command_args):
|
|
19
46
|
"""Executa um script (entry point) como um subprocesso."""
|
|
20
47
|
# Espera que command_args[0] seja um executável no PATH (ex: 'docs-tc-extract-data')
|
|
@@ -45,8 +72,17 @@ def run_script(command_args):
|
|
|
45
72
|
|
|
46
73
|
def main():
|
|
47
74
|
parser = argparse.ArgumentParser(description="Docs Toolkit CLI - Orquestrador de scripts de processamento de documentação.")
|
|
75
|
+
|
|
76
|
+
# Adiciona argumento global para a chave da API
|
|
77
|
+
parser.add_argument("--api", help="Chave da API do Google Gemini (opcional, pode ser fornecida via GOOGLE_API_KEY no .env)")
|
|
78
|
+
|
|
48
79
|
subparsers = parser.add_subparsers(dest="command", help="Comandos disponíveis", required=True)
|
|
49
80
|
|
|
81
|
+
# --- Subparser para configuração da API ---
|
|
82
|
+
parser_api = subparsers.add_parser("api", help="Configura a chave da API do Google Gemini.")
|
|
83
|
+
parser_api.add_argument("api_key", help="Chave da API do Google Gemini para ser salva globalmente.")
|
|
84
|
+
parser_api.add_argument("--show", action="store_true", help="Mostra a chave da API atual (parcialmente mascarada).")
|
|
85
|
+
|
|
50
86
|
# --- Subparser para merge_markdown.py ---
|
|
51
87
|
parser_merge = subparsers.add_parser("merge", help="Consolida arquivos Markdown de um diretório.")
|
|
52
88
|
parser_merge.add_argument("input_dir", help="Diretório de entrada contendo os arquivos .md.")
|
|
@@ -123,11 +159,31 @@ def main():
|
|
|
123
159
|
|
|
124
160
|
args = parser.parse_args()
|
|
125
161
|
|
|
162
|
+
# Carrega a configuração
|
|
163
|
+
config = load_config()
|
|
164
|
+
|
|
165
|
+
# Se o comando for 'api', lida com a configuração da API
|
|
166
|
+
if args.command == "api":
|
|
167
|
+
if args.show:
|
|
168
|
+
if "api_key" in config:
|
|
169
|
+
masked_key = config["api_key"][:8] + "..." + config["api_key"][-4:]
|
|
170
|
+
print(f"Chave da API atual: {masked_key}")
|
|
171
|
+
else:
|
|
172
|
+
print("Nenhuma chave da API configurada.")
|
|
173
|
+
else:
|
|
174
|
+
config["api_key"] = args.api_key
|
|
175
|
+
save_config(config)
|
|
176
|
+
print("✅ Chave da API configurada com sucesso!")
|
|
177
|
+
return
|
|
178
|
+
|
|
179
|
+
# Usa a chave da API da configuração se não for fornecida via linha de comando
|
|
180
|
+
api_key = args.api or config.get("api_key")
|
|
181
|
+
|
|
126
182
|
# Nomes dos entry points (conforme definido em setup.py)
|
|
127
183
|
SCRIPT_MAP = {
|
|
128
184
|
"merge": "docs-tc-merge-markdown",
|
|
129
185
|
"extract": "docs-tc-extract-data",
|
|
130
|
-
"generate_embeddings": "docs-tc-generate-embeddings",
|
|
186
|
+
"generate_embeddings": "docs-tc-generate-embeddings",
|
|
131
187
|
"clean_csv": "docs-tc-clean-csv",
|
|
132
188
|
"evaluate": "docs-tc-evaluate-coverage",
|
|
133
189
|
"report_md": "docs-tc-generate-report-md",
|
|
@@ -139,7 +195,10 @@ def main():
|
|
|
139
195
|
elif args.command == "extract":
|
|
140
196
|
run_script([SCRIPT_MAP["extract"], args.input_file, args.output_file])
|
|
141
197
|
elif args.command == "generate_embeddings":
|
|
142
|
-
|
|
198
|
+
command_args = [SCRIPT_MAP["generate_embeddings"], args.input_file, args.output_file]
|
|
199
|
+
if api_key:
|
|
200
|
+
command_args.extend(["--api-key", api_key])
|
|
201
|
+
run_script(command_args)
|
|
143
202
|
elif args.command == "clean_csv":
|
|
144
203
|
run_script([SCRIPT_MAP["clean_csv"], args.input_file, args.output_file])
|
|
145
204
|
elif args.command == "evaluate":
|
|
@@ -174,7 +233,13 @@ def main():
|
|
|
174
233
|
run_step_or_exit([SCRIPT_MAP["merge"], args.doc_input_dir, args.corpus_file])
|
|
175
234
|
run_step_or_exit([SCRIPT_MAP["clean_csv"], args.qa_input_file, args.cleaned_qa_file])
|
|
176
235
|
run_step_or_exit([SCRIPT_MAP["extract"], args.corpus_file, args.raw_docs_file])
|
|
177
|
-
|
|
236
|
+
|
|
237
|
+
# Adiciona a chave da API ao comando generate_embeddings se fornecida
|
|
238
|
+
generate_embeddings_args = [SCRIPT_MAP["generate_embeddings"], args.raw_docs_file, args.embeddings_file]
|
|
239
|
+
if api_key:
|
|
240
|
+
generate_embeddings_args.extend(["--api-key", api_key])
|
|
241
|
+
run_step_or_exit(generate_embeddings_args)
|
|
242
|
+
|
|
178
243
|
run_step_or_exit([
|
|
179
244
|
SCRIPT_MAP["evaluate"],
|
|
180
245
|
args.cleaned_qa_file,
|
|
@@ -222,7 +287,10 @@ def main():
|
|
|
222
287
|
elif step == "generate_embeddings":
|
|
223
288
|
if not os.path.exists(current_raw_docs_file):
|
|
224
289
|
current_raw_docs_file = input(f"Arquivo Raw Docs ({current_raw_docs_file}) não encontrado. Informe o caminho correto: ")
|
|
225
|
-
|
|
290
|
+
command_args = [SCRIPT_MAP["generate_embeddings"], current_raw_docs_file, current_embeddings_file]
|
|
291
|
+
if api_key:
|
|
292
|
+
command_args.extend(["--api-key", api_key])
|
|
293
|
+
run_custom_step_or_exit(command_args)
|
|
226
294
|
elif step == "clean_csv":
|
|
227
295
|
qa_input_file = input("Por favor, informe o arquivo CSV de Q&A original para 'clean_csv' (pressione Enter para usar 'qa-data.csv'): ") or "qa-data.csv"
|
|
228
296
|
run_custom_step_or_exit([SCRIPT_MAP["clean_csv"], qa_input_file, current_cleaned_qa_file])
|
|
@@ -11,10 +11,6 @@ import re
|
|
|
11
11
|
load_dotenv()
|
|
12
12
|
|
|
13
13
|
# --- Configuração da API do Google Gemini ---
|
|
14
|
-
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
|
15
|
-
if not GOOGLE_API_KEY:
|
|
16
|
-
raise ValueError("A variável de ambiente GOOGLE_API_KEY não está configurada.")
|
|
17
|
-
genai.configure(api_key=GOOGLE_API_KEY) # type: ignore
|
|
18
14
|
EMBEDDING_MODEL = "models/embedding-001"
|
|
19
15
|
|
|
20
16
|
# Limite de caracteres para o embedding, para evitar exceder o limite de tokens da API
|
|
@@ -25,6 +21,16 @@ REQUEST_LIMIT_PER_MINUTE = 150
|
|
|
25
21
|
request_count = 0
|
|
26
22
|
last_request_time = time.time() # Inicializa com o tempo atual
|
|
27
23
|
|
|
24
|
+
def configure_api(api_key=None):
|
|
25
|
+
"""
|
|
26
|
+
Configura a API do Google Gemini com a chave fornecida ou da variável de ambiente.
|
|
27
|
+
"""
|
|
28
|
+
global GOOGLE_API_KEY
|
|
29
|
+
GOOGLE_API_KEY = api_key or os.getenv("GOOGLE_API_KEY")
|
|
30
|
+
if not GOOGLE_API_KEY:
|
|
31
|
+
raise ValueError("A chave da API do Google Gemini não está configurada. Use --api-key ou configure GOOGLE_API_KEY no arquivo .env")
|
|
32
|
+
genai.configure(api_key=GOOGLE_API_KEY) # type: ignore
|
|
33
|
+
|
|
28
34
|
def clean_text_for_embedding(text):
|
|
29
35
|
"""
|
|
30
36
|
Remove caracteres especiais e formatação markdown para texto que será EMBEDDADO.
|
|
@@ -142,11 +148,14 @@ def generate_embedding_with_retry(text_content):
|
|
|
142
148
|
return None
|
|
143
149
|
return None
|
|
144
150
|
|
|
145
|
-
def generate_embeddings_for_docs(input_json_path="raw_docs.json", output_json_path="embeddings.json"):
|
|
151
|
+
def generate_embeddings_for_docs(input_json_path="raw_docs.json", output_json_path="embeddings.json", api_key=None):
|
|
146
152
|
"""
|
|
147
153
|
Lê o JSON com dados de documentos (já separados), divide cada um em chunks,
|
|
148
154
|
gera embeddings para cada chunk, e salva o resultado final em um novo JSON.
|
|
149
155
|
"""
|
|
156
|
+
# Configura a API com a chave fornecida
|
|
157
|
+
configure_api(api_key)
|
|
158
|
+
|
|
150
159
|
if not os.path.exists(input_json_path):
|
|
151
160
|
print(f"Erro: O arquivo '{input_json_path}' não foi encontrado. Por favor, execute o script de extração (ex: 'extract_consolidated_md_to_raw_json.py') primeiro.")
|
|
152
161
|
return False
|
|
@@ -224,8 +233,9 @@ def cli_main():
|
|
|
224
233
|
parser = argparse.ArgumentParser(description="Gera embeddings para documentos a partir de um JSON.")
|
|
225
234
|
parser.add_argument("input_json_path", help="Caminho para o arquivo JSON de entrada (ex: raw_docs.json).")
|
|
226
235
|
parser.add_argument("output_json_path", help="Caminho para o arquivo JSON de saída dos embeddings (ex: embeddings.json).")
|
|
236
|
+
parser.add_argument("--api-key", help="Chave da API do Google Gemini (opcional, pode ser fornecida via GOOGLE_API_KEY no .env)")
|
|
227
237
|
args = parser.parse_args()
|
|
228
|
-
success = generate_embeddings_for_docs(args.input_json_path, args.output_json_path)
|
|
238
|
+
success = generate_embeddings_for_docs(args.input_json_path, args.output_json_path, args.api_key)
|
|
229
239
|
if not success:
|
|
230
240
|
print("A geração de embeddings falhou.")
|
|
231
241
|
sys.exit(1) # Garante que sys está importado se for usar aqui
|
|
@@ -7,17 +7,16 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "docs-cli"
|
|
10
|
-
version = "0.1.
|
|
10
|
+
version = "0.1.1"
|
|
11
11
|
authors = [
|
|
12
12
|
{ name="Paulo Guilherme Pilott", email="seuemail@example.com" },
|
|
13
13
|
]
|
|
14
14
|
description = "Um toolkit para processamento e avaliação de documentação."
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
requires-python = ">=3.8" # Definido aqui
|
|
17
|
-
license =
|
|
17
|
+
license = "MIT"
|
|
18
18
|
classifiers = [
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
|
-
"License :: OSI Approved :: MIT License",
|
|
21
20
|
"Operating System :: OS Independent",
|
|
22
21
|
"Development Status :: 3 - Alpha",
|
|
23
22
|
"Intended Audience :: Developers",
|
|
@@ -38,7 +37,7 @@ dependencies = [ # Equivalente a install_requires
|
|
|
38
37
|
docs-cli = "docs_tc:main"
|
|
39
38
|
docs-tc-merge-markdown = "merge_markdown:cli_main"
|
|
40
39
|
docs-tc-extract-data = "extract_data_from_markdown:cli_main"
|
|
41
|
-
docs-tc-generate-embeddings = "
|
|
40
|
+
docs-tc-generate-embeddings = "generate_embeddings:cli_main" # Corrigido o nome do módulo
|
|
42
41
|
docs-tc-clean-csv = "limpa_csv:cli_main"
|
|
43
42
|
docs-tc-evaluate-coverage = "evaluate_coverage:cli_main"
|
|
44
43
|
docs-tc-generate-report-md = "generate_report:cli_main"
|