Skip to content

Commit 71715ea

Browse files
committed
Update client
1 parent 43dca9c commit 71715ea

File tree

8 files changed

+37
-71
lines changed

8 files changed

+37
-71
lines changed

apps/client/app/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import api from './lib/api';
44
import { useWallet } from '@suiet/wallet-kit';
55
import JSONFormatter from './utils/JSONFormatter';
66

7-
import { keywords } from './data';
87

98
import Messages from './components/sections/Messages';
109
import SampleQuestions from './components/sections/SampleQuestions';
@@ -21,8 +20,8 @@ export default function Home() {
2120
useEffect(() => {
2221
if (address && connected) {
2322
loadChatHistory();
24-
// Send initial wallet connection message
25-
handleSend(`Connected wallet: ${address}`);
23+
// // Send initial wallet connection message
24+
// handleSend(`Connected wallet: ${address}`);
2625
}
2726
}, [address, connected]);
2827

apps/web/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import express, { Application } from 'express';
22
import cors from 'cors';
33
import v1routes from './routes/v1';
44
import { connectDB } from './utils/db';
5-
import queryRouter from './routes/v1/query';
5+
//import queryRouter from './routes/v1/query';
66

77
/**
88
* Express application instance.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ queryRouter.get('/health', (req: Request, res: Response) => {
1515
// Query endpoint
1616
const handleQuery = async (req: Request, res: Response): Promise<void> => {
1717
try {
18+
1819
const { query, walletAddress } = req.body;
20+
1921

2022
if (!query) {
2123
res.status(400).json({
2224
error: 'Missing query in request body'
2325
});
26+
2427
return;
2528
}
26-
2729
// Get agent response first
28-
const result = await suiAgent.SuperVisorAgent(query);
30+
const result = await suiAgent.SuperVisorAgent(query,walletAddress);
2931

3032
// Only try to save chat history if walletAddress is provided
3133
if (walletAddress) {

apps/web/src/types/global.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import mongoose from 'mongoose';
1+
// import mongoose from 'mongoose';
22

3-
declare global {
4-
var _mongooseCache: {
5-
conn: typeof mongoose | null;
6-
promise: Promise<typeof mongoose> | null;
7-
} | undefined;
8-
}
3+
// declare global {
4+
// var _mongooseCache: {
5+
// conn: typeof mongoose | null;
6+
// promise: Promise<typeof mongoose> | null;
7+
// } | undefined;
8+
// }
99

10-
// Augment the NodeJS namespace to include our custom property
11-
declare module 'node:process' {
12-
global: typeof globalThis & {
13-
_mongooseCache?: {
14-
conn: typeof mongoose | null;
15-
promise: Promise<typeof mongoose> | null;
16-
};
17-
};
18-
}
10+
// // Augment the NodeJS namespace to include our custom property
11+
// declare module 'node:process' {
12+
// global: typeof globalThis & {
13+
// _mongooseCache?: {
14+
// conn: typeof mongoose | null;
15+
// promise: Promise<typeof mongoose> | null;
16+
// };
17+
// };
18+
// }
1919

20-
export {};
20+
// export {};

apps/web/src/utils/db.ts

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,20 @@ if (!MONGODB_URI) {
66
throw new Error('Please define the MONGODB_URI environment variable');
77
}
88

9-
// Type the global object with our custom property
10-
const globalWithMongoose = global as typeof globalThis & {
11-
_mongooseCache?: {
12-
conn: typeof mongoose | null;
13-
promise: Promise<typeof mongoose> | null;
14-
};
15-
};
16-
17-
// Initialize the cache if it doesn't exist
18-
if (!globalWithMongoose._mongooseCache) {
19-
globalWithMongoose._mongooseCache = { conn: null, promise: null };
20-
}
21-
229
export async function connectDB() {
23-
// At this point we know _mongooseCache exists because we initialized it above
24-
const mongooseCache = globalWithMongoose._mongooseCache!;
25-
26-
if (mongooseCache.conn) {
27-
return mongooseCache.conn;
28-
}
29-
30-
if (!mongooseCache.promise) {
31-
const opts = {
32-
bufferCommands: false,
33-
};
34-
35-
mongooseCache.promise = mongoose.connect(MONGODB_URI!, opts).then((mongoose) => {
36-
return mongoose;
37-
});
38-
}
39-
4010
try {
41-
const mongoose = await mongooseCache.promise;
42-
mongooseCache.conn = mongoose;
11+
await mongoose.connect(MONGODB_URI|| '');
4312
console.log('Connected to MongoDB');
4413
return mongoose;
45-
} catch (e) {
46-
mongooseCache.promise = null;
47-
console.error('MongoDB connection error:', e);
48-
throw e;
14+
} catch (error) {
15+
console.error('MongoDB connection error:', error);
16+
throw error;
4917
}
5018
}
5119

5220
export async function disconnectDB() {
5321
try {
5422
await mongoose.disconnect();
55-
// At this point we know _mongooseCache exists because we initialized it above
56-
const mongooseCache = globalWithMongoose._mongooseCache!;
57-
mongooseCache.conn = null;
58-
mongooseCache.promise = null;
5923
console.log('Disconnected from MongoDB');
6024
} catch (error) {
6125
console.error('MongoDB disconnection error:', error);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Agents {
3030
* @param prompt - User's input query
3131
* @returns IntentAgentResponse containing tool selection and processing details
3232
*/
33-
async IntentAgent(prompt: string) {
33+
async IntentAgent(prompt: string,address?:string) {
3434
const IntentResponse: IntentAgentResponse =
35-
(await this.tools.selectAppropriateTool(prompt)) as IntentAgentResponse;
35+
(await this.tools.selectAppropriateTool(prompt,address)) as IntentAgentResponse;
3636

3737
return IntentResponse;
3838
}
@@ -61,9 +61,9 @@ class Agents {
6161
* @param prompt - User's input query
6262
* @returns Final processed response
6363
*/
64-
async SuperVisorAgent(prompt: string) {
64+
async SuperVisorAgent(prompt: string,walletAddress?:string) {
6565
// Process intent
66-
const res = await this.IntentAgent(prompt);
66+
const res = await this.IntentAgent(prompt, walletAddress);
6767
console.log('Intent Response:', res);
6868

6969
// Make decision based on intent

packages/sui-agent/src/protocols/navi/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async function checkUserLiquidations(address: string) {
127127
},
128128
});
129129
const liquidations = response.data;
130-
console.log(liquidations.result.rows, 'liquidations');
130+
131131
return {
132132
asUser: liquidations.result.rows.filter(
133133
(l: Liquidation) => l.user === address,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ class Tools {
4444
* @param query - User query
4545
* @returns Selected tool response or null if no tool found
4646
*/
47-
async selectAppropriateTool(query: string): Promise<toolResponse | null> {
48-
console.log(this.getAllTools());
47+
async selectAppropriateTool(query: string,walletAddress?:string): Promise<toolResponse | null> {
48+
4949
const finalPrompt = this.prompt.replace(
5050
'${toolsList}',
5151
JSON.stringify(this.getAllTools()),
5252
);
5353

54+
5455
const response = await atomaChat(this.sdk, [
5556
{
56-
content: finalPrompt,
57+
content: walletAddress?`${finalPrompt}.Wallet address is ${walletAddress}.`:finalPrompt,
5758
role: 'system',
5859
},
5960
{

0 commit comments

Comments
 (0)