Skip to content

Commit 2379b8c

Browse files
Merge pull request #115 from SmythOS/feat/planner-mode
Feat/planner mode + ScrapeFly & Tavily components
2 parents f46cf71 + 6557261 commit 2379b8c

File tree

22 files changed

+1082
-35
lines changed

22 files changed

+1082
-35
lines changed

examples/01-agent-code-skill/04.1-chat-planner-coder.ts

Lines changed: 611 additions & 0 deletions
Large diffs are not rendered by default.

examples/03-agent-workflow-components/02-tavily-websearch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ async function main() {
4444

4545
//#endregion
4646

47-
console.log(agent.data);
47+
//console.log(agent.data);
4848

4949
//const result = await agent.prompt('Hello, what is the price of bitcoin in USD');
5050

51-
const result = await agent.call('MarketData', { coin_id: 'bitcoin' });
51+
const result = await agent.call('WebSearch', { userQuery: 'bitcoin' });
5252

5353
console.log(result);
5454
}

examples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"@smythos/sdk": "workspace:*",
1414
"@smythos/sre": "workspace:*",
1515
"chalk": "^5.4.1",
16-
"dotenv": "^16.5.0"
16+
"dotenv": "^16.5.0",
17+
"tokenloom": "^1.0.7"
1718
},
1819
"devDependencies": {
1920
"@types/node": "^20.19.0",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@google/genai": "^1.10.0",
6666
"@google/generative-ai": "^0.14.1",
6767
"@huggingface/inference": "^2.8.0",
68-
"@modelcontextprotocol/sdk": "^1.10.1",
68+
"@modelcontextprotocol/sdk": "^1.17.4",
6969
"@pinecone-database/pinecone": "^3.0.0",
7070
"@runware/sdk-js": "^1.1.36",
7171
"@smithy/smithy-client": "^4.4.3",

packages/core/src/Components/ScrapflyWebScrape.class.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ import { getCredentials } from '../subsystems/Security/Credentials.helper';
99
// const CREDITS_PER_URL = 0.2;
1010

1111
export class ScrapflyWebScrape extends Component {
12+
protected schema = {
13+
name: 'ScrapflyWebScrape',
14+
description: 'Use this component to scrape web pages',
15+
inputs: {
16+
URLs: {
17+
type: 'Array',
18+
description: 'The URLs to scrape',
19+
default: true,
20+
},
21+
},
22+
outputs: {
23+
Results: {
24+
type: 'Array',
25+
description: 'The scraped results',
26+
default: true,
27+
},
28+
FailedURLs: {
29+
type: 'Array',
30+
description: 'The URLs that failed to scrape',
31+
default: true,
32+
},
33+
},
34+
};
35+
1236
protected configSchema = Joi.object({
1337
// includeImages: Joi.boolean().default(false).label('Include Image Results'),
1438
antiScrapingProtection: Joi.boolean().default(false).label('Enable Anti-Scraping Protection'),

packages/core/src/Components/TavilyWebSearch.class.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ export class TavilyWebSearch extends Component {
8282
return { ...Output, _error, _debug: logger.output };
8383
} catch (err: any) {
8484
const _error = err?.message || err?.response?.data || err.toString();
85-
logger.error(` Error scraping web \n${JSON.stringify(_error)}\n`);
85+
86+
if (err?.status === 401) {
87+
logger.error(`Tavily Web Search Auth failed, make sure that you have the vault key "tavily" is present and valid`);
88+
} else {
89+
logger.error(` Error scraping web \n${JSON.stringify(_error)}\n`);
90+
}
8691
return { Output: undefined, _error, _debug: logger.output };
8792
}
8893
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ export class Conversation extends EventEmitter {
342342
this.emit(TLLMEvent.Thinking, thinking);
343343
});
344344

345+
eventEmitter.on(TLLMEvent.Data, (data) => {
346+
if (this.stop) return;
347+
this.emit(TLLMEvent.Data, data);
348+
});
349+
345350
eventEmitter.on(TLLMEvent.Content, (content) => {
346351
if (this.stop) return;
347352
// if (toolHeaders['x-passthrough']) {

packages/core/src/subsystems/LLMManager/LLM.inference.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ export class LLMInference {
265265
console.warn('Max input context is 0, returning empty context window, This usually indicates a wrong model configuration');
266266
}
267267

268+
console.debug(
269+
`Context Window Configuration: Max Input Tokens: ${maxInputContext}, Max Output Tokens: ${maxOutputContext}, Max Model Tokens: ${maxModelContext}`
270+
);
268271
const systemMessage = { role: 'system', content: systemPrompt };
269272

270273
let smythContextWindow = [];

packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class ChatCompletionsApiInterface extends OpenAIApiInterface {
188188
// Handle OpenAI tool definition format
189189
if ('parameters' in tool) {
190190
return {
191-
type: 'function',
191+
type: 'function' as const,
192192
function: {
193193
name: tool.name,
194194
description: tool.description,
@@ -199,7 +199,7 @@ export class ChatCompletionsApiInterface extends OpenAIApiInterface {
199199

200200
// Handle legacy format for backward compatibility
201201
return {
202-
type: 'function',
202+
type: 'function' as const,
203203
function: {
204204
name: tool.name,
205205
description: tool.description,

packages/core/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export abstract class ModelsProviderConnector extends SecureConnector {
132132
hasAPIKey: boolean;
133133
}) => {
134134
//const teamModels = typeof model === 'string' ? await loadTeamModels() : {};
135+
if (Array.isArray(model?.tags) && model?.tags?.includes('sdk')) {
136+
return; //skip check for SDK
137+
}
135138
const modelInfo = await this.getModelInfo(candidate.readRequest, {}, model, hasAPIKey);
136139
const allowedContextTokens = modelInfo?.tokens;
137140
const totalTokens = promptTokens + completionTokens;

0 commit comments

Comments
 (0)