Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
48e09e8
fix: add foundation model endpoint
CasLubbers Oct 14, 2025
d68a835
fix: get correct endpointName
CasLubbers Oct 20, 2025
81e5761
feat: fetch statefullsets for ai models
CasLubbers Oct 20, 2025
6b63d7d
fix: tests
CasLubbers Oct 21, 2025
31fbe72
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 21, 2025
05b7dac
fix: editAplAgent
CasLubbers Oct 22, 2025
5b5303d
fix: prefix embedding model with nvidea
CasLubbers Oct 23, 2025
8d7ec93
fix: tests
CasLubbers Oct 23, 2025
19af236
feat: fetch CR from cluster
CasLubbers Oct 24, 2025
4237441
feat: fetch CR from cluster
CasLubbers Oct 24, 2025
30f17ce
fix: tests
CasLubbers Oct 24, 2025
3e22975
feat: add await
CasLubbers Oct 24, 2025
9509eb7
feat: add addtributes
CasLubbers Oct 24, 2025
db877c6
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 24, 2025
3a7957b
fix: agent schema types
ferruhcihan Oct 24, 2025
b088189
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 27, 2025
6f7fc72
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 27, 2025
3cde9fa
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 27, 2025
55c7298
fix: get agents and kb from cache and only get status from cluster
CasLubbers Oct 27, 2025
2d7af92
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 31, 2025
098e4fd
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Oct 31, 2025
ea6eb41
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Nov 4, 2025
19d6ed4
Merge remote-tracking branch 'origin/main' into add-fmodel-endpoint
svcAPLBot Nov 4, 2025
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
9 changes: 3 additions & 6 deletions src/ai/AkamaiAgentCR.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('AkamaiAgentCR', () => {
name: 'test-kb',
description:
'Search the test-kb knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.',
endpoint: undefined,
},
])
})
Expand Down Expand Up @@ -111,7 +110,6 @@ describe('AkamaiAgentCR', () => {
type: 'knowledgeBase',
name: 'test-kb',
description: 'Custom description for the knowledge base',
endpoint: undefined,
},
])
})
Expand Down Expand Up @@ -154,7 +152,6 @@ describe('AkamaiAgentCR', () => {
name: 'test-kb',
description:
'Search the test-kb knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.',
endpoint: undefined,
},
],
},
Expand Down Expand Up @@ -186,7 +183,7 @@ describe('AkamaiAgentCR', () => {
expect(response.spec.tools).toBeUndefined()
})

