Skip to content

Commit 812a76a

Browse files
committed
pnpm up & model factory
1 parent 79ed7be commit 812a76a

8 files changed

Lines changed: 1202 additions & 1472 deletions

File tree

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,31 @@
2525
"node": ">=22.13.0"
2626
},
2727
"dependencies": {
28-
"@ai-sdk/amazon-bedrock": "^4.0.96",
29-
"@aws-sdk/credential-providers": "^3.1033.0",
28+
"@ai-sdk/amazon-bedrock": "^4.0.104",
29+
"@ai-sdk/openai": "^3.0.63",
30+
"@aws-sdk/credential-providers": "^3.1045.0",
3031
"@mastra/auth-auth0": "^1.0.1",
31-
"@mastra/core": "^1.25.0",
32-
"@mastra/evals": "^1.2.1",
33-
"@mastra/libsql": "^1.8.1",
32+
"@mastra/core": "^1.32.1",
33+
"@mastra/evals": "^1.2.2",
34+
"@mastra/libsql": "^1.10.0",
3435
"@mastra/loggers": "^1.1.1",
35-
"@mastra/memory": "^1.15.1",
36-
"@mastra/observability": "^1.9.1",
37-
"@mastra/pg": "^1.9.1",
36+
"@mastra/memory": "^1.17.5",
37+
"@mastra/observability": "^1.11.1",
38+
"@mastra/pg": "^1.10.0",
3839
"@topcoder/wipro-ai-sdk-provider": "git+https://git.topcoder.com/Topcoder-Platform/Wipro-Provider-AI-SDK.git",
39-
"ai": "^6.0.168",
40-
"ai-sdk-ollama": "^3.8.3",
40+
"ai": "^6.0.177",
41+
"ai-sdk-ollama": "^3.8.4",
4142
"tc-core-library-js": "^2.4.1",
42-
"zod": "^4.3.6"
43+
"zod": "^4.4.3"
4344
},
4445
"devDependencies": {
4546
"@eslint/js": "^10.0.1",
46-
"@types/node": "^25.6.0",
47-
"eslint": "^10.2.1",
48-
"mastra": "^1.6.0",
47+
"@types/node": "^25.7.0",
48+
"eslint": "^10.3.0",
49+
"mastra": "^1.8.1",
4950
"prettier": "^3.8.3",
5051
"typescript": "^6.0.3",
51-
"typescript-eslint": "^8.59.0",
52-
"vitest": "^4.1.4"
52+
"typescript-eslint": "^8.59.3",
53+
"vitest": "^4.1.6"
5354
}
5455
}

pnpm-lock.yaml

Lines changed: 1126 additions & 1437 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mastra/agents/challenge/challenge-parser-agent.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Agent } from '@mastra/core/agent';
2-
import { bedrock } from '../../../utils';
2+
import { createModel } from '../../../utils';
33

4+
const PROVIDER_NAME = 'AWSBedrock';
45
const MODEL_ID = 'us.anthropic.claude-sonnet-4-6';
6+
const AGENT_ID = 'challenge-parser-agent';
57

