goblin-agents 2.3.0 → 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 +25 -7
  2. package/package.json +1 -1
@@ -134,10 +134,7 @@ function cleanText(text) {
134
134
  if (typeof text !== 'string') {
135
135
  return text;
136
136
  }
137
- const {thinks, cleanText} = splitThinkTags(text);
138
- for (const think of thinks) {
139
- this.log.dbg(`🧐 ${think}`);
140
- }
137
+ const {cleanText} = splitThinkTags(text);
141
138
  return cleanText;
142
139
  }
143
140
 
@@ -149,6 +146,7 @@ class AiAgentShape {
149
146
  prompt = string; //default prompt
150
147
  provider = enumeration('ollama', 'open-ai');
151
148
  model = string;
149
+ otherModels = array(string);
152
150
  host = string;
153
151
  headers = record(string, string);
154
152
  messages = record(string, array(MessageShape)); //for keeping chat history by context
@@ -170,6 +168,7 @@ const defaultValues = {
170
168
  role: 'assistant',
171
169
  provider: 'open-ai',
172
170
  model: '',
171
+ otherModels: [],
173
172
  options: {},
174
173
  host: 'http://127.0.0.1:11434',
175
174
  headers: {},
@@ -193,6 +192,7 @@ class AiAgentLogic extends Elf.Archetype {
193
192
  prompt: defaultValues.prompt,
194
193
  provider: defaultValues.provider,
195
194
  model: defaultValues.model,
195
+ otherModels: defaultValues.otherModels,
196
196
  messages: {},
197
197
  options: defaultValues.options,
198
198
  host: defaultValues.host,
@@ -291,6 +291,12 @@ class AiAgentLogic extends Elf.Archetype {
291
291
  state._state.set(path, newValue);
292
292
  }
293
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
+
294
300
  publish() {
295
301
  const {state} = this;
296
302
  state.meta.status = 'published';
@@ -381,6 +387,18 @@ class AiAgent extends Elf {
381
387
  await this.persist();
382
388
  }
383
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
+
384
402
  async gen(prompt, contextId = 'default') {
385
403
  const logger = Logger.get(contextId, this);
386
404
 
@@ -612,7 +630,7 @@ class AiAgent extends Elf {
612
630
  const res = cleanText(result.message.content);
613
631
  if (typeof res === 'string') {
614
632
  //keep agent response
615
- this.logic.chat(contextId, 'assistant', cleanText);
633
+ this.logic.chat(contextId, 'assistant', res);
616
634
  }
617
635
 
618
636
  this.log.dbg(`🐈 Chat session ended : ${contextId}`);
@@ -872,8 +890,8 @@ class AiAgent extends Elf {
872
890
  }
873
891
 
874
892
  async getBaseSettings() {
875
- const {provider, host, headers, model} = this.state.toJS();
876
- return {provider, host, headers, model};
893
+ const {provider, host, headers, model, otherModels} = this.state.toJS();
894
+ return {provider, host, headers, model, otherModels};
877
895
  }
878
896
 
879
897
  async trash() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-agents",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "AI Agents framework",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [