Skip to content

Commit 82657b9

Browse files
authored
fix: added multiple fixes (#40)
1 parent 95cadd2 commit 82657b9

File tree

10 files changed

+33
-28
lines changed

10 files changed

+33
-28
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Our goal is to create a full-fledged agent system using the Atoma's distributed
2424
- npm or yarn
2525
- Basic understanding of blockchain concepts
2626

27+
28+
# Create and configure the .env file
29+
30+
You can use the [.env.example](apps/web/.env.example)
31+
32+
2733
### Installation
2834

2935
```bash
@@ -34,6 +40,7 @@ git clone https://github.com/atoma-network/atoma-agents.git
3440
cd atoma-agents
3541
pnpm install
3642

43+
3744
# Start the development server
3845
pnpm run dev
3946
```
@@ -88,14 +95,14 @@ You can interact with the agent using either cURL or Postman.
8895

8996
```bash
9097
# Example query
91-
curl -X POST http://localhost:2512/v1/query \
98+
curl -X POST http://localhost:2512/query \
9299
-H "Content-Type: application/json" \
93100
-d '{"query": "what is the price of sui and btc"}'
94101
```
95102

96103
### Using Postman
97104

98-
1. Create a new POST request to `http://localhost:2512/v1/query`
105+
1. Create a new POST request to `http://localhost:2512/query`
99106
2. Set the Content-Type header to `application/json`
100107
3. In the request body, add your query:
101108

apps/web/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ PORT=2512
55
# Get your bearer token from https://atoma.network
66
ATOMASDK_BEARER_AUTH=
77
# Specify the Atoma chat model to use
8-
ATOMA_CHAT_COMPLETIONS_MODEL=meta-llama/Llama-3.3-70B-Instruct
8+
ATOMA_CHAT_COMPLETIONS_MODEL=
99

1010
MONGODB_URI=
1111

1212
# Secret Key Configuration
1313
# Generate a secure key using the following command in Node.js:
14-
#
14+
#
1515
# require('crypto').randomBytes(32).toString('hex')
1616
#
1717
# Copy and paste the generated key below:

apps/web/src/app.ts

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

76
/**
87
* Express application instance.

apps/web/src/logs/atomaHealth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const checkAtomaSDK = async (bearerAuth: string): Promise<void> => {
6363
role: 'user',
6464
content: 'Hi, are you there?'
6565
}
66-
]),
66+
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL),
6767
timeoutPromise(30000)
6868
])) as ChatResponse;
6969

packages/sui-agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@cetusprotocol/cetus-sui-clmm-sdk": "^5.3.1",
2424
"@mysten/sui": "1.1.0",
2525
"aftermath-ts-sdk": "^1.2.53",
26-
"atoma-sdk": "github:atoma-network/atoma-sdk-typescript",
26+
"atoma-sdk": "0.1.1",
2727
"axios": "^1.7.9",
2828
"bn.js": "^5.2.1",
2929
"dotenv": "^16.4.7",

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Agents {
6161
return await this.AtomaClass.atomaChat([
6262
{ content: decomposerPrompt, role: 'assistant' },
6363
{ content: prompt, role: 'user' },
64-
]);
64+
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);
6565
}
6666

6767
/**
@@ -119,9 +119,9 @@ class Agents {
119119
async processUserQueryPipeline(prompt: string, walletAddress?: string) {
120120
// Process intent
121121
const decomposer = await this.QueryDecomposer(prompt);
122-
const decomposed: string[] = JSON.parse(
123-
decomposer.choices[0].message.content,
124-
);
122+
const jsonContent = decomposer.choices[0].message.content.replace(/```json\n|\n```/g, '').trim();
123+
console.log(jsonContent, 'jsonContent');
124+
const decomposed: string[] = JSON.parse(jsonContent);
125125
console.log(decomposed);
126126
const res = await this.toolsSelector(decomposed, walletAddress);
127127
console.log(res, 'this is intent agent response');

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dotenv.config();
1212
* - Add model selection based on query complexity
1313
*/
1414
const ATOMA_CHAT_COMPLETIONS_MODEL =
15-
process.env.ATOMA_CHAT_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
15+
process.env.ATOMA_CHAT_COMPLETIONS_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
1616
console.log(ATOMA_CHAT_COMPLETIONS_MODEL);
1717

1818
/**
@@ -72,9 +72,9 @@ class Atoma {
7272
model?: string,
7373
) {
7474
console.log('**************');
75-
console.log('using atoma chat');
75+
console.log('using atoma chat with model', model);
7676
console.log('**************');
77-
return await new AtomaSDK({ bearerAuth: this.bearerAuth }).chat.create({
77+
return await new AtomaSDK({ bearerAuth: this.bearerAuth }).confidentialChat.create({
7878
messages: messages,
7979
model: model || 'meta-llama/Llama-3.3-70B-Instruct',
8080
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class Utils {
184184
const finalAns = await AtomaInstance.atomaChat([
185185
{ role: 'assistant', content: finalPrompt },
186186
{ role: 'user', content: query },
187-
]);
187+
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);
188188

189189
const res = finalAns.choices[0].message.content;
190190
const parsedRes = JSON.parse(res);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ class Tools {
8787
const response = await AtomaClass.atomaChat([
8888
{ role: 'assistant', content: promptWithAddr },
8989
{ role: 'user', content: query },
90-
]);
90+
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);
9191

9292
if (
9393
response &&
9494
'choices' in response &&
9595
response.choices[0]?.message?.content
9696
) {
97-
console.log(response.choices[0].message.content);
98-
const parsedContent = JSON.parse(response.choices[0].message.content);
97+
const jsonContent = response.choices[0].message.content.replace(/```json\n|\n```/g, '').trim();
98+
const parsedContent = JSON.parse(jsonContent);
9999
if (Array.isArray(parsedContent) && parsedContent.length > 0) {
100100
return parsedContent as toolResponse[];
101101
}

pnpm-lock.yaml

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)