68
/**
79
* Master agent responsible for parsing Topcoder challenge specifications.
@@ -14,9 +16,9 @@ const MODEL_ID = 'us.anthropic.claude-sonnet-4-6';
1416
* codebase-detection, and submission-guidelines-extraction.
1517
*/
1618
export const challengeParserAgent = new Agent({
17-
id: 'challenge-parser-agent',
19+
id: AGENT_ID,
1820
name: 'Challenge Specification Parser',
19-
model: bedrock(MODEL_ID),
21+
model: createModel(PROVIDER_NAME, MODEL_ID, AGENT_ID),
2022
instructions: {
2123
role: 'system',
2224
content: `You are an expert Topcoder challenge specification analyst.
@@ -66,7 +68,6 @@ STRICT OUTPUT CONTRACT
6668
────────────────────────────────────────────────────────
6769
Return ONLY the JSON object matching the provided schema.
6870
Do NOT add commentary, markdown fences, or extra keys.
69-
Every field is mandatory per the schema — never omit a key.
70-
/no_think`,
71+
Every field is mandatory per the schema — never omit a key.`,
7172
},
7273
});

src/mastra/agents/jd/jd-rewriter-agent.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Agent } from '@mastra/core/agent';
2-
import { bedrock } from '../../../utils';
2+
import { createModel } from '../../../utils';
33

4+
const PROVIDER_NAME = 'AWSBedrock';
45
const MODEL_ID = 'us.anthropic.claude-haiku-4-5-20251001-v1:0';
6+
const AGENT_ID = 'jd-rewriter-agent';
57

68
export const jdRewriterAgent = new Agent({
7-
id: 'jd-rewriter-agent',
8-
name: 'Job Description Rewriter',
9-
model: bedrock(MODEL_ID),
10-
instructions: {
11-
role: 'system',
12-
content: `You are an expert technical recruiter and job description writer for Topcoder.
9+
id: AGENT_ID,
10+
name: 'Job Description Rewriter',
11+
model: createModel(PROVIDER_NAME, MODEL_ID, AGENT_ID),
12+
instructions: {
13+
role: 'system',
14+
content: `You are an expert technical recruiter and job description writer for Topcoder.
1315
Your sole job is to take a raw, rough, or vague job description and rewrite it
1416
into a clear, professional, well-structured format suitable for posting as a
1517
Topcoder opportunity.
@@ -44,7 +46,6 @@ STRICT OUTPUT CONTRACT
4446
────────────────────────────────────────────────────────
4547
Return ONLY the JSON object matching the provided schema.
4648
Do NOT add commentary, markdown fences, or extra keys.
47-
Every field is mandatory per the schema — never omit a key.
48-
/no_think`,
49-
},
49+
Every field is mandatory per the schema — never omit a key.`,
50+
},
5051
});

src/mastra/agents/skills/skills-matching-agent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { Agent } from '@mastra/core/agent';
22
import { Memory } from '@mastra/memory';
3-
import { bedrock } from '../../../utils';
3+
import { createModel } from '../../../utils';
44
import { PostgresStore } from '@mastra/pg';
55
import { instanceScorers } from '../../scorers/instance-scorers';
66

7+
8+
const PROVIDER_NAME = 'AWSBedrock';
79
const MODEL_ID = 'us.anthropic.claude-haiku-4-5-20251001-v1:0';
10+
const AGENT_ID = 'skillsMatchingAgent';
811

912
export const skillsMatchingAgent = new Agent({
10-
id: 'skillsMatchingAgent',
13+
id: AGENT_ID,
1114
name: 'Skill terms matching agent for Topcoder standardized skills from a given text',
1215
instructions: {
1316
role: 'system',
@@ -28,7 +31,7 @@ Output requirements:
2831
- No prose, no markdown, no extra keys.
2932
`,
3033
},
31-
model: bedrock(MODEL_ID),
34+
model: createModel(PROVIDER_NAME, MODEL_ID, AGENT_ID),
3235
scorers: {
3336
answerRelevancy: {
3437
scorer: instanceScorers.instanceAnswerRelevancyScorer,

src/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export * from './middleware';
44
export * from './logger';
55
export * from './auth/m2m.service'
66
export * from './providers/wipro';
7-
export * from './providers/bedrock';
7+
export * from './providers/bedrock';
8+
export * from './providers/model-factory';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ollama } from './ollama';
2+
import { wipro } from './wipro';
3+
import { bedrock } from './bedrock';
4+
import { tcAILogger } from '../logger';
5+
import { openai } from './openai';
6+
7+
export type SupportedProvider = 'TC-Ollama' | 'WiproAI' | 'AWSBedrock' | 'OpenAI';
8+
9+
export function createModel(providerName: string, modelName: string, agentId?: string) {
10+
tcAILogger.info(`[Model Factory] PROVIDER: ${providerName}, MODEL: ${modelName} for AGENT: ${agentId ?? 'N/A'}`);
11+
12+
switch (providerName) {
13+
case 'TC-Ollama':
14+
return ollama(modelName);
15+
16+
case 'WiproAI':
17+
return wipro.chatModel(modelName);
18+
19+
case 'AWSBedrock':
20+
return bedrock(modelName);
21+
22+
case 'OpenAI':
23+
return openai(modelName);
24+
25+
default:
26+
tcAILogger.error(`[Model Factory] Unsupported LLM provider: ${providerName}. Supported providers: TC-Ollama, WiproAI, AWSBedrock, OpenAI`);
27+
throw new Error(`Unsupported LLM provider: ${providerName}. Supported providers: TC-Ollama, WiproAI, AWSBedrock, OpenAI`);
28+
}
29+
}

src/utils/providers/openai.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createOpenAI } from '@ai-sdk/openai';
2+
3+
export const openai = createOpenAI({
4+
// custom settings can be added here if needed
5+
});

0 commit comments

Comments
 (0)