Skip to content

Commit 1db7659

Browse files
committed
feat: adjust kb custom resource
1 parent 7971391 commit 1db7659

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/ai/AkamaiAgentCR.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ describe('AkamaiAgentCR', () => {
4949
expect(agentCR.metadata.labels?.['apl.io/teamId']).toBe('team-123')
5050
expect(agentCR.spec.foundationModel).toBe('gpt-4')
5151
expect(agentCR.spec.systemPrompt).toBe('You are a helpful assistant')
52-
expect(agentCR.spec.knowledgeBase).toBe('test-kb')
52+
expect(agentCR.spec.tools).toEqual([
53+
{
54+
type: 'knowledgeBase',
55+
name: 'test-kb',
56+
},
57+
])
5358
})
5459

5560
test('should set teamId label and not merge custom labels', () => {
@@ -73,7 +78,7 @@ describe('AkamaiAgentCR', () => {
7378

7479
const agentCR = new AkamaiAgentCR('team-123', 'test-agent', requestWithoutKB)
7580

76-
expect(agentCR.spec.knowledgeBase).toBeUndefined()
81+
expect(agentCR.spec.tools).toBeUndefined()
7782
})
7883
})
7984

src/ai/AkamaiAgentCR.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ export class AkamaiAgentCR {
1919
public spec: {
2020
foundationModel: string
2121
systemPrompt: string
22-
knowledgeBase?: string
22+
tools?: Array<{
23+
type: string
24+
name: string
25+
description?: string
26+
endpoint?: string
27+
}>
2328
}
2429

2530
constructor(teamId: string, agentName: string, request: AplAgentRequest) {
@@ -38,7 +43,15 @@ export class AkamaiAgentCR {
3843
this.spec = {
3944
foundationModel: request.spec.foundationModel,
4045
systemPrompt: request.spec.agentInstructions,
41-
knowledgeBase: request.spec.knowledgeBase,
46+
tools: request.spec.knowledgeBase
47+
? [
48+
{
49+
type: 'knowledgeBase',
50+
name: request.spec.knowledgeBase,
51+
description: `Search the ${request.spec.knowledgeBase} knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.`,
52+
},
53+
]
54+
: undefined,
4255
}
4356
}
4457

@@ -54,6 +67,9 @@ export class AkamaiAgentCR {
5467

5568
// Transform to API response format
5669
toApiResponse(teamId: string): AplAgentResponse {
70+
// Extract knowledgeBase from tools array (find first knowledgeBase tool)
71+
const knowledgeBaseTool = this.spec.tools?.find((tool) => tool.type === 'knowledgeBase')
72+
5773
return {
5874
kind: 'AkamaiAgent',
5975
metadata: {
@@ -66,7 +82,7 @@ export class AkamaiAgentCR {
6682
spec: {
6783
foundationModel: this.spec.foundationModel,
6884
agentInstructions: this.spec.systemPrompt,
69-
knowledgeBase: this.spec.knowledgeBase || '',
85+
knowledgeBase: knowledgeBaseTool?.name || '',
7086
},
7187
status: {
7288
conditions: [

src/ai/aiModelHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function getConditions(deployment: V1Deployment) {
1414

1515
export function transformK8sDeploymentToAplAIModel(deployment: V1Deployment): AplAIModelResponse {
1616
const labels = deployment.metadata?.labels || {}
17-
const modelName = deployment.metadata?.name || labels.modelName
17+
const modelName = labels.modelName || deployment.metadata?.name || ''
1818

1919
// Convert K8s deployment conditions to schema format
2020
const conditions = getConditions(deployment)

0 commit comments

Comments
 (0)