Skip to content

Commit f1032e5

Browse files
committed
fix intent and decision agent
1 parent 97d8916 commit f1032e5

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

apps/web/test/integration/health.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ describe('Health Check Endpoints', () => {
1515
});
1616

1717
it('GET / should return API info', async () => {
18-
const response = await request(testApp)
19-
.get('/')
20-
.expect('Content-Type', /json/)
21-
.expect(200);
18+
const response = await request(testApp).get('/').expect('Content-Type', /json/).expect(200);
2219

2320
expect(response.body).toHaveProperty('message', 'Atoma Agents API');
2421
expect(response.body).toHaveProperty('version', '1.0.0');
2522
});
26-
});
23+
});

apps/web/test/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ process.on('SIGTERM', () => {
3030

3131
process.on('SIGINT', () => {
3232
process.exit(0);
33-
});
33+
});

packages/sui-agent/src/agents/SuiAgent.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class Agents {
2020

2121
constructor(bearerAuth: string) {
2222
this.tools = new Tools(bearerAuth, intent_agent_prompt);
23-
this.utils = new Utils(bearerAuth, final_answer_agent_prompt);
23+
this.utils = new Utils(bearerAuth, final_answer_agent_prompt, this.tools);
24+
// Register tools when agent is instantiated
25+
registerAllTools(this.tools);
2426
}
2527

2628
/**
@@ -29,8 +31,6 @@ class Agents {
2931
* @returns IntentAgentResponse containing tool selection and processing details
3032
*/
3133
async IntentAgent(prompt: string) {
32-
// Register all available tools before processing
33-
registerAllTools(this.tools);
3434
const IntentResponse: IntentAgentResponse =
3535
(await this.tools.selectAppropriateTool(prompt)) as IntentAgentResponse;
3636
return IntentResponse;
@@ -46,7 +46,12 @@ class Agents {
4646
intentResponse: IntentAgentResponse,
4747
query: string,
4848
) {
49-
return await this.utils.processQuery(query);
49+
// Pass both the selected tool name and arguments to processQuery
50+
return await this.utils.processQuery(
51+
query,
52+
intentResponse.selected_tool,
53+
intentResponse.tool_arguments,
54+
);
5055
}
5156

5257
/**
@@ -58,11 +63,11 @@ class Agents {
5863
async SuperVisorAgent(prompt: string) {
5964
// Process intent
6065
const res = await this.IntentAgent(prompt);
61-
console.log(res);
66+
console.log('Intent Response:', res);
6267

6368
// Make decision based on intent
6469
const finalAnswer = await this.DecisionMakingAgent(res, prompt);
65-
console.log(finalAnswer, 'final');
70+
console.log('Final Answer:', finalAnswer);
6671
return finalAnswer;
6772
}
6873
}

packages/sui-agent/src/config/atoma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as dotenv from 'dotenv';
44
// Load environment variables
55
dotenv.config();
66

7-
const ATOMA_CHAT_COMPLETIONS_MODEL = process.env.ATOMA_CHAT_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
7+
const ATOMA_CHAT_COMPLETIONS_MODEL =
8+
process.env.ATOMA_CHAT_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
89
const sdkInstance: AtomaSDK | null = null;
910

1011
/**

packages/sui-agent/src/utils/index.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,43 @@ import { ToolArgument } from '../@types/interface';
99
* Handles the execution of tools and formatting of final responses
1010
*/
1111
class Utils {
12-
private tools: Tools;
1312
private sdk: AtomaSDK;
1413
private prompt: string;
14+
private tools: Tools;
1515

16-
constructor(bearerAuth: string, prompt: string) {
17-
this.tools = new Tools(bearerAuth, prompt);
16+
constructor(bearerAuth: string, prompt: string, tools?: Tools) {
1817
this.sdk = new AtomaSDK({ bearerAuth });
1918
this.prompt = prompt;
19+
// Use provided tools instance or create new one
20+
this.tools = tools || new Tools(bearerAuth, prompt);
21+
}
22+
23+
/**
24+
* Set tools instance
25+
* @param tools - Tools instance to use
26+
*/
27+
setTools(tools: Tools) {
28+
this.tools = tools;
2029
}
2130

2231
/**
2332
* Process user query and execute appropriate tool
2433
* @param query - User query
34+
* @param selectedTool - Name of the tool to execute
35+
* @param toolArguments - Arguments to pass to the tool
2536
* @returns Processed response
2637
*/
27-
async processQuery(query: string) {
38+
async processQuery(
39+
query: string,
40+
selectedTool: string | null,
41+
toolArguments: ToolArgument[] = [],
42+
) {
2843
try {
29-
const selectedTool = await this.tools.selectAppropriateTool(query);
3044
if (!selectedTool) {
31-
return this.finalAnswer('No tool found for the query', query);
45+
return this.finalAnswer('No tool selected for the query', query);
3246
}
3347

34-
return this.executeTools(
35-
selectedTool.selected_tool || '',
36-
selectedTool.tool_arguments || [],
37-
);
48+
return this.executeTools(selectedTool, toolArguments);
3849
} catch (error: unknown) {
3950
console.error('Error processing query:', error);
4051
return handleError(error, {

0 commit comments

Comments
 (0)