@olane/o-intelligence 0.6.1 → 0.6.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQ3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,eAAe,CAAK;gBAChB,MAAM,EAAE,WAAW;IA0DzB,gBAAgB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,CAAC;IA8DvD,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA2EtE,kBAAkB,CACtB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAW1C,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAkB3D"}
|
|
@@ -66,36 +66,41 @@ export class IntelligenceTool extends oVirtualTool {
|
|
|
66
66
|
}
|
|
67
67
|
throw new Error('Invalid model provider choice, please set the MODEL_PROVIDER_CHOICE environment variable to a valid model provider');
|
|
68
68
|
}
|
|
69
|
+
let model = LLMProviders.ANTHROPIC;
|
|
69
70
|
// check secure storage for preference
|
|
70
|
-
|
|
71
|
+
await this.use(new oAddress('o://secure'), {
|
|
71
72
|
method: 'get',
|
|
72
73
|
params: {
|
|
73
74
|
key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
|
|
74
75
|
},
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
})
|
|
77
|
+
.then((config) => {
|
|
78
|
+
const payload = config.result.data;
|
|
79
|
+
if (payload && payload.value) {
|
|
80
|
+
const modelProvider = payload.value;
|
|
81
|
+
model = modelProvider;
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.catch(async (err) => {
|
|
85
|
+
this.logger.error('Error getting model provider preference: ', err);
|
|
86
|
+
// we need to ask the human for the model provider
|
|
87
|
+
this.logger.info('Asking human for model selection...');
|
|
88
|
+
const modelResponse = await this.use(new oAddress('o://human'), {
|
|
89
|
+
method: 'question',
|
|
90
|
+
params: {
|
|
91
|
+
question: 'Which AI model do you want to use? (anthropic, openai, ollama, perplexity, grok)',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
// process the human response
|
|
95
|
+
const { answer: modelHuman } = modelResponse.result.data;
|
|
96
|
+
model = modelHuman.toLowerCase();
|
|
97
|
+
await this.use(new oAddress('o://secure'), {
|
|
98
|
+
method: 'put',
|
|
99
|
+
params: {
|
|
100
|
+
key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
|
|
101
|
+
value: model,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
99
104
|
});
|
|
100
105
|
return {
|
|
101
106
|
provider: model,
|
|
@@ -136,38 +141,42 @@ export class IntelligenceTool extends oVirtualTool {
|
|
|
136
141
|
apiKey: modelEnvConfig.key,
|
|
137
142
|
};
|
|
138
143
|
}
|
|
144
|
+
let apiKey = '';
|
|
139
145
|
// check secure storage 2nd
|
|
140
|
-
|
|
146
|
+
await this.use(new oAddress('o://secure'), {
|
|
141
147
|
method: 'get',
|
|
142
148
|
params: {
|
|
143
149
|
key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
|
|
144
150
|
},
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
apiKey
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
})
|
|
152
|
+
.then((config) => {
|
|
153
|
+
const payload = config.result.data;
|
|
154
|
+
if (payload && payload.value) {
|
|
155
|
+
const apiKeyStored = payload.value;
|
|
156
|
+
apiKey = apiKeyStored;
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
.catch(async (err) => {
|
|
160
|
+
// we need to ask the human for the api key
|
|
161
|
+
const keyResponse = await this.use(new oAddress('o://human'), {
|
|
162
|
+
method: 'question',
|
|
163
|
+
params: {
|
|
164
|
+
question: `What is the API key for the ${provider} model?`,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
// process the human response
|
|
168
|
+
const { answer: key } = keyResponse.result.data;
|
|
169
|
+
apiKey = key;
|
|
170
|
+
await this.use(new oAddress('o://secure'), {
|
|
171
|
+
method: 'put',
|
|
172
|
+
params: {
|
|
173
|
+
key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
|
|
174
|
+
value: key,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
168
177
|
});
|
|
169
178
|
return {
|
|
170
|
-
apiKey:
|
|
179
|
+
apiKey: apiKey,
|
|
171
180
|
};
|
|
172
181
|
}
|
|
173
182
|
async chooseIntelligence(request) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-intelligence",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -37,10 +37,6 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/eslintrc": "^3.3.1",
|
|
39
39
|
"@eslint/js": "^9.29.0",
|
|
40
|
-
"@olane/o-config": "0.6.1",
|
|
41
|
-
"@olane/o-core": "0.6.1",
|
|
42
|
-
"@olane/o-protocol": "0.6.1",
|
|
43
|
-
"@olane/o-tool": "0.6.1",
|
|
44
40
|
"@tsconfig/node20": "^20.1.6",
|
|
45
41
|
"@types/jest": "^30.0.0",
|
|
46
42
|
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
@@ -58,10 +54,10 @@
|
|
|
58
54
|
"typescript": "5.4.5"
|
|
59
55
|
},
|
|
60
56
|
"peerDependencies": {
|
|
61
|
-
"@olane/o-config": "^0.6.
|
|
62
|
-
"@olane/o-core": "^0.6.
|
|
63
|
-
"@olane/o-protocol": "^0.6.
|
|
64
|
-
"@olane/o-tool": "^0.6.
|
|
57
|
+
"@olane/o-config": "^0.6.2",
|
|
58
|
+
"@olane/o-core": "^0.6.2",
|
|
59
|
+
"@olane/o-protocol": "^0.6.2",
|
|
60
|
+
"@olane/o-tool": "^0.6.2"
|
|
65
61
|
},
|
|
66
62
|
"dependencies": {
|
|
67
63
|
"debug": "^4.4.1",
|