@yesvara/svara 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -24
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/core/agent.ts +1 -1
- package/my-agent/.env.example +0 -4
- package/my-agent/docs/README.md +0 -3
- package/my-agent/package.json +0 -19
- package/my-agent/src/index.ts +0 -35
- package/my-agent/tsconfig.json +0 -19
package/README.md
CHANGED
|
@@ -65,40 +65,31 @@ That's it. No pipeline setup. No embedding boilerplate. No webhook configuration
|
|
|
65
65
|
```bash
|
|
66
66
|
npm install @yesvara/svara
|
|
67
67
|
```
|
|
68
|
-
|
|
69
|
-
### 2. Set your API key
|
|
68
|
+
### 2. Create a new project
|
|
70
69
|
|
|
71
70
|
```bash
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
npx svara new my-agent
|
|
72
|
+
cd my-agent
|
|
74
73
|
```
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
// src/index.ts
|
|
80
|
-
import 'dotenv/config';
|
|
81
|
-
import { SvaraApp, SvaraAgent } from '@yesvara/svara';
|
|
75
|
+
This scaffolds a ready-to-run project with TypeScript, tools, and RAG setup.
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const agent = new SvaraAgent({
|
|
86
|
-
name: 'Aria',
|
|
87
|
-
model: 'gpt-4o-mini',
|
|
88
|
-
systemPrompt: 'You are Aria, a helpful and friendly AI assistant.',
|
|
89
|
-
});
|
|
77
|
+
### 3. Configure API keys
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
```bash
|
|
80
|
+
nano .env
|
|
81
|
+
# Edit .env and add your API keys
|
|
82
|
+
OPENAI_API_KEY=sk-...
|
|
93
83
|
```
|
|
94
84
|
|
|
95
|
-
### 4. Run
|
|
85
|
+
### 4. Run the agent
|
|
96
86
|
|
|
97
87
|
```bash
|
|
98
|
-
npx
|
|
88
|
+
npx svara dev
|
|
89
|
+
# Server running at http://localhost:3000
|
|
99
90
|
```
|
|
100
91
|
|
|
101
|
-
### 5. Chat
|
|
92
|
+
### 5. Chat with your agent
|
|
102
93
|
|
|
103
94
|
```bash
|
|
104
95
|
curl -X POST http://localhost:3000/chat \
|
|
@@ -112,13 +103,27 @@ curl -X POST http://localhost:3000/chat \
|
|
|
112
103
|
|
|
113
104
|
```json
|
|
114
105
|
{
|
|
115
|
-
"response": "Hi! I'm
|
|
106
|
+
"response": "Hi! I'm my-agent, your AI assistant...",
|
|
116
107
|
"sessionId": "user-1-session-1",
|
|
117
108
|
"usage": { "totalTokens": 142 }
|
|
118
109
|
}
|
|
119
110
|
```
|
|
120
111
|
|
|
121
|
-
|
|
112
|
+
### 6. (Optional) Customize your agent
|
|
113
|
+
|
|
114
|
+
Edit `src/index.ts` to customize:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const agent = new SvaraAgent({
|
|
118
|
+
name: 'My Awesome Bot',
|
|
119
|
+
model: 'gpt-4o-mini', // Change model
|
|
120
|
+
systemPrompt: 'Custom personality here', // Custom behavior
|
|
121
|
+
knowledge: './docs/**/*', // Add RAG documents
|
|
122
|
+
tools: [yourTools], // Add tools
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Add more documents anytime — just drop files in `docs/` and restart.
|
|
122
127
|
|
|
123
128
|
---
|
|
124
129
|
|
package/dist/index.js
CHANGED
|
@@ -1708,7 +1708,7 @@ var SvaraAgent = class extends import_events.default {
|
|
|
1708
1708
|
this.name = config.name;
|
|
1709
1709
|
this.maxIterations = config.maxIterations ?? 10;
|
|
1710
1710
|
this.verbose = config.verbose ?? false;
|
|
1711
|
-
this.db = new SvaraDB(
|
|
1711
|
+
this.db = new SvaraDB(`./data/${config.name}.db`);
|
|
1712
1712
|
this.systemPrompt = config.systemPrompt ?? `You are ${config.name}, a helpful and friendly AI assistant. Be concise and accurate.`;
|
|
1713
1713
|
this.llmConfig = resolveConfig(config.model, {
|
|
1714
1714
|
temperature: config.temperature,
|
package/dist/index.mjs
CHANGED
|
@@ -898,7 +898,7 @@ var SvaraAgent = class extends EventEmitter {
|
|
|
898
898
|
this.name = config.name;
|
|
899
899
|
this.maxIterations = config.maxIterations ?? 10;
|
|
900
900
|
this.verbose = config.verbose ?? false;
|
|
901
|
-
this.db = new SvaraDB(
|
|
901
|
+
this.db = new SvaraDB(`./data/${config.name}.db`);
|
|
902
902
|
this.systemPrompt = config.systemPrompt ?? `You are ${config.name}, a helpful and friendly AI assistant. Be concise and accurate.`;
|
|
903
903
|
this.llmConfig = resolveConfig(config.model, {
|
|
904
904
|
temperature: config.temperature,
|
package/package.json
CHANGED
package/src/core/agent.ts
CHANGED
|
@@ -182,7 +182,7 @@ export class SvaraAgent extends EventEmitter {
|
|
|
182
182
|
this.name = config.name;
|
|
183
183
|
this.maxIterations = config.maxIterations ?? 10;
|
|
184
184
|
this.verbose = config.verbose ?? false;
|
|
185
|
-
this.db = new SvaraDB(
|
|
185
|
+
this.db = new SvaraDB(`./data/${config.name}.db`);
|
|
186
186
|
|
|
187
187
|
this.systemPrompt = config.systemPrompt
|
|
188
188
|
?? `You are ${config.name}, a helpful and friendly AI assistant. Be concise and accurate.`;
|
package/my-agent/.env.example
DELETED
package/my-agent/docs/README.md
DELETED
package/my-agent/package.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "my-agent",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "tsx watch src/index.ts",
|
|
7
|
-
"build": "tsc",
|
|
8
|
-
"start": "node dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"@yesvara/svara": "^0.1.3",
|
|
12
|
-
"dotenv": "^16.4.5"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/node": "^20.14.2",
|
|
16
|
-
"tsx": "^4.15.7",
|
|
17
|
-
"typescript": "^5.4.5"
|
|
18
|
-
}
|
|
19
|
-
}
|
package/my-agent/src/index.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { SvaraApp, SvaraAgent, createTool } from '@yesvara/svara';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* my-agent — powered by SvaraJS
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Define tools
|
|
9
|
-
const timeTool = createTool({
|
|
10
|
-
name: 'get_time',
|
|
11
|
-
description: 'Get the current date and time',
|
|
12
|
-
parameters: {},
|
|
13
|
-
async run() {
|
|
14
|
-
return {
|
|
15
|
-
datetime: new Date().toISOString(),
|
|
16
|
-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Create agent
|
|
22
|
-
const agent = new SvaraAgent({
|
|
23
|
-
name: 'my-agent',
|
|
24
|
-
model: 'gpt-4o',
|
|
25
|
-
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
26
|
-
tools: [timeTool],
|
|
27
|
-
knowledge: './docs', // Add your documents here for RAG
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Setup channels
|
|
31
|
-
const app = new SvaraApp({ cors: true });
|
|
32
|
-
app.route('/chat', agent.handler());
|
|
33
|
-
app.listen(3000);
|
|
34
|
-
|
|
35
|
-
console.log('✨ my-agent is running!');
|
package/my-agent/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"rootDir": "src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true
|
|
11
|
-
},
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*"
|
|
14
|
-
],
|
|
15
|
-
"exclude": [
|
|
16
|
-
"node_modules",
|
|
17
|
-
"dist"
|
|
18
|
-
]
|
|
19
|
-
}
|