Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Our goal is to create a full-fledged agent system using the Atoma's distributed
- npm or yarn
- Basic understanding of blockchain concepts


# Create and configure the .env file

You can use the [.env.example](apps/web/.env.example)


### Installation

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


# Start the development server
pnpm run dev
```
Expand Down Expand Up @@ -88,14 +95,14 @@ You can interact with the agent using either cURL or Postman.

```bash
# Example query
curl -X POST http://localhost:2512/v1/query \
curl -X POST http://localhost:2512/query \
-H "Content-Type: application/json" \
-d '{"query": "what is the price of sui and btc"}'
```

### Using Postman

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

Expand Down
4 changes: 2 additions & 2 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ PORT=2512
# Get your bearer token from https://atoma.network
ATOMASDK_BEARER_AUTH=
# Specify the Atoma chat model to use
ATOMA_CHAT_COMPLETIONS_MODEL=meta-llama/Llama-3.3-70B-Instruct
ATOMA_CHAT_COMPLETIONS_MODEL=

MONGODB_URI=

# Secret Key Configuration
# Generate a secure key using the following command in Node.js:
#
#
# require('crypto').randomBytes(32).toString('hex')
#
# Copy and paste the generated key below:
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import express, { Application } from 'express';
import cors from 'cors';
import v1routes from './routes/v1';
import { connectDB } from './config/db';
//import queryRouter from './routes/v1/query';

/**
* Express application instance.
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/logs/atomaHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const checkAtomaSDK = async (bearerAuth: string): Promise<void> => {
role: 'user',
content: 'Hi, are you there?'
}
]),
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL),
timeoutPromise(30000)
])) as ChatResponse;

Expand Down
2 changes: 1 addition & 1 deletion packages/sui-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@cetusprotocol/cetus-sui-clmm-sdk": "^5.3.1",
"@mysten/sui": "1.1.0",
"aftermath-ts-sdk": "^1.2.53",
"atoma-sdk": "github:atoma-network/atoma-sdk-typescript",
"atoma-sdk": "0.1.1",
"axios": "^1.7.9",
"bn.js": "^5.2.1",
"dotenv": "^16.4.7",
Expand Down
8 changes: 4 additions & 4 deletions packages/sui-agent/src/agents/SuiAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Agents {
return await this.AtomaClass.atomaChat([
{ content: decomposerPrompt, role: 'assistant' },
{ content: prompt, role: 'user' },
]);
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);
}

/**
Expand Down Expand Up @@ -119,9 +119,9 @@ class Agents {
async processUserQueryPipeline(prompt: string, walletAddress?: string) {
// Process intent
const decomposer = await this.QueryDecomposer(prompt);
const decomposed: string[] = JSON.parse(
decomposer.choices[0].message.content,
);
const jsonContent = decomposer.choices[0].message.content.replace(/```json\n|\n```/g, '').trim();
console.log(jsonContent, 'jsonContent');
const decomposed: string[] = JSON.parse(jsonContent);
console.log(decomposed);
const res = await this.toolsSelector(decomposed, walletAddress);
console.log(res, 'this is intent agent response');
Expand Down
6 changes: 3 additions & 3 deletions packages/sui-agent/src/config/atoma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dotenv.config();
* - Add model selection based on query complexity
*/
const ATOMA_CHAT_COMPLETIONS_MODEL =
process.env.ATOMA_CHAT_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
process.env.ATOMA_CHAT_COMPLETIONS_MODEL || 'meta-llama/Llama-3.3-70B-Instruct';
console.log(ATOMA_CHAT_COMPLETIONS_MODEL);

/**
Expand Down Expand Up @@ -72,9 +72,9 @@ class Atoma {
model?: string,
) {
console.log('**************');
console.log('using atoma chat');
console.log('using atoma chat with model', model);
console.log('**************');
return await new AtomaSDK({ bearerAuth: this.bearerAuth }).chat.create({
return await new AtomaSDK({ bearerAuth: this.bearerAuth }).confidentialChat.create({
messages: messages,
model: model || 'meta-llama/Llama-3.3-70B-Instruct',
});
Expand Down
2 changes: 1 addition & 1 deletion packages/sui-agent/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Utils {
const finalAns = await AtomaInstance.atomaChat([
{ role: 'assistant', content: finalPrompt },
{ role: 'user', content: query },
]);
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);

const res = finalAns.choices[0].message.content;
const parsedRes = JSON.parse(res);
Expand Down
6 changes: 3 additions & 3 deletions packages/sui-agent/src/utils/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ class Tools {
const response = await AtomaClass.atomaChat([
{ role: 'assistant', content: promptWithAddr },
{ role: 'user', content: query },
]);
], process.env.ATOMA_CHAT_COMPLETIONS_MODEL);

if (
response &&
'choices' in response &&
response.choices[0]?.message?.content
) {
console.log(response.choices[0].message.content);
const parsedContent = JSON.parse(response.choices[0].message.content);
const jsonContent = response.choices[0].message.content.replace(/```json\n|\n```/g, '').trim();
const parsedContent = JSON.parse(jsonContent);
if (Array.isArray(parsedContent) && parsedContent.length > 0) {
return parsedContent as toolResponse[];
}
Expand Down
19 changes: 9 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.