test('should preserve custom description and endpoint in response', () => {
test('should preserve custom description and apiUrl in response', () => {
const requestWithDetails = {
...mockAgentRequest,
spec: {
Expand All @@ -196,7 +193,7 @@ describe('AkamaiAgentCR', () => {
type: 'knowledgeBase',
name: 'test-kb',
description: 'Custom KB description',
endpoint: 'https://api.example.com/kb',
apiUrl: 'https://api.example.com/kb',
},
],
},
Expand All @@ -210,7 +207,7 @@ describe('AkamaiAgentCR', () => {
type: 'knowledgeBase',
name: 'test-kb',
description: 'Custom KB description',
endpoint: 'https://api.example.com/kb',
apiUrl: 'https://api.example.com/kb',
},
])
})
Expand Down
94 changes: 72 additions & 22 deletions src/ai/AkamaiAgentCR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ export class AkamaiAgentCR {
}
public spec: {
foundationModel: string
foundationModelEndpoint?: string
temperature?: number
topP?: number
maxTokens?: number
agentInstructions: string
routes?: Array<{
agent: string
condition: string
apiUrl: string
apiKey?: string
}>
tools?: Array<{
type: string
name: string
description?: string
endpoint?: string
apiUrl?: string
apiKey?: string
}>
}

Expand All @@ -42,17 +53,32 @@ export class AkamaiAgentCR {
}
this.spec = {
foundationModel: request.spec.foundationModel,
...(request.spec.foundationModelEndpoint && { foundationModelEndpoint: request.spec.foundationModelEndpoint }),
...(request.spec.temperature && { temperature: request.spec.temperature }),
...(request.spec.topP && { topP: request.spec.topP }),
...(request.spec.maxTokens && { maxTokens: request.spec.maxTokens }),
agentInstructions: request.spec.agentInstructions,
tools: request.spec.tools?.map((tool) => ({
type: tool.type,
name: tool.name,
description:
tool.description ||
(tool.type === 'knowledgeBase'
? `Search the ${tool.name} knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.`
: undefined),
endpoint: tool.endpoint,
})),
...(request.spec.routes && {
routes: request.spec.routes.map((route) => ({
agent: route.agent,
condition: route.condition,
apiUrl: route.apiUrl,
...(route.apiKey && { apiKey: route.apiKey }),
})),
}),
...(request.spec.tools && {
tools: request.spec.tools.map((tool) => ({
type: tool.type,
name: tool.name,
description:
tool.description ||
(tool.type === 'knowledgeBase'
? `Search the ${tool.name} knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.`
: undefined),
...(tool.apiUrl && { apiUrl: tool.apiUrl }),
...(tool.apiKey && { apiKey: tool.apiKey }),
})),
}),
}
}

Expand All @@ -67,7 +93,7 @@ export class AkamaiAgentCR {
}

// Transform to API response format
toApiResponse(teamId: string): AplAgentResponse {
toApiResponse(teamId: string, status?: any): AplAgentResponse {
return {
kind: 'AkamaiAgent',
metadata: {
Expand All @@ -79,15 +105,30 @@ export class AkamaiAgentCR {
},
spec: {
foundationModel: this.spec.foundationModel,
...(this.spec.foundationModelEndpoint && { foundationModelEndpoint: this.spec.foundationModelEndpoint }),
...(this.spec.temperature && { temperature: this.spec.temperature }),
...(this.spec.topP && { topP: this.spec.topP }),
...(this.spec.maxTokens && { maxTokens: this.spec.maxTokens }),
agentInstructions: this.spec.agentInstructions,
tools: this.spec.tools?.map((tool) => ({
type: tool.type,
name: tool.name,
...(tool.description && { description: tool.description }),
...(tool.endpoint && { endpoint: tool.endpoint }),
})),
...(this.spec.routes && {
routes: this.spec.routes.map((route) => ({
agent: route.agent,
condition: route.condition,
apiUrl: route.apiUrl,
...(route.apiKey && { apiKey: route.apiKey }),
})),
}),
...(this.spec.tools && {
tools: this.spec.tools.map((tool) => ({
type: tool.type,
name: tool.name,
...(tool.description && { description: tool.description }),
...(tool.apiUrl && { apiUrl: tool.apiUrl }),
...(tool.apiKey && { apiKey: tool.apiKey }),
})),
}),
},
status: {
status: status || {
conditions: [
{
type: 'AgentDeployed',
Expand All @@ -103,15 +144,24 @@ export class AkamaiAgentCR {
// Static factory method
static async create(teamId: string, agentName: string, request: AplAgentRequest): Promise<AkamaiAgentCR> {
const aiModels = await getAIModels()
const embeddingModel = aiModels.find(
const foundationModel = aiModels.find(
(model) => model.metadata.name === request.spec.foundationModel && model.spec.modelType === 'foundation',
)

if (!embeddingModel) {
if (!foundationModel) {
throw new K8sResourceNotFound('Foundation model', `Foundation model '${request.spec.foundationModel}' not found`)
}

return new AkamaiAgentCR(teamId, agentName, request)
// Create enriched request with foundationModelEndpoint from the model
const enrichedRequest: AplAgentRequest = {
...request,
spec: {
...request.spec,
foundationModelEndpoint: foundationModel.spec.modelEndpoint,
},
}

return new AkamaiAgentCR(teamId, agentName, enrichedRequest)
}

// Static method to create from existing CR (for transformation)
Expand Down
4 changes: 2 additions & 2 deletions src/ai/AkamaiKnowledgeBaseCR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class AkamaiKnowledgeBaseCR {
}

// Transform to API response format
toApiResponse(teamId: string): AplKnowledgeBaseResponse {
toApiResponse(teamId: string, status?: any): AplKnowledgeBaseResponse {
return {
kind: env.KNOWLEDGE_BASE_KIND as 'AkamaiKnowledgeBase',
metadata: {
Expand All @@ -97,7 +97,7 @@ export class AkamaiKnowledgeBaseCR {
modelName: this.spec.pipelineParameters.embedding_model,
sourceUrl: this.spec.pipelineParameters.url,
},
status: {},
status: status || {},
}
}

Expand Down
Loading
Loading