@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,EAAE,MAAM,eAAe,CAAC;AACzC,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;IAsDvD,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAuEtE,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"}
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
- const config = await this.use(new oAddress('o://secure-storage'), {
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
- const payload = config.result.data;
77
- if (payload && payload.value) {
78
- const modelProvider = payload.value;
79
- return {
80
- provider: modelProvider,
81
- };
82
- }
83
- // we need to ask the human for the model provider
84
- this.logger.info('Asking human for model selection');
85
- const modelResponse = await this.use(new oAddress('o://human'), {
86
- method: 'question',
87
- params: {
88
- question: 'Which AI model do you want to use? (anthropic, openai, ollama, perplexity, grok)',
89
- },
90
- });
91
- // process the human response
92
- const { answer: model } = modelResponse.result.data;
93
- await this.use(new oAddress('o://secure-storage'), {
94
- method: 'put',
95
- params: {
96
- key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
97
- value: model,
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
- const config = await this.use(new oAddress('o://secure-storage'), {
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
- const payload = config.result.data;
147
- if (payload && payload.value) {
148
- const apiKey = payload.value;
149
- return {
150
- apiKey,
151
- };
152
- }
153
- // we need to ask the human for the api key
154
- const keyResponse = await this.use(new oAddress('o://human'), {
155
- method: 'question',
156
- params: {
157
- question: `What is the API key for the ${provider} model?`,
158
- },
159
- });
160
- // process the human response
161
- const { answer: key } = keyResponse.result.data;
162
- await this.use(new oAddress('o://secure-storage'), {
163
- method: 'put',
164
- params: {
165
- key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
166
- value: key,
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: key,
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.1",
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.1",
62
- "@olane/o-core": "^0.6.1",
63
- "@olane/o-protocol": "^0.6.1",
64
- "@olane/o-tool": "^0.6.1"
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",