goblin-agents 2.3.1 → 2.4.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.
Files changed (2) hide show
  1. package/lib/llm/aiAgent.js +23 -2
  2. package/package.json +1 -1
@@ -146,6 +146,7 @@ class AiAgentShape {
146
146
  prompt = string; //default prompt
147
147
  provider = enumeration('ollama', 'open-ai');
148
148
  model = string;
149
+ otherModels = array(string);
149
150
  host = string;
150
151
  headers = record(string, string);
151
152
  messages = record(string, array(MessageShape)); //for keeping chat history by context
@@ -167,6 +168,7 @@ const defaultValues = {
167
168
  role: 'assistant',
168
169
  provider: 'open-ai',
169
170
  model: '',
171
+ otherModels: [],
170
172
  options: {},
171
173
  host: 'http://127.0.0.1:11434',
172
174
  headers: {},
@@ -190,6 +192,7 @@ class AiAgentLogic extends Elf.Archetype {
190
192
  prompt: defaultValues.prompt,
191
193
  provider: defaultValues.provider,
192
194
  model: defaultValues.model,
195
+ otherModels: defaultValues.otherModels,
193
196
  messages: {},
194
197
  options: defaultValues.options,
195
198
  host: defaultValues.host,
@@ -288,6 +291,12 @@ class AiAgentLogic extends Elf.Archetype {
288
291
  state._state.set(path, newValue);
289
292
  }
290
293
 
294
+ useOtherModel(model) {
295
+ this.state.otherModels.deleteByValue(model);
296
+ this.state.otherModels.push(this.state.model);
297
+ this.state.model = model;
298
+ }
299
+
291
300
  publish() {
292
301
  const {state} = this;
293
302
  state.meta.status = 'published';
@@ -378,6 +387,18 @@ class AiAgent extends Elf {
378
387
  await this.persist();
379
388
  }
380
389
 
390
+ async useOtherModel(model) {
391
+ if (!this.state.otherModels.includes(model)) {
392
+ return false;
393
+ }
394
+ this.logic.useOtherModel(model);
395
+ return true;
396
+ }
397
+
398
+ async getModelList() {
399
+ return [this.state.model, ...this.state.otherModels];
400
+ }
401
+
381
402
  async gen(prompt, contextId = 'default') {
382
403
  const logger = Logger.get(contextId, this);
383
404
 
@@ -869,8 +890,8 @@ class AiAgent extends Elf {
869
890
  }
870
891
 
871
892
  async getBaseSettings() {
872
- const {provider, host, headers, model} = this.state.toJS();
873
- return {provider, host, headers, model};
893
+ const {provider, host, headers, model, otherModels} = this.state.toJS();
894
+ return {provider, host, headers, model, otherModels};
874
895
  }
875
896
 
876
897
  async trash() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-agents",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "AI Agents framework",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [