vectorgov 0.2.0 → 0.3.0
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.
- package/README.md +162 -0
- package/dist/index.d.mts +362 -5
- package/dist/index.d.ts +362 -5
- package/dist/index.js +476 -22
- package/dist/index.mjs +476 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -181,6 +181,152 @@ await vg.feedback(results.metadata.queryId, true);
|
|
|
181
181
|
await vg.feedback(results.metadata.queryId, false);
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
+
## Streaming
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// Resposta em tempo real com Server-Sent Events
|
|
188
|
+
for await (const chunk of vg.askStream('O que é ETP?')) {
|
|
189
|
+
if (chunk.type === 'token') {
|
|
190
|
+
process.stdout.write(chunk.content || '');
|
|
191
|
+
} else if (chunk.type === 'complete') {
|
|
192
|
+
console.log('\n\nCitações:', chunk.citations);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## System Prompts
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// Ver prompts disponíveis
|
|
201
|
+
console.log(vg.availablePrompts); // ['default', 'concise', 'detailed', 'chatbot']
|
|
202
|
+
|
|
203
|
+
// Obter prompt específico
|
|
204
|
+
const prompt = vg.getSystemPrompt('detailed');
|
|
205
|
+
|
|
206
|
+
// Usar com seu LLM
|
|
207
|
+
const results = await vg.search('O que é ETP?');
|
|
208
|
+
const response = await openai.chat.completions.create({
|
|
209
|
+
model: 'gpt-4',
|
|
210
|
+
messages: [
|
|
211
|
+
{ role: 'system', content: prompt + '\n\n' + results.toContext() },
|
|
212
|
+
{ role: 'user', content: 'O que é ETP?' }
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Function Calling (Agentes)
|
|
218
|
+
|
|
219
|
+
Use VectorGov como ferramenta em agentes de IA:
|
|
220
|
+
|
|
221
|
+
### OpenAI Function Calling
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
const tools = [vg.toOpenAITool()];
|
|
225
|
+
|
|
226
|
+
const response = await openai.chat.completions.create({
|
|
227
|
+
model: 'gpt-4',
|
|
228
|
+
messages: [{ role: 'user', content: 'Pesquise sobre ETP' }],
|
|
229
|
+
tools,
|
|
230
|
+
tool_choice: 'auto'
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Se o modelo chamou a ferramenta
|
|
234
|
+
const toolCall = response.choices[0].message.tool_calls?.[0];
|
|
235
|
+
if (toolCall) {
|
|
236
|
+
const result = await vg.executeToolCall(toolCall);
|
|
237
|
+
console.log(result);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Anthropic Claude Tools
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
const tools = [vg.toAnthropicTool()];
|
|
245
|
+
|
|
246
|
+
const response = await anthropic.messages.create({
|
|
247
|
+
model: 'claude-sonnet-4-20250514',
|
|
248
|
+
max_tokens: 1024,
|
|
249
|
+
tools,
|
|
250
|
+
messages: [{ role: 'user', content: 'Pesquise sobre ETP' }]
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Google Gemini Tools
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
const tools = [vg.toGoogleTool()];
|
|
258
|
+
// Use com a API do Gemini
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## BYOLLM (Bring Your Own LLM)
|
|
262
|
+
|
|
263
|
+
Armazene respostas geradas pelo seu próprio LLM para analytics:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
const results = await vg.search('O que é ETP?');
|
|
267
|
+
|
|
268
|
+
// Gere resposta com seu LLM
|
|
269
|
+
const myResponse = await openai.chat.completions.create({
|
|
270
|
+
model: 'gpt-4',
|
|
271
|
+
messages: results.toMessages('O que é ETP?')
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Armazene para analytics
|
|
275
|
+
await vg.storeResponse({
|
|
276
|
+
query: 'O que é ETP?',
|
|
277
|
+
answer: myResponse.choices[0].message.content!,
|
|
278
|
+
provider: 'OpenAI',
|
|
279
|
+
model: 'gpt-4',
|
|
280
|
+
chunksUsed: results.hits.length,
|
|
281
|
+
latencyMs: 1500
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Gestão de Documentos
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// Listar documentos disponíveis
|
|
289
|
+
const docs = await vg.listDocuments();
|
|
290
|
+
for (const doc of docs.documents) {
|
|
291
|
+
console.log(`${doc.tipoDocumento} ${doc.numero}/${doc.ano}: ${doc.chunksCount} chunks`);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Detalhes de um documento
|
|
295
|
+
const doc = await vg.getDocument('LEI-14133-2021');
|
|
296
|
+
|
|
297
|
+
// Verificar status de ingestão
|
|
298
|
+
const status = await vg.getIngestStatus('task-id-123');
|
|
299
|
+
|
|
300
|
+
// Iniciar enriquecimento
|
|
301
|
+
await vg.startEnrichment('LEI-14133-2021');
|
|
302
|
+
|
|
303
|
+
// Verificar status de enriquecimento
|
|
304
|
+
const enrichStatus = await vg.getEnrichmentStatus('LEI-14133-2021');
|
|
305
|
+
|
|
306
|
+
// Deletar documento
|
|
307
|
+
await vg.deleteDocument('LEI-14133-2021');
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Logs de Auditoria
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// Listar logs de auditoria
|
|
314
|
+
const logs = await vg.getAuditLogs({
|
|
315
|
+
limit: 50,
|
|
316
|
+
severity: 'warning',
|
|
317
|
+
eventType: 'pii_detected'
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
for (const log of logs.logs) {
|
|
321
|
+
console.log(`${log.createdAt}: ${log.eventType} - ${log.severity}`);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Estatísticas de auditoria
|
|
325
|
+
const stats = await vg.getAuditStats(30); // últimos 30 dias
|
|
326
|
+
console.log(`Total eventos: ${stats.totalEvents}`);
|
|
327
|
+
console.log(`Bloqueados: ${stats.blockedCount}`);
|
|
328
|
+
```
|
|
329
|
+
|
|
184
330
|
## Tratamento de Erros
|
|
185
331
|
|
|
186
332
|
```typescript
|
|
@@ -229,7 +375,23 @@ const vg = new VectorGov({
|
|
|
229
375
|
|--------|-----------|
|
|
230
376
|
| `search(query, options?)` | Busca semântica |
|
|
231
377
|
| `ask(query, options?)` | Pergunta com resposta IA |
|
|
378
|
+
| `askStream(query, options?)` | Pergunta com streaming |
|
|
232
379
|
| `feedback(queryId, like)` | Envia feedback |
|
|
380
|
+
| `storeResponse(options)` | Armazena resposta do seu LLM |
|
|
381
|
+
| `getSystemPrompt(style)` | Obtém system prompt |
|
|
382
|
+
| `availablePrompts` | Lista prompts disponíveis |
|
|
383
|
+
| `toOpenAITool()` | Ferramenta para OpenAI |
|
|
384
|
+
| `toAnthropicTool()` | Ferramenta para Anthropic |
|
|
385
|
+
| `toGoogleTool()` | Ferramenta para Google |
|
|
386
|
+
| `executeToolCall(toolCall)` | Executa chamada de ferramenta |
|
|
387
|
+
| `listDocuments(options?)` | Lista documentos |
|
|
388
|
+
| `getDocument(documentId)` | Detalhes de documento |
|
|
389
|
+
| `getIngestStatus(taskId)` | Status de ingestão |
|
|
390
|
+
| `startEnrichment(documentId)` | Inicia enriquecimento |
|
|
391
|
+
| `getEnrichmentStatus(documentId)` | Status de enriquecimento |
|
|
392
|
+
| `deleteDocument(documentId)` | Remove documento |
|
|
393
|
+
| `getAuditLogs(options?)` | Logs de auditoria |
|
|
394
|
+
| `getAuditStats(days?)` | Estatísticas de auditoria |
|
|
233
395
|
|
|
234
396
|
### SearchOptions
|
|
235
397
|
|
package/dist/index.d.mts
CHANGED
|
@@ -213,6 +213,175 @@ interface AuditLogsOptions {
|
|
|
213
213
|
/** Data final (ISO 8601) */
|
|
214
214
|
endDate?: string;
|
|
215
215
|
}
|
|
216
|
+
/** Opções para armazenar resposta de LLM externo */
|
|
217
|
+
interface StoreResponseOptions {
|
|
218
|
+
/** Pergunta original */
|
|
219
|
+
query: string;
|
|
220
|
+
/** Resposta gerada pelo LLM */
|
|
221
|
+
answer: string;
|
|
222
|
+
/** Provedor do LLM (ex: "OpenAI", "Google", "Anthropic") */
|
|
223
|
+
provider: string;
|
|
224
|
+
/** Modelo usado (ex: "gpt-4o", "gemini-2.0-flash") */
|
|
225
|
+
model: string;
|
|
226
|
+
/** Quantidade de chunks usados como contexto */
|
|
227
|
+
chunksUsed?: number;
|
|
228
|
+
/** Latência total em ms */
|
|
229
|
+
latencyMs?: number;
|
|
230
|
+
/** Tempo de busca em ms */
|
|
231
|
+
retrievalMs?: number;
|
|
232
|
+
/** Tempo de geração em ms */
|
|
233
|
+
generationMs?: number;
|
|
234
|
+
}
|
|
235
|
+
/** Resultado do armazenamento de resposta */
|
|
236
|
+
interface StoreResponseResult {
|
|
237
|
+
/** Se foi armazenado com sucesso */
|
|
238
|
+
success: boolean;
|
|
239
|
+
/** Hash da query para uso em feedback */
|
|
240
|
+
queryHash: string;
|
|
241
|
+
/** Mensagem de status */
|
|
242
|
+
message: string;
|
|
243
|
+
}
|
|
244
|
+
/** Chunk de resposta em streaming */
|
|
245
|
+
interface StreamChunk {
|
|
246
|
+
/** Tipo do chunk (start, token, complete, error) */
|
|
247
|
+
type: 'start' | 'token' | 'complete' | 'error';
|
|
248
|
+
/** Conteúdo do chunk (token ou mensagem) */
|
|
249
|
+
content?: string;
|
|
250
|
+
/** Query original (em start) */
|
|
251
|
+
query?: string;
|
|
252
|
+
/** Chunks usados (em start) */
|
|
253
|
+
chunks?: number;
|
|
254
|
+
/** Tempo em ms (em complete) */
|
|
255
|
+
timeMs?: number;
|
|
256
|
+
/** Citações (em complete) */
|
|
257
|
+
citations?: Citation[];
|
|
258
|
+
/** Hash da query (em complete) */
|
|
259
|
+
queryHash?: string;
|
|
260
|
+
/** Mensagem de erro (em error) */
|
|
261
|
+
message?: string;
|
|
262
|
+
}
|
|
263
|
+
/** Resumo de um documento */
|
|
264
|
+
interface DocumentSummary {
|
|
265
|
+
/** ID único do documento */
|
|
266
|
+
documentId: string;
|
|
267
|
+
/** Tipo do documento (LEI, DECRETO, IN, etc) */
|
|
268
|
+
tipoDocumento: string;
|
|
269
|
+
/** Número do documento */
|
|
270
|
+
numero: string;
|
|
271
|
+
/** Ano do documento */
|
|
272
|
+
ano: number;
|
|
273
|
+
/** Título do documento */
|
|
274
|
+
titulo?: string;
|
|
275
|
+
/** Descrição/ementa */
|
|
276
|
+
descricao?: string;
|
|
277
|
+
/** Quantidade de chunks */
|
|
278
|
+
chunksCount: number;
|
|
279
|
+
/** Quantidade de chunks enriquecidos */
|
|
280
|
+
enrichedCount: number;
|
|
281
|
+
}
|
|
282
|
+
/** Resposta da listagem de documentos */
|
|
283
|
+
interface DocumentsResponse {
|
|
284
|
+
/** Lista de documentos */
|
|
285
|
+
documents: DocumentSummary[];
|
|
286
|
+
/** Total de documentos */
|
|
287
|
+
total: number;
|
|
288
|
+
/** Página atual */
|
|
289
|
+
page: number;
|
|
290
|
+
/** Total de páginas */
|
|
291
|
+
pages: number;
|
|
292
|
+
}
|
|
293
|
+
/** Opções para listagem de documentos */
|
|
294
|
+
interface ListDocumentsOptions {
|
|
295
|
+
/** Página (padrão: 1) */
|
|
296
|
+
page?: number;
|
|
297
|
+
/** Limite por página (padrão: 20) */
|
|
298
|
+
limit?: number;
|
|
299
|
+
}
|
|
300
|
+
/** Resposta de upload */
|
|
301
|
+
interface UploadResponse {
|
|
302
|
+
/** Se foi iniciado com sucesso */
|
|
303
|
+
success: boolean;
|
|
304
|
+
/** Mensagem de status */
|
|
305
|
+
message: string;
|
|
306
|
+
/** ID do documento criado */
|
|
307
|
+
documentId: string;
|
|
308
|
+
/** ID da task de ingestão */
|
|
309
|
+
taskId: string;
|
|
310
|
+
}
|
|
311
|
+
/** Status de ingestão */
|
|
312
|
+
interface IngestStatus {
|
|
313
|
+
/** ID da task */
|
|
314
|
+
taskId: string;
|
|
315
|
+
/** Status (pending, processing, completed, failed) */
|
|
316
|
+
status: string;
|
|
317
|
+
/** Progresso (0-100) */
|
|
318
|
+
progress: number;
|
|
319
|
+
/** Mensagem de status */
|
|
320
|
+
message: string;
|
|
321
|
+
/** ID do documento */
|
|
322
|
+
documentId?: string;
|
|
323
|
+
/** Chunks criados */
|
|
324
|
+
chunksCreated: number;
|
|
325
|
+
}
|
|
326
|
+
/** Status de enriquecimento */
|
|
327
|
+
interface EnrichStatus {
|
|
328
|
+
/** ID da task */
|
|
329
|
+
taskId: string;
|
|
330
|
+
/** Status (pending, processing, completed, failed) */
|
|
331
|
+
status: string;
|
|
332
|
+
/** Progresso (0-100) */
|
|
333
|
+
progress: number;
|
|
334
|
+
/** Chunks enriquecidos */
|
|
335
|
+
chunksEnriched: number;
|
|
336
|
+
/** Chunks pendentes */
|
|
337
|
+
chunksPending: number;
|
|
338
|
+
/** Chunks com erro */
|
|
339
|
+
chunksFailed: number;
|
|
340
|
+
/** Lista de erros */
|
|
341
|
+
errors: string[];
|
|
342
|
+
}
|
|
343
|
+
/** Resposta de deleção */
|
|
344
|
+
interface DeleteResponse {
|
|
345
|
+
/** Se foi deletado com sucesso */
|
|
346
|
+
success: boolean;
|
|
347
|
+
/** Mensagem de status */
|
|
348
|
+
message: string;
|
|
349
|
+
}
|
|
350
|
+
/** Definição de ferramenta para OpenAI */
|
|
351
|
+
interface OpenAITool {
|
|
352
|
+
type: 'function';
|
|
353
|
+
function: {
|
|
354
|
+
name: string;
|
|
355
|
+
description: string;
|
|
356
|
+
parameters: {
|
|
357
|
+
type: 'object';
|
|
358
|
+
properties: Record<string, unknown>;
|
|
359
|
+
required: string[];
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/** Definição de ferramenta para Anthropic */
|
|
364
|
+
interface AnthropicTool {
|
|
365
|
+
name: string;
|
|
366
|
+
description: string;
|
|
367
|
+
input_schema: {
|
|
368
|
+
type: 'object';
|
|
369
|
+
properties: Record<string, unknown>;
|
|
370
|
+
required: string[];
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/** Definição de ferramenta para Google Gemini */
|
|
374
|
+
interface GoogleTool {
|
|
375
|
+
name: string;
|
|
376
|
+
description: string;
|
|
377
|
+
parameters: {
|
|
378
|
+
type: 'object';
|
|
379
|
+
properties: Record<string, unknown>;
|
|
380
|
+
required: string[];
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/** Estilos de system prompt disponíveis */
|
|
384
|
+
type SystemPromptStyle = 'default' | 'concise' | 'detailed' | 'chatbot';
|
|
216
385
|
|
|
217
386
|
/**
|
|
218
387
|
* VectorGov SDK Client
|
|
@@ -271,6 +440,25 @@ declare class VectorGov {
|
|
|
271
440
|
* @returns Resposta com citações
|
|
272
441
|
*/
|
|
273
442
|
ask(query: string, options?: AskOptions): Promise<AskResponse>;
|
|
443
|
+
/**
|
|
444
|
+
* Faz uma pergunta com resposta em streaming
|
|
445
|
+
*
|
|
446
|
+
* @param query - Pergunta do usuário
|
|
447
|
+
* @param options - Opções de busca
|
|
448
|
+
* @yields StreamChunk com cada parte da resposta
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* for await (const chunk of vg.askStream('O que é ETP?')) {
|
|
453
|
+
* if (chunk.type === 'token') {
|
|
454
|
+
* process.stdout.write(chunk.content || '');
|
|
455
|
+
* } else if (chunk.type === 'complete') {
|
|
456
|
+
* console.log(`\n\nFontes: ${chunk.citations?.length} citações`);
|
|
457
|
+
* }
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
askStream(query: string, options?: SearchOptions): AsyncGenerator<StreamChunk>;
|
|
274
462
|
/**
|
|
275
463
|
* Envia feedback (like/dislike) para uma resposta
|
|
276
464
|
*
|
|
@@ -279,13 +467,174 @@ declare class VectorGov {
|
|
|
279
467
|
*/
|
|
280
468
|
feedback(queryId: string, like: boolean): Promise<FeedbackResponse>;
|
|
281
469
|
/**
|
|
282
|
-
*
|
|
470
|
+
* Armazena resposta de LLM externo no cache do VectorGov
|
|
471
|
+
*
|
|
472
|
+
* Use quando você gera uma resposta com seu próprio LLM e quer:
|
|
473
|
+
* 1. Habilitar o sistema de feedback (like/dislike)
|
|
474
|
+
* 2. Contribuir para melhorias futuras
|
|
475
|
+
*
|
|
476
|
+
* @param options - Dados da resposta
|
|
477
|
+
* @returns Resultado com queryHash para usar em feedback()
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* // 1. Busca no VectorGov
|
|
482
|
+
* const results = await vg.search('O que é ETP?');
|
|
483
|
+
*
|
|
484
|
+
* // 2. Gera resposta com seu LLM
|
|
485
|
+
* const answer = await openai.chat.completions.create({
|
|
486
|
+
* model: 'gpt-4o',
|
|
487
|
+
* messages: results.toMessages('O que é ETP?')
|
|
488
|
+
* });
|
|
489
|
+
*
|
|
490
|
+
* // 3. Salva no VectorGov
|
|
491
|
+
* const stored = await vg.storeResponse({
|
|
492
|
+
* query: 'O que é ETP?',
|
|
493
|
+
* answer: answer.choices[0].message.content,
|
|
494
|
+
* provider: 'OpenAI',
|
|
495
|
+
* model: 'gpt-4o',
|
|
496
|
+
* chunksUsed: results.hits.length
|
|
497
|
+
* });
|
|
498
|
+
*
|
|
499
|
+
* // 4. Agora pode receber feedback
|
|
500
|
+
* await vg.feedback(stored.queryHash, true);
|
|
501
|
+
* ```
|
|
283
502
|
*/
|
|
284
|
-
|
|
503
|
+
storeResponse(options: StoreResponseOptions): Promise<StoreResponseResult>;
|
|
285
504
|
/**
|
|
286
|
-
*
|
|
505
|
+
* Retorna um system prompt pré-definido
|
|
506
|
+
*
|
|
507
|
+
* @param style - Estilo do prompt (default, concise, detailed, chatbot)
|
|
508
|
+
* @returns String com o system prompt
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* const prompt = vg.getSystemPrompt('detailed');
|
|
513
|
+
* const messages = results.toMessages('query');
|
|
514
|
+
* messages[0].content = prompt; // Substitui o system prompt
|
|
515
|
+
* ```
|
|
287
516
|
*/
|
|
288
|
-
|
|
517
|
+
getSystemPrompt(style?: SystemPromptStyle): string;
|
|
518
|
+
/**
|
|
519
|
+
* Lista os estilos de system prompt disponíveis
|
|
520
|
+
*/
|
|
521
|
+
get availablePrompts(): SystemPromptStyle[];
|
|
522
|
+
/**
|
|
523
|
+
* Retorna a ferramenta VectorGov no formato OpenAI Function Calling
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* const response = await openai.chat.completions.create({
|
|
528
|
+
* model: 'gpt-4o',
|
|
529
|
+
* messages: [...],
|
|
530
|
+
* tools: [vg.toOpenAITool()],
|
|
531
|
+
* });
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
toOpenAITool(): OpenAITool;
|
|
535
|
+
/**
|
|
536
|
+
* Retorna a ferramenta VectorGov no formato Anthropic Claude Tools
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```typescript
|
|
540
|
+
* const response = await anthropic.messages.create({
|
|
541
|
+
* model: 'claude-sonnet-4-20250514',
|
|
542
|
+
* messages: [...],
|
|
543
|
+
* tools: [vg.toAnthropicTool()],
|
|
544
|
+
* });
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
toAnthropicTool(): AnthropicTool;
|
|
548
|
+
/**
|
|
549
|
+
* Retorna a ferramenta VectorGov no formato Google Gemini
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```typescript
|
|
553
|
+
* const model = genai.GenerativeModel({
|
|
554
|
+
* model: 'gemini-2.0-flash',
|
|
555
|
+
* tools: [vg.toGoogleTool()],
|
|
556
|
+
* });
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
toGoogleTool(): GoogleTool;
|
|
560
|
+
/**
|
|
561
|
+
* Executa uma chamada de ferramenta e retorna o resultado formatado
|
|
562
|
+
*
|
|
563
|
+
* @param toolCall - Objeto de tool_call do LLM (OpenAI, Anthropic ou dict)
|
|
564
|
+
* @param mode - Modo de busca opcional
|
|
565
|
+
* @returns String formatada com os resultados
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```typescript
|
|
569
|
+
* // OpenAI
|
|
570
|
+
* if (response.choices[0].message.tool_calls) {
|
|
571
|
+
* const toolCall = response.choices[0].message.tool_calls[0];
|
|
572
|
+
* const result = await vg.executeToolCall(toolCall);
|
|
573
|
+
* // Passa result de volta para o LLM
|
|
574
|
+
* }
|
|
575
|
+
*
|
|
576
|
+
* // Anthropic
|
|
577
|
+
* for (const block of response.content) {
|
|
578
|
+
* if (block.type === 'tool_use') {
|
|
579
|
+
* const result = await vg.executeToolCall(block);
|
|
580
|
+
* }
|
|
581
|
+
* }
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
executeToolCall(toolCall: unknown, mode?: SearchOptions['mode']): Promise<string>;
|
|
585
|
+
/**
|
|
586
|
+
* Extrai argumentos de diferentes formatos de tool_call
|
|
587
|
+
*/
|
|
588
|
+
private extractToolArguments;
|
|
589
|
+
/**
|
|
590
|
+
* Formata resultado da busca para retornar ao LLM
|
|
591
|
+
*/
|
|
592
|
+
private formatToolResponse;
|
|
593
|
+
/**
|
|
594
|
+
* Lista os documentos disponíveis
|
|
595
|
+
*
|
|
596
|
+
* @param options - Opções de paginação
|
|
597
|
+
* @returns Lista paginada de documentos
|
|
598
|
+
*/
|
|
599
|
+
listDocuments(options?: ListDocumentsOptions): Promise<DocumentsResponse>;
|
|
600
|
+
/**
|
|
601
|
+
* Obtém detalhes de um documento específico
|
|
602
|
+
*
|
|
603
|
+
* @param documentId - ID do documento
|
|
604
|
+
* @returns Detalhes do documento
|
|
605
|
+
*/
|
|
606
|
+
getDocument(documentId: string): Promise<DocumentSummary>;
|
|
607
|
+
/**
|
|
608
|
+
* Obtém o status de uma ingestão
|
|
609
|
+
*
|
|
610
|
+
* @param taskId - ID da task de ingestão
|
|
611
|
+
* @returns Status da ingestão
|
|
612
|
+
*/
|
|
613
|
+
getIngestStatus(taskId: string): Promise<IngestStatus>;
|
|
614
|
+
/**
|
|
615
|
+
* Inicia o enriquecimento de um documento
|
|
616
|
+
*
|
|
617
|
+
* @param documentId - ID do documento
|
|
618
|
+
* @returns ID da task de enriquecimento
|
|
619
|
+
*/
|
|
620
|
+
startEnrichment(documentId: string): Promise<{
|
|
621
|
+
taskId: string;
|
|
622
|
+
message: string;
|
|
623
|
+
}>;
|
|
624
|
+
/**
|
|
625
|
+
* Obtém o status de um enriquecimento
|
|
626
|
+
*
|
|
627
|
+
* @param taskId - ID da task de enriquecimento
|
|
628
|
+
* @returns Status do enriquecimento
|
|
629
|
+
*/
|
|
630
|
+
getEnrichmentStatus(taskId: string): Promise<EnrichStatus>;
|
|
631
|
+
/**
|
|
632
|
+
* Deleta um documento
|
|
633
|
+
*
|
|
634
|
+
* @param documentId - ID do documento
|
|
635
|
+
* @returns Resultado da deleção
|
|
636
|
+
*/
|
|
637
|
+
deleteDocument(documentId: string): Promise<DeleteResponse>;
|
|
289
638
|
/**
|
|
290
639
|
* Obtém os logs de auditoria da conta
|
|
291
640
|
*
|
|
@@ -342,6 +691,14 @@ declare class VectorGov {
|
|
|
342
691
|
* ```
|
|
343
692
|
*/
|
|
344
693
|
getAuditEventTypes(): Promise<string[]>;
|
|
694
|
+
/**
|
|
695
|
+
* Converte hits para formato de mensagens de chat
|
|
696
|
+
*/
|
|
697
|
+
private hitsToMessages;
|
|
698
|
+
/**
|
|
699
|
+
* Converte hits para texto de contexto
|
|
700
|
+
*/
|
|
701
|
+
private hitsToContext;
|
|
345
702
|
}
|
|
346
703
|
|
|
347
|
-
export { type AskMetadata, type AskOptions, type AskResponse, type AuditLog, type AuditLogsOptions, type AuditLogsResponse, type AuditStats, AuthenticationError, type ChatMessage, type Citation, type FeedbackResponse, RateLimitError, type SearchHit, type SearchMetadata, type SearchMode, type SearchOptions, type SearchResult, VectorGov, type VectorGovConfig, VectorGovError };
|
|
704
|
+
export { type AnthropicTool, type AskMetadata, type AskOptions, type AskResponse, type AuditLog, type AuditLogsOptions, type AuditLogsResponse, type AuditStats, AuthenticationError, type ChatMessage, type Citation, type DeleteResponse, type DocumentSummary, type DocumentsResponse, type EnrichStatus, type FeedbackResponse, type GoogleTool, type IngestStatus, type ListDocumentsOptions, type OpenAITool, RateLimitError, type SearchHit, type SearchMetadata, type SearchMode, type SearchOptions, type SearchResult, type StoreResponseOptions, type StoreResponseResult, type StreamChunk, type SystemPromptStyle, type UploadResponse, VectorGov, type VectorGovConfig, VectorGovError };
|