goblin-agents 3.0.1 → 3.1.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.
Files changed (2) hide show
  1. package/lib/llm/aiAgent.js +26 -8
  2. package/package.json +1 -1
@@ -596,16 +596,34 @@ class AiAgent extends Elf {
596
596
 
597
597
  /**
598
598
  * Set chat session context, model and level of reasoning
599
- * @param {*} contextId
600
- * @param {string} context
601
- * @param {string} model
602
- * @param {string} reasoning
599
+ * @param {string} contextId
600
+ * @param {string} [context]
601
+ * @param {string} [model]
602
+ * @param {string|boolean} [reasoning]
603
603
  */
604
604
  async setContext(contextId, context, model, reasoning) {
605
605
  this.logic.setContext(contextId, context, model, reasoning);
606
606
  }
607
607
 
608
- async chat(contextId, question, userDesktopId) {
608
+ /**
609
+ * Retrieves the configuration associated with a chat context.
610
+ *
611
+ * Falls back to the global settings when no context-specific
612
+ * configuration is available.
613
+ *
614
+ * @param {string} contextId - Unique identifier of the chat context.
615
+ * @returns {Promise<{context: string, model: string, reasoning: string|boolean}>}
616
+ * The context content, selected model, and reasoning level.
617
+ */
618
+ async getContext(contextId) {
619
+ const context = this.state.contexts[contextId] || '';
620
+ const model = this.state.models[contextId] || this.state.model;
621
+ const reasoning =
622
+ this.state.reasonings[contextId] || this.state.reasoning || false;
623
+ return {context, model, reasoning};
624
+ }
625
+
626
+ async chat(contextId, question, userDesktopId, disableTool = false) {
609
627
  const logger = Logger.get(contextId, this);
610
628
 
611
629
  await this._mutex.lock(this.id);
@@ -652,7 +670,7 @@ ${context}
652
670
  messages,
653
671
  options,
654
672
  format: this.state.format?.toJS(),
655
- tools: this.state.tools?.toJS(),
673
+ tools: disableTool ? undefined : this.state.tools?.toJS(),
656
674
  };
657
675
 
658
676
  const result = await this._provider.chat(chatCompletionRequest);
@@ -666,10 +684,10 @@ ${context}
666
684
  ),
667
685
  question,
668
686
  reasoning: result.message?.reasoning,
669
- callTools: !!result.message.tool_calls?.length,
687
+ callTools: disableTool ? 'disabled' : !!result.message.tool_calls?.length,
670
688
  });
671
689
 
672
- if (this.state.toolServiceId && this.state.tools) {
690
+ if (this.state.toolServiceId && this.state.tools && !disableTool) {
673
691
  const used = await this.callTools(
674
692
  contextId,
675
693
  result.message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-agents",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "AI Agents framework",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [