Skip to content

Commit b4a8d79

Browse files
committed
update function names and more fixes
1 parent be42c60 commit b4a8d79

File tree

8 files changed

+35
-36
lines changed

8 files changed

+35
-36
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const suiAgent = new Agent('your_atoma_sdk_bearer_token');
5353
// Use the agent to process queries
5454
async function processQuery(query: string) {
5555
try {
56-
const result = await suiAgent.SuperVisorAgent(query);
56+
const result = await suiAgent.processUserQueryPipeline(query);
5757
return result;
5858
} catch (error) {
5959
console.error('Error processing query:', error);
@@ -72,7 +72,7 @@ const suiAgent = new Agent(config.atomaSdkBearerAuth);
7272
app.post('/query', async (req, res) => {
7373
try {
7474
const { query } = req.body;
75-
const result = await suiAgent.SuperVisorAgent(query);
75+
const result = await suiAgent.processUserQueryPipeline(query);
7676
res.json(result);
7777
} catch (error) {
7878
res.status(500).json({ error: 'Internal server error' });

apps/web/src/controllers/conversation.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ConversationController {
3939
res.status(400).json({ error: 'Invalid conversation ID' });
4040
return;
4141
}
42-
const result = await suiAgent.SuperVisorAgent(message, walletAddress);
42+
const result = await suiAgent.processUserQueryPipeline(message, walletAddress);
4343
const newMessage = await this.messageService.createMessage({
4444
sender: sender ? sender : 'user',
4545
walletAddress,

apps/web/src/routes/v1/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const handleQuery = async (req: Request, res: Response): Promise<void> => {
2020
return;
2121
}
2222
// Get agent response first
23-
const result = await suiAgent.SuperVisorAgent(query);
23+
const result = await suiAgent.processUserQueryPipeline(query);
2424
res.status(200).json(result);
2525
} catch (error) {
2626
console.error('Error handling query:', error);

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { IntentAgentResponse } from '../@types/interface';
22
import Tools from '../utils/tools';
33
import { registerAllTools } from './ToolRegistry';
44
import Utils from '../utils';
5-
import intent_agent_prompt from '../prompts/intent_agent_prompt';
5+
import intent_agent_prompt from '../prompts/tool_selector';
66
import final_answer_agent_prompt from '../prompts/final_answer_agent';
77
import Atoma from '../config/atoma';
88
import decomposerPrompt from '../prompts/decomposer';
@@ -13,7 +13,7 @@ import decomposerPrompt from '../prompts/decomposer';
1313
*
1414
* @example
1515
* const agent = new Agents("your-bearer-auth-token");
16-
* const response = await agent.SuperVisorAgent("What is the current price of the Sui token?");
16+
* const response = await agent.processUserQueryPipeline("What is the current price of the Sui token?");
1717
* console.log(response);
1818
*/
1919
class Agents {
@@ -41,7 +41,7 @@ class Agents {
4141
* @param prompt - User's input query
4242
* @returns IntentAgentResponse containing tool selection and processing details
4343
*/
44-
async IntentAgent(subqueries: string[], address?: string) {
44+
async toolsSelector(subqueries: string[], address?: string) {
4545
const IntentResponse: IntentAgentResponse[] =
4646
(await this.tools.selectAppropriateTool(
4747
this.AtomaClass,
@@ -58,10 +58,7 @@ class Agents {
5858
* @param query - Original user query
5959
* @returns Processed response after decision making
6060
*/
61-
async DecisionMakingAgent(
62-
intentResponse: IntentAgentResponse[],
63-
query: string,
64-
) {
61+
async QueryProcessor(intentResponse: IntentAgentResponse[], query: string) {
6562
// Pass both the selected tool name and arguments to processQuery
6663

6764
return await this.utils.processQuery(
@@ -77,17 +74,17 @@ class Agents {
7774
* @param prompt - User's input query
7875
* @returns Final processed response
7976
*/
80-
async SuperVisorAgent(prompt: string, walletAddress?: string) {
77+
async processUserQueryPipeline(prompt: string, walletAddress?: string) {
8178
// Process intent
8279
const decomposer = await this.QueryDecomposer(prompt);
8380
const decomposed: string[] = JSON.parse(
8481
decomposer.choices[0].message.content,
8582
);
8683
console.log(decomposed);
87-
const res = await this.IntentAgent(decomposed, walletAddress);
84+
const res = await this.toolsSelector(decomposed, walletAddress);
8885
console.log(res, 'this is intent agent response');
8986
// Make decision based on intent
90-
const finalAnswer = await this.DecisionMakingAgent(res, prompt);
87+
const finalAnswer = await this.QueryProcessor(res, prompt);
9188
console.log('Final Answer:', finalAnswer);
9289
return finalAnswer;
9390
}
File renamed without changes.

packages/sui-agent/src/protocols/aftermath/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@ The Sui Agent includes comprehensive integration with the Aftermath Protocol, pr
3232
const agent = new Agents(YOUR_BEARER_TOKEN);
3333

3434
// Get pool information
35-
const poolInfo = await agent.SuperVisorAgent(
35+
const poolInfo = await agent.processUserQueryPipeline(
3636
'Get information about Aftermath pool 0x123...abc',
3737
);
3838

3939
// Get APR for a token
40-
const apr = await agent.SuperVisorAgent('Get APR for token 0x456...def');
40+
const apr = await agent.processUserQueryPipeline(
41+
'Get APR for token 0x456...def',
42+
);
4143

4244
// Execute a multi-pool deposit
43-
const deposit = await agent.SuperVisorAgent(
45+
const deposit = await agent.processUserQueryPipeline(
4446
'Deposit 100 SUI into top 3 Aftermath pools by APR with 1% slippage',
4547
);
4648

4749
// Check staking positions
48-
const stakingInfo = await agent.SuperVisorAgent(
50+
const stakingInfo = await agent.processUserQueryPipeline(
4951
'Get my staking positions for address 0x789...ghi',
5052
);
5153
```

packages/sui-agent/src/protocols/cetus/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ The Sui Agent includes comprehensive integration with the Cetus Protocol, provid
3131
const agent = new Agents(YOUR_BEARER_TOKEN);
3232

3333
// Get pool information
34-
const poolInfo = await agent.SuperVisorAgent(
34+
const poolInfo = await agent.processUserQueryPipeline(
3535
'Get information about Cetus pool 0x123...abc',
3636
);
3737

3838
// Get positions for an address
39-
const positions = await agent.SuperVisorAgent(
39+
const positions = await agent.processUserQueryPipeline(
4040
'Get all Cetus positions for address 0x456...def',
4141
);
4242

4343
// Calculate and execute a swap
44-
const swap = await agent.SuperVisorAgent(
44+
const swap = await agent.processUserQueryPipeline(
4545
'Swap 1 SUI for USDC on Cetus pool 0x123...abc with 1% slippage',
4646
);
4747

4848
// Add liquidity
49-
const addLiquidity = await agent.SuperVisorAgent(
49+
const addLiquidity = await agent.processUserQueryPipeline(
5050
'Add 100 USDC as liquidity to Cetus pool 0x123...abc with 0.5% slippage',
5151
);
5252
```

packages/sui-agent/src/tests/cetus.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const agent = new Agents(process.env.BEARER_TOKEN || '');
88
describe('Cetus Protocol Integration Tests', () => {
99
describe('Pool Operations', () => {
1010
test('should get pool information', async () => {
11-
const response = await agent.SuperVisorAgent(
11+
const response = await agent.processUserQueryPipeline(
1212
`Get information about Cetus pool ${TEST_POOLS.SUI_USDC}`,
1313
);
1414
expect(response).toBeDefined();
@@ -19,7 +19,7 @@ describe('Cetus Protocol Integration Tests', () => {
1919
});
2020

2121
test('should get pool statistics and TVL', async () => {
22-
const response = await agent.SuperVisorAgent(
22+
const response = await agent.processUserQueryPipeline(
2323
`Get statistics and TVL for Cetus pool ${TEST_POOLS.USDC_USDT}`,
2424
);
2525
expect(response).toBeDefined();
@@ -29,7 +29,7 @@ describe('Cetus Protocol Integration Tests', () => {
2929
});
3030

3131
test('should list all pools', async () => {
32-
const response = await agent.SuperVisorAgent(
32+
const response = await agent.processUserQueryPipeline(
3333
'List all available Cetus pools',
3434
);
3535
expect(response).toBeDefined();
@@ -41,7 +41,7 @@ describe('Cetus Protocol Integration Tests', () => {
4141

4242
describe('Position Operations', () => {
4343
test('should get positions for address', async () => {
44-
const response = await agent.SuperVisorAgent(
44+
const response = await agent.processUserQueryPipeline(
4545
`Get all Cetus positions for address ${TEST_ADDRESSES.LP_PROVIDER}`,
4646
);
4747
expect(response).toBeDefined();
@@ -50,7 +50,7 @@ describe('Cetus Protocol Integration Tests', () => {
5050
});
5151

5252
test('should calculate add liquidity parameters', async () => {
53-
const response = await agent.SuperVisorAgent(
53+
const response = await agent.processUserQueryPipeline(
5454
`Calculate parameters for adding 1000 USDC to Cetus pool ${TEST_POOLS.USDC_USDT} with ${SLIPPAGE.MEDIUM * 100}% slippage`,
5555
);
5656
expect(response).toBeDefined();
@@ -63,12 +63,12 @@ describe('Cetus Protocol Integration Tests', () => {
6363

6464
test('should calculate remove liquidity parameters', async () => {
6565
// First get a position
66-
const positionsResponse = await agent.SuperVisorAgent(
66+
const positionsResponse = await agent.processUserQueryPipeline(
6767
`Get all Cetus positions for address ${TEST_ADDRESSES.LP_PROVIDER}`,
6868
);
6969
const position = positionsResponse.response[0];
7070

71-
const response = await agent.SuperVisorAgent(
71+
const response = await agent.processUserQueryPipeline(
7272
`Calculate parameters for removing liquidity from Cetus position ${position.pos_object_id} with ${SLIPPAGE.LOW * 100}% slippage`,
7373
);
7474
expect(response).toBeDefined();
@@ -80,7 +80,7 @@ describe('Cetus Protocol Integration Tests', () => {
8080

8181
describe('Trading Operations', () => {
8282
test('should calculate swap quote for exact input', async () => {
83-
const response = await agent.SuperVisorAgent(
83+
const response = await agent.processUserQueryPipeline(
8484
`Calculate swap quote for trading 1 SUI to USDC on Cetus pool ${TEST_POOLS.SUI_USDC} with ${SLIPPAGE.HIGH * 100}% slippage`,
8585
);
8686
expect(response).toBeDefined();
@@ -90,7 +90,7 @@ describe('Cetus Protocol Integration Tests', () => {
9090
});
9191

9292
test('should calculate swap quote for exact output', async () => {
93-
const response = await agent.SuperVisorAgent(
93+
const response = await agent.processUserQueryPipeline(
9494
`Calculate swap quote to receive exactly 100 USDC by trading SUI on Cetus pool ${TEST_POOLS.SUI_USDC} with ${SLIPPAGE.MEDIUM * 100}% slippage`,
9595
);
9696
expect(response).toBeDefined();
@@ -100,7 +100,7 @@ describe('Cetus Protocol Integration Tests', () => {
100100
});
101101

102102
test('should handle price impact calculation', async () => {
103-
const response = await agent.SuperVisorAgent(
103+
const response = await agent.processUserQueryPipeline(
104104
`Calculate price impact for swapping 1000 USDC to USDT on Cetus pool ${TEST_POOLS.USDC_USDT}`,
105105
);
106106
expect(response).toBeDefined();
@@ -114,7 +114,7 @@ describe('Cetus Protocol Integration Tests', () => {
114114

115115
describe('Pool Creation', () => {
116116
test('should validate pool creation parameters', async () => {
117-
const response = await agent.SuperVisorAgent(
117+
const response = await agent.processUserQueryPipeline(
118118
'Create a new Cetus pool for SUI/USDC with tick spacing 2 and initial price 1.0',
119119
);
120120
expect(response).toBeDefined();
@@ -126,7 +126,7 @@ describe('Cetus Protocol Integration Tests', () => {
126126

127127
describe('Error Handling', () => {
128128
test('should handle invalid pool ID gracefully', async () => {
129-
const response = await agent.SuperVisorAgent(
129+
const response = await agent.processUserQueryPipeline(
130130
'Get information about Cetus pool 0xinvalid_pool_id',
131131
);
132132
expect(response).toBeDefined();
@@ -135,7 +135,7 @@ describe('Cetus Protocol Integration Tests', () => {
135135
});
136136

137137
test('should handle invalid address gracefully', async () => {
138-
const response = await agent.SuperVisorAgent(
138+
const response = await agent.processUserQueryPipeline(
139139
'Get all Cetus positions for address 0xinvalid_address',
140140
);
141141
expect(response).toBeDefined();
@@ -144,7 +144,7 @@ describe('Cetus Protocol Integration Tests', () => {
144144
});
145145

146146
test('should handle excessive slippage values', async () => {
147-
const response = await agent.SuperVisorAgent(
147+
const response = await agent.processUserQueryPipeline(
148148
`Calculate swap quote for trading 1 SUI to USDC on Cetus pool ${TEST_POOLS.SUI_USDC} with 50% slippage`,
149149
);
150150
expect(response).toBeDefined();

0 commit comments

Comments
 (0)