@yesvara/svara 0.2.2 → 0.2.4
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/cli/index.js +3 -3
- package/dist/cli/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{new-ULRP6IUQ.mjs → new-CKIQEA2K.mjs} +3 -3
- package/my-agent/.env.example +4 -0
- package/my-agent/docs/README.md +3 -0
- package/my-agent/package.json +19 -0
- package/my-agent/src/index.ts +35 -0
- package/my-agent/tsconfig.json +19 -0
- package/package.json +1 -1
- package/src/cli/commands/new.ts +3 -3
- package/src/core/agent.ts +1 -1
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 @yesvara/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/cli/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function generateEnvExample(provider, channels) {
|
|
|
140
140
|
}
|
|
141
141
|
function generateIndexFile(name, provider, channels) {
|
|
142
142
|
const modelMap = {
|
|
143
|
-
openai: "gpt-4o",
|
|
143
|
+
openai: "gpt-4o-mini",
|
|
144
144
|
anthropic: "claude-opus-4-6",
|
|
145
145
|
ollama: "llama3"
|
|
146
146
|
};
|
|
@@ -181,10 +181,10 @@ const timeTool = createTool({
|
|
|
181
181
|
// Create agent
|
|
182
182
|
const agent = new SvaraAgent({
|
|
183
183
|
name: '${name}',
|
|
184
|
-
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
184
|
+
model: '${modelMap[provider] ?? "gpt-4o-mini"}',
|
|
185
185
|
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
186
186
|
tools: [timeTool],
|
|
187
|
-
knowledge: './docs', // Add your documents here for RAG
|
|
187
|
+
knowledge: './docs/**/*', // Add your documents here for RAG
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
// Setup channels
|
package/dist/cli/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ var pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
|
9
9
|
var program = new Command();
|
|
10
10
|
program.name("svara").description(pkg.description).version(pkg.version, "-v, --version");
|
|
11
11
|
program.command("new <name>").description("Create a new SvaraJS project").option("--provider <provider>", "LLM provider (openai|anthropic|ollama)", "openai").option("--channel <channels...>", "Channels to include", ["web"]).option("--no-install", "Skip npm install").action(async (name, opts) => {
|
|
12
|
-
const { newProject } = await import("../new-
|
|
12
|
+
const { newProject } = await import("../new-CKIQEA2K.mjs");
|
|
13
13
|
await newProject({
|
|
14
14
|
name,
|
|
15
15
|
provider: opts.provider,
|
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,
|
|
@@ -109,7 +109,7 @@ function generateEnvExample(provider, channels) {
|
|
|
109
109
|
}
|
|
110
110
|
function generateIndexFile(name, provider, channels) {
|
|
111
111
|
const modelMap = {
|
|
112
|
-
openai: "gpt-4o",
|
|
112
|
+
openai: "gpt-4o-mini",
|
|
113
113
|
anthropic: "claude-opus-4-6",
|
|
114
114
|
ollama: "llama3"
|
|
115
115
|
};
|
|
@@ -150,10 +150,10 @@ const timeTool = createTool({
|
|
|
150
150
|
// Create agent
|
|
151
151
|
const agent = new SvaraAgent({
|
|
152
152
|
name: '${name}',
|
|
153
|
-
model: '${modelMap[provider] ?? "gpt-4o"}',
|
|
153
|
+
model: '${modelMap[provider] ?? "gpt-4o-mini"}',
|
|
154
154
|
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
155
155
|
tools: [timeTool],
|
|
156
|
-
knowledge: './docs', // Add your documents here for RAG
|
|
156
|
+
knowledge: './docs/**/*', // Add your documents here for RAG
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
// Setup channels
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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!');
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
package/src/cli/commands/new.ts
CHANGED
|
@@ -142,7 +142,7 @@ function generateIndexFile(
|
|
|
142
142
|
channels: string[]
|
|
143
143
|
): string {
|
|
144
144
|
const modelMap: Record<string, string> = {
|
|
145
|
-
openai: 'gpt-4o',
|
|
145
|
+
openai: 'gpt-4o-mini',
|
|
146
146
|
anthropic: 'claude-opus-4-6',
|
|
147
147
|
ollama: 'llama3',
|
|
148
148
|
};
|
|
@@ -184,10 +184,10 @@ const timeTool = createTool({
|
|
|
184
184
|
// Create agent
|
|
185
185
|
const agent = new SvaraAgent({
|
|
186
186
|
name: '${name}',
|
|
187
|
-
model: '${modelMap[provider] ?? 'gpt-4o'}',
|
|
187
|
+
model: '${modelMap[provider] ?? 'gpt-4o-mini'}',
|
|
188
188
|
systemPrompt: 'You are a helpful AI assistant. Be concise and friendly.',
|
|
189
189
|
tools: [timeTool],
|
|
190
|
-
knowledge: './docs', // Add your documents here for RAG
|
|
190
|
+
knowledge: './docs/**/*', // Add your documents here for RAG
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
// Setup channels
|
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.`;
|