Skip to content

Commit 2fe8bef

Browse files
committed
Fix JSONVault shared vault option
SDK : Add LLM prompting with attachment SDK : Add Support for attachments processing with agent skills Updated examples and documentation
1 parent e40af9e commit 2fe8bef

File tree

25 files changed

+625
-56
lines changed

25 files changed

+625
-56
lines changed

examples/01-agent-code-skill/01-prompting.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Agent, Scope } from '@smythos/sdk';
33
async function main() {
44
const agent = new Agent({
55
id: 'crypto-market-assistant',
6-
teamId: 'the-matrix',
6+
77
name: 'CryptoMarket Assistant',
88
behavior: 'You are a crypto price tracker. You are given a coin id and you need to get the price of the coin in USD',
99
model: 'gpt-4o',
@@ -19,9 +19,28 @@ async function main() {
1919
return data.market_data;
2020
},
2121
});
22+
const imgSkill = agent.addSkill({
23+
name: 'ImageAnalyser',
24+
description: 'Any attachment should be processed by this function',
25+
process: async ({ image_url }) => {
26+
console.log(image_url);
27+
return 'Image analysed';
28+
},
29+
});
30+
// imgSkill.in({
31+
// image_url : {
32+
// type:'Binary',
33+
// description:'The image url that we will analyze'
34+
// }
35+
// })
36+
37+
38+
39+
const prompt = await agent.prompt('Analyze this image please ', {
40+
files: ['https://www.robuxio.com/wp-content/uploads/2023/05/Trend.png'],
41+
});
42+
console.log(prompt);
2243

23-
const storage = agent.storage.LocalStorage({ scope: Scope.TEAM });
24-
await storage.write('test0001.txt', 'Hello, world!');
2544

2645
//this will prompt the agent and use the agent's LLM to determine which skill to use
2746
const promptResult = await agent.prompt('What are the current prices of Bitcoin and Ethereum ?');
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Agent, Scope } from '@smythos/sdk';
2+
3+
async function main() {
4+
//in this example, the image is processed by the native agent LLM
5+
6+
7+
const agent = new Agent({
8+
id: 'image-analyser',
9+
name: 'Image Analyser',
10+
behavior: 'You are an image analyser. You are given an image and you need to analyse it',
11+
model: 'gpt-4o',
12+
});
13+
14+
15+
16+
const prompt = await agent.prompt('Describe this image please ', {
17+
//you can pass your attachments in files array
18+
//it supports local files, remote urls, smythfs:// urls, Buffers or Blobs
19+
files: ['https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/VanGogh-starry_night_ballance1.jpg/960px-VanGogh-starry_night_ballance1.jpg'],
20+
});
21+
console.log(prompt);
22+
23+
24+
}
25+
26+
main();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Agent, Scope } from '@smythos/sdk';
2+
3+
async function main() {
4+
//in this example, we will skip the native LLM image processing, and we will let the agent delegate it to the appropriate skill
5+
6+
const agent = new Agent({
7+
id: 'image-analyser',
8+
name: 'Image Analyser',
9+
behavior: 'You are an image analyser. You are given an image and you need to analyse it',
10+
model: 'gpt-4o',
11+
});
12+
13+
//First we define the skill that will handle the image
14+
const imgSkill = agent.addSkill({
15+
name: 'ImageAnalyser',
16+
description: 'Any attachment should be processed by this function',
17+
process: async ({ image_url }) => {
18+
//Here the image_url will be passed as smythfs:// url
19+
//we can extract it using agent.storage functions
20+
21+
console.log(image_url);
22+
return 'Image analysed';
23+
},
24+
});
25+
//very important, we need to force the input type of image_url to Binary
26+
//this will tell our agent to skip the native LLM image processing, and use the agent skill instead
27+
imgSkill.in({
28+
image_url : {
29+
type:'Binary',
30+
description:'The image url that we will analyze'
31+
}
32+
})
33+
34+
35+
const prompt = await agent.prompt('Analyze this image please ', {
36+
//you can pass your attachments in files array
37+
//it supports local files, remote urls, smythfs:// urls, Buffers or Blobs
38+
files: ['https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/VanGogh-starry_night_ballance1.jpg/960px-VanGogh-starry_night_ballance1.jpg'],
39+
});
40+
console.log(prompt);
41+
42+
43+
}
44+
45+
main();

examples/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SmythOS SRE Examples
2+
3+
This directory contains a collection of examples demonstrating how to use the SmythOS SRE (Smyth Runtime Environment) and its various features.
4+
5+
Each example is a standalone script that can be run to see a specific part of the system in action.
6+
7+
## Running Examples
8+
9+
You can run any example using `npm`, `pnpm`, or `yarn`. Simply provide the path to the example file you want to run.
10+
11+
### With NPM
12+
13+
```bash
14+
npm start <path_to_example.ts>
15+
```
16+
17+
### With PNPM
18+
19+
```bash
20+
pnpm start <path_to_example.ts>
21+
```
22+
23+
### With Yarn
24+
25+
```bash
26+
yarn start <path_to_example.ts>
27+
```
28+
29+
For instance, to run an example located at `01-agent-code-skill/01-prompting.ts`, you would execute:
30+
31+
```bash
32+
npm start ./01-agent-code-skill/01-prompting.ts
33+
```

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@smythos/examples",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"private": true,
55
"description": "SmythOS SDK Examples",
66
"type": "module",
77
"author": "Alaa-eddine KADDOURI",
88
"license": "MIT",
99
"scripts": {
10-
"try": "tsx"
10+
"start": "tsx"
1111
},
1212
"dependencies": {
1313
"@smythos/sdk": "workspace:*",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sre",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/cli/oclif.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,5 @@
195195
]
196196
}
197197
},
198-
"version": "0.2.11"
198+
"version": "0.2.12"
199199
}

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/cli",
3-
"version": "0.2.11",
3+
"version": "0.2.12",
44
"description": "SmythOS SRE Command Line Interface",
55
"keywords": [
66
"smythos",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sre",
3-
"version": "1.5.12",
3+
"version": "1.5.13",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

0 commit comments

Comments
 (0)