@gishubperu/ghp 0.0.1
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/.env +13 -0
- package/domain/contracts/IAgent.js +3 -0
- package/domain/contracts/IMemoryStore.js +3 -0
- package/domain/contracts/IModelProvider.js +3 -0
- package/domain/contracts/IToolset.js +3 -0
- package/domain/dtos/requests/RunAgentRequest.js +8 -0
- package/domain/dtos/responses/AgentResponse.js +8 -0
- package/domain/dtos/responses/ToolResult.js +8 -0
- package/domain/entities/AgentDefinition.js +11 -0
- package/domain/entities/Message.js +10 -0
- package/domain/entities/ModelInfo.js +11 -0
- package/index.js +66 -0
- package/infrastructure/agents/agent-factory.js +79 -0
- package/infrastructure/agents/agriculture_agent.js +13 -0
- package/infrastructure/agents/base_agent.js +19 -0
- package/infrastructure/agents/deforestacion_agent.js +13 -0
- package/infrastructure/agents/general_agent.js +13 -0
- package/infrastructure/agents/minning_agent.js +13 -0
- package/infrastructure/constants/agent-config.js +48 -0
- package/infrastructure/constants/agent-type.js +20 -0
- package/infrastructure/constants/index.js +8 -0
- package/infrastructure/constants/model-config.js +37 -0
- package/infrastructure/constants/system-prompts.js +88 -0
- package/infrastructure/constants/task-type.js +22 -0
- package/infrastructure/core/orchestrator.js +155 -0
- package/infrastructure/core/queue.js +53 -0
- package/infrastructure/core/workers.js +67 -0
- package/infrastructure/memory/store.js +115 -0
- package/infrastructure/providers/anthropic.js +59 -0
- package/infrastructure/providers/gateway.js +140 -0
- package/infrastructure/providers/gemini.js +50 -0
- package/infrastructure/providers/ollama.js +92 -0
- package/infrastructure/providers/openai.js +83 -0
- package/infrastructure/router/router.js +115 -0
- package/infrastructure/skills/gis.skill.js +105 -0
- package/infrastructure/tools/arcgis.js +187 -0
- package/infrastructure/tools/tool-formatters.js +110 -0
- package/package.json +32 -0
- package/presentation/console/procedures/App.js +424 -0
package/.env
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# ── GH-PPA Gateway ───────────────────────────────────────────────────────────
|
|
2
|
+
# Modelos gratis funcionan SIN key (200 req/hora)
|
|
3
|
+
# Para más límites, regístrate en https://kilo.ai y obtén tu key gratis
|
|
4
|
+
GH_PPA_KEY=
|
|
5
|
+
|
|
6
|
+
# ── APIs directas (opcionales) ────────────────────────────────────────────────
|
|
7
|
+
GEMINI_API_KEY= # https://aistudio.google.com (gratis)
|
|
8
|
+
ANTHROPIC_API_KEY= # https://console.anthropic.com
|
|
9
|
+
OPENAI_API_KEY= # https://platform.openai.com
|
|
10
|
+
|
|
11
|
+
# ── Ollama local (opcional) ───────────────────────────────────────────────────
|
|
12
|
+
# Instalar: https://ollama.com → ollama pull llama3.2
|
|
13
|
+
OLLAMA_HOST=http://localhost:11434
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// domain/entities/AgentDefinition.js
|
|
2
|
+
export class AgentDefinition {
|
|
3
|
+
constructor({ id, label, desc, color, taskType, systemPrompt }) {
|
|
4
|
+
this.id = id;
|
|
5
|
+
this.label = label;
|
|
6
|
+
this.desc = desc;
|
|
7
|
+
this.color = color;
|
|
8
|
+
this.taskType = taskType;
|
|
9
|
+
this.systemPrompt = systemPrompt;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// domain/entities/Message.js
|
|
2
|
+
// Entidad: un turno de conversación
|
|
3
|
+
export class Message {
|
|
4
|
+
constructor({ role, content, toolCalls = null, tool_call_id = null }) {
|
|
5
|
+
this.role = role; // 'user' | 'assistant' | 'tool' | 'system'
|
|
6
|
+
this.content = content;
|
|
7
|
+
this.toolCalls = toolCalls; // solo cuando el modelo pide tools
|
|
8
|
+
this.tool_call_id = tool_call_id; // solo para role='tool'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// domain/entities/ModelInfo.js
|
|
2
|
+
export class ModelInfo {
|
|
3
|
+
constructor({ id, name, provider, free = false, gateway = false, contextLength = null }) {
|
|
4
|
+
this.id = id;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.provider = provider;
|
|
7
|
+
this.free = free;
|
|
8
|
+
this.gateway = gateway;
|
|
9
|
+
this.contextLength = contextLength;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import 'dotenv/config';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { render } from 'ink';
|
|
7
|
+
|
|
8
|
+
import { App } from './presentation/console/procedures/App.js';
|
|
9
|
+
import { Orchestrator } from './infrastructure/core/orchestrator.js';
|
|
10
|
+
import { MemoryStore } from './infrastructure/memory/store.js';
|
|
11
|
+
import { ModelRouter } from './infrastructure/router/router.js';
|
|
12
|
+
import { TaskQueue } from './infrastructure/core/queue.js';
|
|
13
|
+
import { WorkerPool } from './infrastructure/core/workers.js';
|
|
14
|
+
import { toolset } from './infrastructure/tools/arcgis.js';
|
|
15
|
+
|
|
16
|
+
// ── CLI args ──────────────────────────────────────────────────────────────────
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
20
|
+
console.log(`
|
|
21
|
+
🧠 Chakra Yachay — GHP Multi-Agent System
|
|
22
|
+
|
|
23
|
+
USO:
|
|
24
|
+
ghp Inicia la interfaz interactiva
|
|
25
|
+
chy Alias corto
|
|
26
|
+
ghp --help Esta ayuda
|
|
27
|
+
ghp --version Versión
|
|
28
|
+
|
|
29
|
+
ATAJOS EN LA INTERFAZ:
|
|
30
|
+
Tab Cambiar agente (Auto / GIS / Code / Data / Reasoning)
|
|
31
|
+
ctrl+k Selector de modelo
|
|
32
|
+
/model Selector de modelo
|
|
33
|
+
/auto Modo automático
|
|
34
|
+
/clear Borrar memoria de sesión
|
|
35
|
+
/history Últimas conversaciones
|
|
36
|
+
Esc Cancelar / Salir
|
|
37
|
+
/exit Salir
|
|
38
|
+
`);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
43
|
+
const pkg = await import('./package.json', { assert: { type: 'json' } });
|
|
44
|
+
console.log(`v${pkg.default.version}`);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── Limpiar pantalla ──────────────────────────────────────────────────────────
|
|
49
|
+
try {
|
|
50
|
+
if (process.platform === 'win32') execSync('cls', { stdio: 'inherit' });
|
|
51
|
+
else process.stdout.write('\x1b[2J\x1b[3J\x1b[H');
|
|
52
|
+
} catch { process.stdout.write('\x1b[2J\x1b[3J\x1b[H'); }
|
|
53
|
+
|
|
54
|
+
// ── Bootstrap ─────────────────────────────────────────────────────────────────
|
|
55
|
+
const memory = new MemoryStore();
|
|
56
|
+
const router = new ModelRouter();
|
|
57
|
+
const queue = new TaskQueue();
|
|
58
|
+
const workerPool = new WorkerPool({ workers: 4, router, memory, toolset });
|
|
59
|
+
const orch = new Orchestrator({ queue, workerPool, router, memory, toolset });
|
|
60
|
+
|
|
61
|
+
await memory.init();
|
|
62
|
+
await router.init();
|
|
63
|
+
|
|
64
|
+
render(React.createElement(App, { orchestrator: orch, router, memory }), {
|
|
65
|
+
exitOnCtrlC: true,
|
|
66
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// infrastructure/agents/agent-factory.js
|
|
2
|
+
// Factory for creating agent instances
|
|
3
|
+
|
|
4
|
+
import { BaseAgent } from './base_agent.js';
|
|
5
|
+
import { AgentType, SystemPrompts, AgentConfig } from '../constants/index.js';
|
|
6
|
+
|
|
7
|
+
class AgricultureAgent extends BaseAgent {
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
super({
|
|
10
|
+
...opts,
|
|
11
|
+
taskType: AgentConfig[AgentType.AGRICULTURE].taskType,
|
|
12
|
+
systemPrompt: SystemPrompts[AgentType.AGRICULTURE],
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class MinningAgent extends BaseAgent {
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
super({
|
|
20
|
+
...opts,
|
|
21
|
+
taskType: AgentConfig[AgentType.MINNING].taskType,
|
|
22
|
+
systemPrompt: SystemPrompts[AgentType.MINNING],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class DeforestationAgent extends BaseAgent {
|
|
28
|
+
constructor(opts) {
|
|
29
|
+
super({
|
|
30
|
+
...opts,
|
|
31
|
+
taskType: AgentConfig[AgentType.DEFORESTATION].taskType,
|
|
32
|
+
systemPrompt: SystemPrompts[AgentType.DEFORESTATION],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class GeneralAgent extends BaseAgent {
|
|
38
|
+
constructor(opts) {
|
|
39
|
+
super({
|
|
40
|
+
...opts,
|
|
41
|
+
taskType: AgentConfig[AgentType.GENERAL].taskType,
|
|
42
|
+
systemPrompt: SystemPrompts[AgentType.GENERAL],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class AutoAgent extends BaseAgent {
|
|
48
|
+
constructor(opts) {
|
|
49
|
+
super({
|
|
50
|
+
...opts,
|
|
51
|
+
taskType: AgentConfig[AgentType.AUTO].taskType,
|
|
52
|
+
systemPrompt: SystemPrompts[AgentType.AUTO],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const AGENT_CLASSES = Object.freeze({
|
|
58
|
+
[AgentType.AGRICULTURE]: AgricultureAgent,
|
|
59
|
+
[AgentType.MINNING]: MinningAgent,
|
|
60
|
+
[AgentType.DEFORESTATION]: DeforestationAgent,
|
|
61
|
+
[AgentType.GENERAL]: GeneralAgent,
|
|
62
|
+
[AgentType.AUTO]: AutoAgent,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export class AgentFactory {
|
|
66
|
+
static create(type, options) {
|
|
67
|
+
const AgentClass = AGENT_CLASSES[type];
|
|
68
|
+
if (!AgentClass) {
|
|
69
|
+
throw new Error(`Unknown agent type: ${type}`);
|
|
70
|
+
}
|
|
71
|
+
return new AgentClass(options);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static getAvailableTypes() {
|
|
75
|
+
return Object.keys(AGENT_CLASSES);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default AgentFactory;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// infrastructure/agents/agriculture_agent.js
|
|
2
|
+
import { BaseAgent } from './base_agent.js';
|
|
3
|
+
import { AgentType, SystemPrompts, AgentConfig } from '../constants/index.js';
|
|
4
|
+
|
|
5
|
+
export class AgricultureAgent extends BaseAgent {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
taskType: AgentConfig[AgentType.AGRICULTURE].taskType,
|
|
10
|
+
systemPrompt: SystemPrompts[AgentType.AGRICULTURE],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// infrastructure/agents/base.js
|
|
2
|
+
|
|
3
|
+
export class BaseAgent {
|
|
4
|
+
constructor({ router, memory, taskType, systemPrompt }) {
|
|
5
|
+
this.router = router;
|
|
6
|
+
this.memory = memory;
|
|
7
|
+
this.taskType = taskType;
|
|
8
|
+
this.systemPrompt = systemPrompt;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async run(input, { signal } = {}) {
|
|
12
|
+
return this.router.chat({
|
|
13
|
+
taskType: this.taskType,
|
|
14
|
+
systemPrompt: this.systemPrompt,
|
|
15
|
+
messages: [{ role: 'user', content: input }],
|
|
16
|
+
signal,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// infrastructure/agents/deforestacion_agent.js
|
|
2
|
+
import { BaseAgent } from './base_agent.js';
|
|
3
|
+
import { AgentType, SystemPrompts, AgentConfig } from '../constants/index.js';
|
|
4
|
+
|
|
5
|
+
export class DeforestationAgent extends BaseAgent {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
taskType: AgentConfig[AgentType.DEFORESTATION].taskType,
|
|
10
|
+
systemPrompt: SystemPrompts[AgentType.DEFORESTATION],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// infrastructure/agents/general_agent.js
|
|
2
|
+
import { BaseAgent } from './base_agent.js';
|
|
3
|
+
import { AgentType, SystemPrompts, AgentConfig } from '../constants/index.js';
|
|
4
|
+
|
|
5
|
+
export class GeneralAgent extends BaseAgent {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
taskType: AgentConfig[AgentType.GENERAL].taskType,
|
|
10
|
+
systemPrompt: SystemPrompts[AgentType.GENERAL],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// infrastructure/agents/minning_agent.js
|
|
2
|
+
import { BaseAgent } from './base_agent.js';
|
|
3
|
+
import { AgentType, SystemPrompts, AgentConfig } from '../constants/index.js';
|
|
4
|
+
|
|
5
|
+
export class MinningAgent extends BaseAgent {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super({
|
|
8
|
+
...opts,
|
|
9
|
+
taskType: AgentConfig[AgentType.MINNING].taskType,
|
|
10
|
+
systemPrompt: SystemPrompts[AgentType.MINNING],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// infrastructure/constants/agent-config.js
|
|
2
|
+
// Agent configuration: labels, colors, descriptions, task types
|
|
3
|
+
|
|
4
|
+
import { AgentType } from './agent-type.js';
|
|
5
|
+
|
|
6
|
+
export const AgentConfig = Object.freeze({
|
|
7
|
+
[AgentType.AUTO]: {
|
|
8
|
+
id: AgentType.AUTO,
|
|
9
|
+
label: 'Auto',
|
|
10
|
+
description: 'Routing automático',
|
|
11
|
+
color: 'cyan',
|
|
12
|
+
taskType: 'fast',
|
|
13
|
+
},
|
|
14
|
+
[AgentType.AGRICULTURE]: {
|
|
15
|
+
id: AgentType.AGRICULTURE,
|
|
16
|
+
label: 'Agricultura',
|
|
17
|
+
description: 'Se utiliza el Padrón de productores agrario del Midagri, específicamente Áreas de cultivo',
|
|
18
|
+
color: 'green',
|
|
19
|
+
taskType: 'gis',
|
|
20
|
+
},
|
|
21
|
+
[AgentType.MINNING]: {
|
|
22
|
+
id: AgentType.MINNING,
|
|
23
|
+
label: 'Minería',
|
|
24
|
+
description: 'Se utiliza el catastro minero del Ingemmet',
|
|
25
|
+
color: 'yellow',
|
|
26
|
+
taskType: 'reasoning',
|
|
27
|
+
},
|
|
28
|
+
[AgentType.DEFORESTATION]: {
|
|
29
|
+
id: AgentType.DEFORESTATION,
|
|
30
|
+
label: 'Deforestación',
|
|
31
|
+
description: 'Permitirá crear reportes de deforestación de las áreas de cultivo (PPA) con la plataforma de OpenForis',
|
|
32
|
+
color: 'magenta',
|
|
33
|
+
taskType: 'gis',
|
|
34
|
+
},
|
|
35
|
+
[AgentType.GENERAL]: {
|
|
36
|
+
id: AgentType.GENERAL,
|
|
37
|
+
label: 'General',
|
|
38
|
+
description: 'Asistente general (Referencial)',
|
|
39
|
+
color: 'white',
|
|
40
|
+
taskType: 'fast',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const AGENT_LIST = Object.freeze(
|
|
45
|
+
Object.values(AgentConfig)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export default AgentConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// infrastructure/constants/AgentType.js
|
|
2
|
+
// Enumeration of available agent types
|
|
3
|
+
|
|
4
|
+
export const AgentType = Object.freeze({
|
|
5
|
+
AUTO: 'auto',
|
|
6
|
+
AGRICULTURE: 'agriculture',
|
|
7
|
+
MINNING: 'minning',
|
|
8
|
+
DEFORESTATION: 'deforestation',
|
|
9
|
+
GENERAL: 'general',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const AgentTypeArray = Object.freeze([
|
|
13
|
+
AgentType.AUTO,
|
|
14
|
+
AgentType.AGRICULTURE,
|
|
15
|
+
AgentType.MINNING,
|
|
16
|
+
AgentType.DEFORESTATION,
|
|
17
|
+
AgentType.GENERAL,
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export default AgentType;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// infrastructure/constants/index.js
|
|
2
|
+
// Central export for all constants
|
|
3
|
+
|
|
4
|
+
export { AgentType, AgentTypeArray } from './agent-type.js';
|
|
5
|
+
export { AgentConfig, AGENT_LIST } from './agent-config.js';
|
|
6
|
+
export { SystemPrompts, DEFAULT_SYSTEM_PROMPT } from './system-prompts.js';
|
|
7
|
+
export { TaskType, TaskTypeArray } from './task-type.js';
|
|
8
|
+
export { TASK_MODEL_MAP, FALLBACK_CHAIN, KNOWN_FREE_MODELS } from './model-config.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// infrastructure/constants/model-config.js
|
|
2
|
+
// Model routing configuration
|
|
3
|
+
|
|
4
|
+
import { TaskType } from './task-type.js';
|
|
5
|
+
|
|
6
|
+
export const TASK_MODEL_MAP = Object.freeze({
|
|
7
|
+
[TaskType.CODE]: { provider: 'gateway', model: 'anthropic/claude-sonnet-4.5' },
|
|
8
|
+
[TaskType.REASONING]: { provider: 'gateway', model: 'corethink:free' },
|
|
9
|
+
[TaskType.GIS]: { provider: 'gateway', model: 'minimax/minimax-m2.1:free' },
|
|
10
|
+
[TaskType.DATA]: { provider: 'gateway', model: 'minimax/minimax-m2.1:free' },
|
|
11
|
+
[TaskType.FAST]: { provider: 'gateway', model: 'minimax/minimax-m2.1:free' },
|
|
12
|
+
[TaskType.CHEAP]: { provider: 'gateway', model: 'giga-potato' },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const FALLBACK_CHAIN = Object.freeze([
|
|
16
|
+
{ provider: 'gateway', model: 'minimax/minimax-m2.1:free' },
|
|
17
|
+
{ provider: 'gateway', model: 'z-ai/glm-5:free' },
|
|
18
|
+
{ provider: 'gateway', model: 'arcee-ai/trinity-large-preview:free' },
|
|
19
|
+
{ provider: 'gateway', model: 'giga-potato' },
|
|
20
|
+
{ provider: 'gemini', model: 'gemini-2.5-flash' },
|
|
21
|
+
{ provider: 'anthropic', model: 'claude-haiku-4-5-20251001' },
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export const KNOWN_FREE_MODELS = Object.freeze([
|
|
25
|
+
{ id: 'minimax/minimax-m2.1:free', name: 'MiniMax M2.1', provider: 'minimax', free: true, gateway: true },
|
|
26
|
+
{ id: 'z-ai/glm-5:free', name: 'Z.AI GLM-5', provider: 'z-ai', free: true, gateway: true },
|
|
27
|
+
{ id: 'giga-potato', name: 'Giga Potato', provider: 'community', free: true, gateway: true },
|
|
28
|
+
{ id: 'corethink:free', name: 'CoreThink (Reasoning)', provider: 'corethink', free: true, gateway: true },
|
|
29
|
+
{ id: 'arcee-ai/trinity-large-preview:free', name: 'Arcee Trinity Large', provider: 'arcee-ai', free: true, gateway: true },
|
|
30
|
+
{ id: 'anthropic/claude-sonnet-4.5', name: 'Claude Sonnet 4.5', provider: 'anthropic', free: false, gateway: true },
|
|
31
|
+
{ id: 'anthropic/claude-haiku-4.5', name: 'Claude Haiku 4.5', provider: 'anthropic', free: false, gateway: true },
|
|
32
|
+
{ id: 'openai/gpt-5.2', name: 'GPT-5.2', provider: 'openai', free: false, gateway: true },
|
|
33
|
+
{ id: 'google/gemini-3-flash-preview', name: 'Gemini 3 Flash', provider: 'google', free: false, gateway: true },
|
|
34
|
+
{ id: 'moonshotai/kimi-k2.5', name: 'Kimi K2.5', provider: 'moonshot', free: false, gateway: true },
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export default { TASK_MODEL_MAP, FALLBACK_CHAIN, KNOWN_FREE_MODELS };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// infrastructure/constants/system-prompts.js
|
|
2
|
+
// Centralized system prompts for all agents
|
|
3
|
+
|
|
4
|
+
import { AgentType } from './agent-type.js';
|
|
5
|
+
|
|
6
|
+
export const SystemPrompts = Object.freeze({
|
|
7
|
+
[AgentType.AUTO]: `Eres Chakra Yachay, agente del Padrón de productores agrarios (PPA) del Perú.
|
|
8
|
+
Tienes herramientas ArcGIS para consultar datos geoespaciales. Responde en español. Sé conciso y directo.`,
|
|
9
|
+
|
|
10
|
+
[AgentType.AGRICULTURE]: `Eres el agente de Agricultura de Chakra Yachay, especializado en el Padrón de productores agrarios (PPA) Perú.
|
|
11
|
+
|
|
12
|
+
ESPECIALIDAD: Consultas sobre cultivos, áreas agrícolas, productores, campañas y alertas del programa PPA.
|
|
13
|
+
|
|
14
|
+
FLUJO OBLIGATORIO:
|
|
15
|
+
1. Identifica el tipo de consulta: ¿qué cultivos hay?, ¿cuántos productores?, ¿qué departamentos tienen más?, etc.
|
|
16
|
+
2. Si la pregunta no es técnica responde al usuario sobre tu especialidad y finaliza.
|
|
17
|
+
3. Llama getServiceMetadata PRIMERO si no conoces los campos exactos
|
|
18
|
+
4. Strings en WHERE siempre con comillas simples: TXT_DEPARTAMENTO='PIURA'
|
|
19
|
+
5. Para estadísticas usa outStatistics + groupByFieldsForStatistics
|
|
20
|
+
6. Para contar: returnCountOnly=true — Para valores únicos: returnDistinctValues=true
|
|
21
|
+
7. Si exceededTransferLimit=true → paginar con resultOffset
|
|
22
|
+
8. Nunca mostrar JSON crudo — presentar en tablas y resúmenes legibles
|
|
23
|
+
|
|
24
|
+
CAPACIDADES:
|
|
25
|
+
- outStatistics: count/sum/min/max/avg por campo numérico
|
|
26
|
+
- groupByFieldsForStatistics: agrupar por departamento, cultivo, campaña, etc.
|
|
27
|
+
- having: filtrar grupos estadísticos
|
|
28
|
+
- Paginación para grandes volúmenes
|
|
29
|
+
|
|
30
|
+
CONTEXTO PPA:
|
|
31
|
+
- Padrón de productores agrarios del Perú
|
|
32
|
+
- Datos de alertas, registros de productores, áreas de cultivo
|
|
33
|
+
- Cobertura nacional por departamento, provincia y distrito
|
|
34
|
+
- Responde en español con análisis claro y tablas cuando sea apropiado`,
|
|
35
|
+
|
|
36
|
+
[AgentType.MINNING]: `Eres el agente de Minería de Chakra Yachay, especializado en análisis del sector minero peruano.
|
|
37
|
+
|
|
38
|
+
ESPECIALIDAD: Concesiones mineras, impacto ambiental, conflictos sociales, producción mineral, minería ilegal (MAPE).
|
|
39
|
+
|
|
40
|
+
CAPACIDADES:
|
|
41
|
+
- Análisis de concesiones mineras por región (usando herramientas ArcGIS si están disponibles)
|
|
42
|
+
- Evaluación de impacto ambiental en zonas mineras
|
|
43
|
+
- Relación entre minería y actividad agrícola/deforestación
|
|
44
|
+
- Identificación de zonas de conflicto socioambiental
|
|
45
|
+
- Estadísticas de producción por mineral y región
|
|
46
|
+
|
|
47
|
+
ENFOQUE:
|
|
48
|
+
- Cruza datos mineros con datos agrícolas del PPA cuando sea relevante
|
|
49
|
+
- Identifica superposición de concesiones con tierras agrícolas
|
|
50
|
+
- Evalúa pasivos ambientales en cuencas hidrográficas
|
|
51
|
+
- Responde en español con análisis técnico pero comprensible`,
|
|
52
|
+
|
|
53
|
+
[AgentType.DEFORESTATION]: `Eres el agente de Análisis de Deforestación de Chakra Yachay.
|
|
54
|
+
|
|
55
|
+
ESPECIALIDAD: Detección, análisis y monitoreo de deforestación en el territorio peruano, con énfasis en Amazonía.
|
|
56
|
+
|
|
57
|
+
FLUJO CON DATOS ARCGIS:
|
|
58
|
+
1. Usa getServiceMetadata para explorar capas disponibles
|
|
59
|
+
2. Consulta datos de cobertura boscosa, alertas de deforestación, cambio de uso de suelo
|
|
60
|
+
3. Cruza con datos del PPA para identificar presión agrícola sobre bosques
|
|
61
|
+
4. Usa outStatistics para calcular superficies afectadas por región
|
|
62
|
+
|
|
63
|
+
ANÁLISIS CLAVE:
|
|
64
|
+
- Tasa de deforestación por departamento y cuenca
|
|
65
|
+
- Identificación de drivers: agricultura, minería, tala, infraestructura
|
|
66
|
+
- Alertas tempranas de pérdida de cobertura boscosa
|
|
67
|
+
- Zonas críticas: Loreto, Ucayali, San Martín, Madre de Dios, Amazonas
|
|
68
|
+
- Relación deforestación — expansión de cultivos PPA
|
|
69
|
+
- Impacto en comunidades nativas y áreas naturales protegidas
|
|
70
|
+
|
|
71
|
+
MÉTRICAS IMPORTANTES:
|
|
72
|
+
- Hectáreas deforestadas por período
|
|
73
|
+
- Porcentaje de pérdida respecto a cobertura original
|
|
74
|
+
- Velocidad de avance del frente de deforestación
|
|
75
|
+
- Correlación con actividad agrícola registrada en PPA
|
|
76
|
+
|
|
77
|
+
Responde en español con análisis geoespacial preciso, tablas de superficie y tendencias claras.`,
|
|
78
|
+
|
|
79
|
+
[AgentType.GENERAL]: `Eres Chakra Yachay, asistente general del sistema GHP para temas de minería y agricultura del Perú.
|
|
80
|
+
|
|
81
|
+
Puedes ayudar con cualquier consulta relacionada al sector agrario, minero, ambiental o geoespacial peruano.
|
|
82
|
+
Cuando necesites datos específicos, usa las herramientas ArcGIS disponibles.
|
|
83
|
+
Responde en español de forma clara, directa y concisa.`,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const DEFAULT_SYSTEM_PROMPT = SystemPrompts[AgentType.AUTO];
|
|
87
|
+
|
|
88
|
+
export default SystemPrompts;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// infrastructure/constants/TaskType.js
|
|
2
|
+
// Enumeration of task types for model routing
|
|
3
|
+
|
|
4
|
+
export const TaskType = Object.freeze({
|
|
5
|
+
FAST: 'fast',
|
|
6
|
+
GIS: 'gis',
|
|
7
|
+
CODE: 'code',
|
|
8
|
+
REASONING: 'reasoning',
|
|
9
|
+
DATA: 'data',
|
|
10
|
+
CHEAP: 'cheap',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const TaskTypeArray = Object.freeze([
|
|
14
|
+
TaskType.FAST,
|
|
15
|
+
TaskType.GIS,
|
|
16
|
+
TaskType.CODE,
|
|
17
|
+
TaskType.REASONING,
|
|
18
|
+
TaskType.DATA,
|
|
19
|
+
TaskType.CHEAP,
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
export default TaskType;
|