Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/sre",
"version": "1.5.68",
"version": "1.5.70",
"description": "Smyth Runtime Environment",
"author": "Alaa-eddine KADDOURI",
"license": "MIT",
Expand Down
23 changes: 16 additions & 7 deletions packages/core/src/helpers/Conversation.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ export class Conversation extends EventEmitter {
let _content = '';
const reqMethods = this._reqMethods;
const toolsConfig = this._toolsConfig;
//deduplicate tools
toolsConfig.tools = toolsConfig.tools.filter((tool, index, self) => self.findIndex((t) => t.function.name === tool.function.name) === index);
const endpoints = this._endpoints;
const baseUrl = this._baseUrl;
const message_id = 'msg_' + randomUUID();
Expand Down Expand Up @@ -832,15 +830,22 @@ export class Conversation extends EventEmitter {
this._customToolsDeclarations.push(toolDefinition);
this._customToolsHandlers[tool.name] = tool.handler;

//deduplicate tools

const llmInference: LLMInference = await LLMInference.getInstance(this.model, AccessCandidate.team(this._teamId));
this._customToolsDeclarations = this._customToolsDeclarations.filter(
(tool, index, self) => self.findIndex((t) => t.name === tool.name) === index
);
const toolsConfig: any = llmInference.connector.formatToolsConfig({
type: 'function',
toolDefinitions: [toolDefinition],
toolDefinitions: this._customToolsDeclarations,
toolChoice: this.toolChoice,
});

if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools);
else this._toolsConfig = toolsConfig;
//if (this._toolsConfig) this._toolsConfig.tools.push(...toolsConfig?.tools);
//else this._toolsConfig = toolsConfig;

this._toolsConfig = toolsConfig;
}
/**
* updates LLM model, if spec is available, it will update the tools config
Expand All @@ -857,15 +862,19 @@ export class Conversation extends EventEmitter {
this._baseUrl = this._spec?.servers?.[0].url;

const functionDeclarations = this.getFunctionDeclarations(this._spec);
functionDeclarations.push(...this._customToolsDeclarations);
//functionDeclarations.push(...this._customToolsDeclarations);
this._customToolsDeclarations.push(...functionDeclarations);
const llmInference: LLMInference = await LLMInference.getInstance(this._model, AccessCandidate.team(this._teamId));
if (!llmInference.connector) {
this.emit('error', 'No connector found for model: ' + this._model);
return;
}
this._customToolsDeclarations = this._customToolsDeclarations.filter(
(tool, index, self) => self.findIndex((t) => t.name === tool.name) === index
);
this._toolsConfig = llmInference.connector.formatToolsConfig({
type: 'function',
toolDefinitions: functionDeclarations,
toolDefinitions: this._customToolsDeclarations,
toolChoice: this.toolChoice,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/sdk",
"version": "1.1.10",
"version": "1.1.11",
"description": "SRE SDK",
"keywords": [
"smythos",
Expand Down