Skip to content

Commit 9024610

Browse files
committed
Hotfix : Agent Tools
1 parent 23851dc commit 9024610

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sre",
3-
"version": "1.5.68",
3+
"version": "1.5.70",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/core/src/helpers/Conversation.helper.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ export class Conversation extends EventEmitter {
281281
let _content = '';
282282
const reqMethods = this._reqMethods;
283283
const toolsConfig = this._toolsConfig;
284-
//deduplicate tools
285-
toolsConfig.tools = toolsConfig.tools.filter((tool, index, self) => self.findIndex((t) => t.function.name === tool.function.name) === index);
286284
const endpoints = this._endpoints;
287285
const baseUrl = this._baseUrl;
288286
const message_id = 'msg_' + randomUUID();
@@ -832,15 +830,22 @@ export class Conversation extends EventEmitter {
832830
this._customToolsDeclarations.push(toolDefinition);
833831
this._customToolsHandlers[tool.name] = tool.handler;
834832

833+
//deduplicate tools
834+
835835
const llmInference: LLMInference = await LLMInference.getInstance(this.model, AccessCandidate.team(this._teamId));
836+
this._customToolsDeclarations = this._customToolsDeclarations.filter(
837+
(tool, index, self) => self.findIndex((t) => t.name === tool.name) === index
838+
);
836839
const toolsConfig: any = llmInference.connector.formatToolsConfig({
837840
type: 'function',
838-
toolDefinitions: [toolDefinition],
841+
toolDefinitions: this._customToolsDeclarations,
839842
toolChoice: this.toolChoice,
840843
});
841844

842-
if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools);
843-
else this._toolsConfig = toolsConfig;
845+
//if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools);
846+
//else this._toolsConfig = toolsConfig;
847+
848+
this._toolsConfig = toolsConfig;
844849
}
845850
/**
846851
* updates LLM model, if spec is available, it will update the tools config
@@ -857,15 +862,19 @@ export class Conversation extends EventEmitter {
857862
this._baseUrl = this._spec?.servers?.[0].url;
858863

859864
const functionDeclarations = this.getFunctionDeclarations(this._spec);
860-
functionDeclarations.push(...this._customToolsDeclarations);
865+
//functionDeclarations.push(...this._customToolsDeclarations);
866+
this._customToolsDeclarations.push(...functionDeclarations);
861867
const llmInference: LLMInference = await LLMInference.getInstance(this._model, AccessCandidate.team(this._teamId));
862868
if (!llmInference.connector) {
863869
this.emit('error', 'No connector found for model: ' + this._model);
864870
return;
865871
}
872+
this._customToolsDeclarations = this._customToolsDeclarations.filter(
873+
(tool, index, self) => self.findIndex((t) => t.name === tool.name) === index
874+
);
866875
this._toolsConfig = llmInference.connector.formatToolsConfig({
867876
type: 'function',
868-
toolDefinitions: functionDeclarations,
877+
toolDefinitions: this._customToolsDeclarations,
869878
toolChoice: this.toolChoice,
870879
});
871880

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sdk",
3-
"version": "1.1.10",
3+
"version": "1.1.11",
44
"description": "SRE SDK",
55
"keywords": [
66
"smythos",

0 commit comments

Comments
 (0)