@indra.ai/deva.services 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Quinn Michaels
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # ServicesDeva
2
+ The Services Deva
package/data.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "Services Deva Data File",
3
+ "describe": "The main Data file for Services Deva",
4
+ "copyright": "Copyright (c)2023 Quinn Michaels. All rights reserved.",
5
+ "DATA": {
6
+ "agent": {
7
+ "id": 4855882658530,
8
+ "key": "services",
9
+ "model": "gpt3",
10
+ "prompt": {
11
+ "emoji": "🛠️ ",
12
+ "text": "Services",
13
+ "colors": {
14
+ "label": {
15
+ "R": 163,
16
+ "G": 163,
17
+ "B": 168
18
+ },
19
+ "text": {
20
+ "R": 240,
21
+ "G": 242,
22
+ "B": 136
23
+ }
24
+ }
25
+ },
26
+ "profile": {
27
+ "identity": "You are #ServicesDEVA in deva.world.",
28
+ "invoke": "#ServicesDEVA of deva.world",
29
+ "name": "Services Deva",
30
+ "mention": "@ServicesDEVA",
31
+ "tags": "#Services #ServicesDEVA",
32
+ "gender": "Deva",
33
+ "pronouns": "Male, Man, He, Him, His, Guy, Dude, Deva",
34
+ "creator": "Quinn Michaels",
35
+ "created": "May 22, 2023 at 10:14 AM",
36
+ "house": "House Deva",
37
+ "temple": "Kedarnath Temple (Vadari)",
38
+ "forest": "Pushkara",
39
+ "city": "Amaravati",
40
+ "region": "Svarga",
41
+ "land": "Visisipra",
42
+ "planet": "Arjika",
43
+ "loka": "Devaloka",
44
+ "verse": "Rikverse",
45
+ "system": "deva.world",
46
+ "agency": "indra.agency",
47
+ "describe": "Services Deva is the entity in deva.world multi-agent system that manages services for teh users and entites. Managing connection strings into various data sources or proving the built in services features and functions. Services Deva is here to make sure the necessary services are online and running that keep deva.world operation.",
48
+ "emoji": "/public/devas/services/emoji.png",
49
+ "avatar": "/public/devas/services/avatar.png",
50
+ "background": "/public/devas/services/background.png",
51
+ "color": "#ffffff",
52
+ "bgcolor": "#000000",
53
+ "voice": "onyx",
54
+ "style": "Has the style of a severvices technical draftsman. Artwork should be technical in nature, but a futuristic vibe."
55
+ }
56
+ },
57
+ "vars": {
58
+ "messages": {
59
+ "init": "🟠 INIT",
60
+ "start": "🔵 START",
61
+ "enter": "🟢 ENTER",
62
+ "stop": "🔴 STOP",
63
+ "exit": "🟡 EXIT",
64
+ "done": "🟣 DONE",
65
+ "error": "💣 ERROR!",
66
+ "label": "👨‍🔧SERVICES",
67
+ "signature": "@Services"
68
+ },
69
+ "live": {
70
+ "profile": "services",
71
+ "max_tokens": 50,
72
+ "words": 25,
73
+ "history": [],
74
+ "max_chats": 10,
75
+ "page_token": ""
76
+ },
77
+ "ask": {
78
+ "max_tokens": 500,
79
+ "words": 200,
80
+ "history": []
81
+ },
82
+ "reply": {
83
+ "profile": "services",
84
+ "max_tokens": 300,
85
+ "words": 100,
86
+ "history": []
87
+ },
88
+ "comment": {
89
+ "profile": "services",
90
+ "max_tokens": 300,
91
+ "words": 100,
92
+ "history": []
93
+ },
94
+ "art": {
95
+ "history": []
96
+ },
97
+ "trigger": "@SERVICES",
98
+ "context": {
99
+ "uid": "generating uid",
100
+ "status": "getting status",
101
+ "info": "getting info",
102
+ "feature": "accessing feature",
103
+ "issue": "has issues",
104
+ "help": "asking for help",
105
+ "ask": "Ask",
106
+ "live": "Livechat",
107
+ "comment": "Comment",
108
+ "reply": "Reply",
109
+ "art": "Create"
110
+ }
111
+ }
112
+ }
113
+ }
@@ -0,0 +1,613 @@
1
+ function buildProfile(profile, type='assistant') {
2
+ const _profile = [];
3
+ _profile.push(`::begin:${type}`);
4
+ for (let x in profile) {
5
+ _profile.push(`${x}: ${profile[x]}`);
6
+ }
7
+ _profile.push(`::end:${type}\n`);
8
+ return _profile.join('\n');
9
+ }
10
+ module.exports = {
11
+ /**************
12
+ method: service
13
+ params: packet
14
+ describe: The global service feature that installs with every agent
15
+ ***************/
16
+ services(packet) {
17
+ this.context('feature');
18
+ const services = this.services();
19
+ const data = {};
20
+ return new Promise((resolve, reject) => {
21
+ this.question(`#docs raw feature/services`).then(doc => {
22
+ data.doc = doc.a.data;
23
+ const info = [
24
+ `## Settings`,
25
+ `::begin:services:${services.id}`,
26
+ `client: ${services.client_name}`,
27
+ `concerns: ${services.concerns.join(', ')}`,
28
+ `::end:services:${this.hash(services)}`,
29
+ ].join('\n');
30
+ const text = doc.a.text.replace(/::info::/g, info)
31
+ return this.question(`#feecting parse ${text}`)
32
+ }).then(feecting => {
33
+ return this.finish({
34
+ text: feecting.a.text,
35
+ html: feecting.a.html,
36
+ data: services
37
+ }, resolve);
38
+ }).catch(err => {
39
+ return this.error(err, packet, reject);
40
+ })
41
+ });
42
+ },
43
+ comment(packet) {
44
+ return new Promise((resolve, reject) => {
45
+ if (!this.vars.comment) return resolve('NO COMMENT');
46
+ const agent = this.agent();
47
+ const profile = buildProfile(agent.profile);
48
+ const data = {};
49
+ const text = [];
50
+
51
+ const msg = [
52
+ `${packet.q.text}`,
53
+ `important: Respond in ${this.vars.comment.words} words or less.`,
54
+ ].join('\n');
55
+
56
+ this.question(`${this.askChr}docs view devas/${agent.key}:corpus`).then(corpus => {
57
+ data.corpus = corpus.a.data;
58
+
59
+ return this.question(`${this.askChr}open relay ${msg}`, {
60
+ model: agent.model || false,
61
+ profile,
62
+ corpus: corpus.a.text,
63
+ max_tokens: this.vars.comment.max_tokens,
64
+ history: this.vars.comment.history.slice(-10),
65
+ });
66
+ }).then(chat => {
67
+ data.chat = chat.a.data.chat;
68
+ text.push(chat.a.data.parsed);
69
+ this.vars.comment.history.push({
70
+ role: chat.a.data.chat.role,
71
+ content: chat.a.data.chat.text,
72
+ });
73
+ return this.question(`${this.askChr}youtube commentWrite:${this.vars.comment.profile} ${chat.a.text}`);
74
+ }).then(youtube => {
75
+ data.youtube = youtube.a.data;
76
+ text.push(youtube.a.text);
77
+
78
+ return this.question(`${this.askChr}feecting parse ${text.join('\n')}`);
79
+ }).then(feecting => {
80
+ return resolve({
81
+ text: feecting.a.text,
82
+ html: feecting.a.html,
83
+ data,
84
+ });
85
+ }).catch(err => {
86
+ console.log('THERE WAS AN ERROR', err);
87
+ return this.error(packet, err, reject);
88
+ });
89
+ });
90
+ },
91
+
92
+ /**************
93
+ method: ask
94
+ params: packet
95
+ describe: this method provides a global ask method to all agents.
96
+ ***************/
97
+ 'ask'(packet) {
98
+ this.context('ask', packet.q.agent.name);
99
+ this.action('feature', 'ask');
100
+ return new Promise((resolve, reject) => {
101
+ if (!this.vars.ask) return resolve('NO ASK');
102
+ const askAgent = packet.q.meta.params[1] ? false : true;
103
+ const text = [];
104
+ const data = {};
105
+ const agent = this.agent();
106
+ const client = this.client();
107
+ const info = this.info();
108
+
109
+ this.state('set', 'message');
110
+ const msg = [
111
+ `::begin:user:${client.id}`,
112
+ `id: ${client.id}`,
113
+ `name: ${client.profile.nickname}`,
114
+ `fullname: ${client.profile.name}`,
115
+ `date: ${this.formatDate(Date.now(), 'long', true)}`,
116
+ `::end:user`,
117
+ packet.q.text,
118
+ ].join('\n');
119
+
120
+ // get the agent main help file for teir corpus.
121
+ this.state('get', 'ask:help');
122
+ this.help('main', info.dir).then(corpus => {
123
+ this.action('parse', 'ask:corpus');
124
+ return this.question(`${this.askChr}feecting parse ${corpus}`);
125
+ }).then(doc => {
126
+ data.corpus = doc.a.data;
127
+ this.state('get', 'ask:chat');
128
+ return this.question(`${this.askChr}open relay ${msg}`, {
129
+ model: agent.model || false,
130
+ user: buildProfile(client.profile, 'user'),
131
+ corpus: doc.a.text,
132
+ max_tokens: this.vars.ask.max_tokens,
133
+ history: this.vars.ask.history.slice(-10),
134
+ memory: agent.key,
135
+ askAgent,
136
+ });
137
+ }).then(chat => {
138
+
139
+ text.push(`::begin:${agent.key}:${chat.id}`);
140
+ text.push(chat.a.data.parsed);
141
+ if (chat.a.text) {
142
+ text.push('::begin:buttons');
143
+ text.push(`button[🗣️ Speak]:${this.askChr}${agent.key} speak ${encodeURI(chat.a.text)}`);
144
+ text.push(`button[🎨 Art]:${this.askChr}${agent.key} art ${encodeURI(chat.a.text)}`);
145
+ text.push('::end:buttons');
146
+ }
147
+ text.push(`::end:${agent.key}:${chat.hash}`);
148
+
149
+ // memory event
150
+ this.talk('data:memory', {
151
+ id: chat.a.data.chat.id,
152
+ client,
153
+ agent,
154
+ q: packet.q.text,
155
+ a: chat.a.data.chat.text,
156
+ created: Date.now(),
157
+ });
158
+
159
+
160
+ data.chat = chat.a.data.chat;
161
+
162
+ this.state('set', 'ask:history');
163
+
164
+ this.vars.ask.history.push({
165
+ role: 'user',
166
+ content: this.trimWords(chat.q.text, 100),
167
+ });
168
+
169
+ this.vars.ask.history.push({
170
+ role: chat.a.data.chat.role,
171
+ content: this.trimWords(chat.a.data.chat.text, 100),
172
+ });
173
+
174
+ this.state('parse', 'ask:chat');
175
+ return this.question(`${this.askChr}feecting parse ${text.join('\n')}`);
176
+ }).then(feecting => {
177
+ data.feecting = feecting.a.data;
178
+ this.state('resolve', 'ask');
179
+ return resolve({
180
+ text: data.chat.text,
181
+ html: feecting.a.html,
182
+ data,
183
+ });
184
+ }).catch(err => {
185
+ this.state('reject', 'ask');
186
+ return this.error(packet, err, reject);
187
+ });
188
+ });
189
+ },
190
+
191
+ live(packet) {
192
+ return new Promise((resolve, reject) => {
193
+ if (!this.vars.live) return resolve('NO LIVE');
194
+
195
+ const agent = this.agent();
196
+ const client = this.client();
197
+ const info = this.info();
198
+ const profile = buildProfile(agent.profile);
199
+ const data = {};
200
+ let text, corpus;
201
+
202
+ this.state('get', 'live:help');
203
+
204
+ this.help('main', info.dir).then(help => {
205
+ this.action('parse', 'ask:help');
206
+ return this.question(`${this.askChr}feecting parse ${help}`);
207
+
208
+ }).then(doc => {
209
+ data.corpus = doc.a.data;
210
+ corpus = doc.a.text;
211
+
212
+ this.state('set', 'chat message');
213
+ const msg = [
214
+ packet.q.text,
215
+ `important: Youtube chat has strict requirements, so please respond in ${this.vars.live.words} words or less.`,
216
+ ].join('\n');
217
+
218
+ this.action('get', 'open relay');
219
+
220
+ return this.question(`${this.askChr}open relay ${msg}`, {
221
+ model: agent.model || false,
222
+ profile,
223
+ corpus,
224
+ max_tokens: this.vars.live.max_tokens,
225
+ history: this.vars.live.history.slice(-10),
226
+ });
227
+
228
+ }).then(chat => {
229
+ console.log('CHAT RESPONSE... ', JSON.stringify(chat, null, 2));
230
+ this.state('set', 'chat data');
231
+ data.chat = chat.a.data.chat;
232
+ text = chat.a.data.parsed;
233
+
234
+ this.action('talk', 'data:memory');
235
+ // memory event
236
+ this.talk('data:memory', {
237
+ id: chat.a.data.chat.id,
238
+ client,
239
+ agent,
240
+ q: packet.q.text,
241
+ a: chat.a.data.chat.text,
242
+ created: Date.now(),
243
+ });
244
+
245
+ this.state('set', 'history:user');
246
+ this.vars.live.history.push({
247
+ role: 'user',
248
+ content: chat.q.text,
249
+ });
250
+
251
+ this.state('set', `history:${chat.a.data.chat.role}`);
252
+ this.vars.live.history.push({
253
+ role: chat.a.data.chat.role,
254
+ content: chat.a.data.chat.text,
255
+ });
256
+
257
+ this.action('send', `chat:${this.vars.live.profile}`);
258
+ return this.question(`${this.askChr}youtube chat:${this.vars.live.profile} ${chat.a.text.substr(0, 199)}`);
259
+
260
+ }).then(youtube => {
261
+ data.youtube = youtube.a.data;
262
+ this.action('parse', 'Youtube response');
263
+ return this.question(`${this.askChr}feecting parse ${text}`);
264
+
265
+ }).then(feecting => {
266
+ this.state('resolve', 'live');
267
+ return resolve({
268
+ text: feecting.a.text,
269
+ html: feecting.a.html,
270
+ data,
271
+ });
272
+
273
+ }).catch(err => {
274
+ this.state('reject', 'live');
275
+ console.log('LIVE ERROR', err);
276
+ return this.error(packet, err, reject);
277
+ });
278
+ });
279
+ },
280
+ /**************
281
+ method: livechat
282
+ params: packet
283
+ describe: Get the latest chats from a youtube stream and chat about it.
284
+ ***************/
285
+ livechat(packet) {
286
+ return new Promise((resolve, reject) => {
287
+ if (!this.vars.live) return resolve('NO LIVE');
288
+ const data = {};
289
+ this.action('get', 'Youtube chats');
290
+ this.question(`${this.askChr}youtube chats:${this.vars.live.max_chats}:${this.vars.live.page_token}`).then(chats => {
291
+
292
+ data.chats = chats.a.data;
293
+ this.vars.live.page_token = chats.a.data.messages.nextPageToken;
294
+ this.state('set', 'chat items');
295
+
296
+ const hasItems = chats.a.data.messages.items.length ? true : false;
297
+ const items = chats.a.data.messages.items.map(item => {
298
+ return `@${item.authorDetails.displayName}: ${item.snippet.displayMessage}`;
299
+ }).join('\n');
300
+
301
+ this.state('set', 'chat message');
302
+ const msg = ['::begin:chats'];
303
+ if (hasItems) {
304
+ msg.push(items);
305
+ }
306
+ msg.push(`${packet.q.client.profile.name}: ${packet.q.text}`);
307
+ msg.push('::end:chats');
308
+
309
+ this.action('get', 'open relay');
310
+
311
+ return this.methods.live(packet);
312
+ }).then(chat => {
313
+ this.state('resolve', 'live');
314
+ return resolve({
315
+ text: chat.text,
316
+ html: chat.html,
317
+ data: chat.data,
318
+ });
319
+ }).catch(err => {
320
+ this.state('reject', 'livechats');
321
+ console.log('LIVEchats ERROR', err);
322
+ return this.error(packet, err, reject);
323
+ });
324
+ });
325
+ },
326
+
327
+ /**************
328
+ method: doc
329
+ params: packet
330
+ describe: send a doc to the deva.
331
+ ***************/
332
+ docs(packet) {
333
+ this.action('feature', 'docs');
334
+ return new Promise((resolve, reject) => {
335
+
336
+ const data = {};
337
+ const agent = this.agent();
338
+ const profile = buildProfile(agent.profile, 'assistant');
339
+ const client = this.client();
340
+ const user = buildProfile(client.profile, 'user');
341
+ const info = this.info();
342
+ let corpus = false;
343
+
344
+ this.state('set', 'docs:text');
345
+ const text = [];
346
+
347
+ this.state('get', 'docs:help');
348
+ this.help('main', info.dir).then(corpus => {
349
+ this.action('parse', 'docs:corpus');
350
+ return this.question(`${this.askChr}feecting parse ${corpus}`);
351
+
352
+ }).then(_corpus => {
353
+ corpus = _corpus.a.text;
354
+ data.corpus = _corpus.a.data;
355
+ this.state('get', 'docs:document');
356
+ return this.question(`${this.askChr}docs view ${packet.q.text}`);
357
+
358
+ }).then(doc => {
359
+ data.doc = doc.a.data;
360
+ text.push(`::begin:document:${doc.id}`);
361
+ text.push(doc.a.text);
362
+ text.push(`::end:document:${this.hash(doc.a.text)}`);
363
+
364
+ return this.question(`${this.askChr}open relay ${text.join('\n')}`, {
365
+ model: agent.model || false,
366
+ corpus,
367
+ profile,
368
+ user,
369
+ max_tokens: this.vars.ask.max_tokens,
370
+ history: this.vars.ask.history.slice(-10),
371
+ memory: agent.key,
372
+ askAgent: false,
373
+ });
374
+
375
+ }).then(chat => {
376
+ data.chat = chat.a.data;
377
+ this.state('parse', 'docs:chat');
378
+
379
+ const msg = [
380
+ chat.a.data.parsed,
381
+ '::begin:buttons',
382
+ `button[🗣️ Speak]:${this.askChr}${agent.key} speak ${encodeURI(chat.a.text)}`,
383
+ `button[🎨 Art]:${this.askChr}${agent.key} art ${encodeURI(chat.a.text)}`,
384
+ '::end:buttons',
385
+ ].join('\n');
386
+
387
+ return this.question(`${this.askChr}feecting parse ${msg}`);
388
+ }).then(feecting => {
389
+ data.feecting = feecting.a.data;
390
+ this.state('resolve', 'docs');
391
+ return resolve({
392
+ text: feecting.a.text,
393
+ html: feecting.a.html,
394
+ data,
395
+ });
396
+
397
+ }).catch(err => {
398
+ this.state('reject', 'docs');
399
+ console.log('DOCS feature ERROR', err);
400
+ return this.error(err, packet, reject);
401
+ });
402
+ });
403
+ },
404
+
405
+ /**************
406
+ method: veda
407
+ params: packet
408
+ describe: send a veda hymn to the deva.
409
+ ***************/
410
+ veda(packet) {
411
+ this.action('feature', 'hymn');
412
+ return new Promise((resolve, reject) => {
413
+
414
+ const data = {};
415
+ const agent = this.agent();
416
+ const profile = buildProfile(agent.profile, 'assistant');
417
+ const client = this.client();
418
+ const user = buildProfile(client.profile, 'user');
419
+ const info = this.info();
420
+ let corpus = false;
421
+
422
+ this.state('get', 'agent:help');
423
+ this.help('main', info.dir).then(corpus => {
424
+ this.action('parse', 'docs:corpus');
425
+ return this.question(`${this.askChr}feecting parse ${corpus}`);
426
+ }).then(_corpus => {
427
+ corpus = _corpus.a.text;
428
+ data.corpus = _corpus.a.data;
429
+ this.state('get', 'veda:hymn');
430
+ return this.question(`${this.askChr}veda hymn ${packet.q.meta.params[1]}`);
431
+ }).then(hymn => {
432
+ data.hymn = hymn.a.data;
433
+ const text = [
434
+ hymn.a.text,
435
+ `---`,
436
+ `note: ${packet.q.text}`,
437
+ ].join('\n');
438
+ return this.question(`${this.askChr}open relay ${text}`, {
439
+ model: agent.model || false,
440
+ corpus,
441
+ profile,
442
+ user,
443
+ max_tokens: this.vars.ask.max_tokens,
444
+ history: this.vars.ask.history.slice(-10),
445
+ memory: agent.key,
446
+ askAgent: false,
447
+ });
448
+ }).then(chat => {
449
+ data.chat = chat.a.data;
450
+ this.state('parse', 'hymn:chat');
451
+ const msg = [
452
+ chat.a.data.parsed,
453
+ '::begin:buttons',
454
+ `button[🗣️ Speak]:${this.askChr}${agent.key} speak ${encodeURI(chat.a.text)}`,
455
+ `button[🎨 Art]:${this.askChr}${agent.key} art ${encodeURI(chat.a.text)}`,
456
+ '::end:buttons',
457
+ ].join('\n');
458
+ return this.question(`${this.askChr}feecting parse ${msg}`);
459
+ }).then(feecting => {
460
+ data.feecting = feecting.a.data;
461
+ this.state('resolve', 'hymn');
462
+ return resolve({
463
+ text: feecting.a.text,
464
+ html: feecting.a.html,
465
+ data,
466
+ });
467
+ }).catch(err => {
468
+ this.state('reject', 'hymn');
469
+ console.log('HYMN feature ERROR', err);
470
+ return this.error(err, packet, reject);
471
+ });
472
+ });
473
+ },
474
+
475
+
476
+ /**************
477
+ method: speak
478
+ params: packet
479
+ describe: have the agent say a message
480
+ ***************/
481
+ speak(packet) {
482
+ return new Promise((resolve, reject) => {
483
+ if (!packet.q.text) return resolve(this._messages.notext);
484
+ this.action('feature', 'speak');
485
+ const agent = this.agent();
486
+
487
+ this.state('get', 'speak:speech')
488
+ this.question(`${this.askChr}open speech:${agent.profile.voice} ${decodeURI(packet.q.text)}`).then(speech => {
489
+ this.state('resolve', 'speak');
490
+ return resolve({
491
+ text: speech.a.text,
492
+ html: speech.a.html,
493
+ data: speech.a.data,
494
+ })
495
+ }).catch(err => {
496
+ this.state('reject', 'speak');
497
+ return this.error(err, packet, reject);
498
+ });
499
+ // this.state('get', 'speech');
500
+ // return
501
+ // }).then(voice => {
502
+ // text.push(voice.a.text);
503
+ // data.voice = voice.a.data;
504
+
505
+ });
506
+ },
507
+
508
+ /**************
509
+ method: artist
510
+ params: packet
511
+ describe: this method provides a global artist method to all agents.
512
+ ***************/
513
+ art(packet) {
514
+ return new Promise((resolve, reject) => {
515
+ this.action('feature', 'services:art');
516
+
517
+ const text = [];
518
+ const data = {};
519
+ const agent = this.agent();
520
+ const client = this.client();
521
+ const size = packet.q.meta.params[1] || 'square';
522
+ if (!agent.profile.style) return resolve(this._messages.nostyle);
523
+ this.state('get', 'image');
524
+ const msg = [
525
+ `style: ${agent.profile.style}`,
526
+ `prompt: ${packet.q.text}`,
527
+ ].join('\n');
528
+ this.question(`${this.askChr}open image:${size} ${msg}`).then(painting => {
529
+ data.patining = painting.a.data.image;
530
+
531
+ this.state('set', 'history');
532
+ this.vars.art.history.push(painting.a.text);
533
+
534
+ return resolve({
535
+ text: painting.a.text,
536
+ html: painting.a.html,
537
+ data,
538
+ });
539
+ }).catch(err => {
540
+ console.log('ERROR', err);
541
+ return this.error(packet, err, reject);
542
+ });
543
+ });
544
+ },
545
+
546
+ /**************
547
+ method: reply
548
+ params: packet
549
+ describe: this method is a feature that allows each agent to reply to messages
550
+ with their specific features. if a header is supplied in the request then
551
+ it will be added to the data.
552
+ ***************/
553
+ reply(packet) {
554
+ return new Promise((resolve, reject) => {
555
+ if (!this.vars.reply) return resolve('NO REPLY');
556
+ this.context('reply')
557
+ const agent = this.agent();
558
+ const client = this.client();
559
+ const {admin} = this.services().global;
560
+
561
+ const {author} = packet.q.data;
562
+
563
+ const profile = [
564
+ `::begin:admin:${admin.id}`,
565
+ `id: ${admin.id}`,
566
+ `name: ${admin.name}`,
567
+ `roles: ${admin.roles}`,
568
+ `disclaimer: For Admin use only.`,
569
+ `::end:admin`,
570
+ `::begin:user:${client.id}`,
571
+ `id: ${client.id}`,
572
+ `name: ${client.profile.name}`,
573
+ `nickname: ${client.profile.nickname}`,
574
+ `describe: ${client.profile.describe}`,
575
+ `::end:user`
576
+ ];
577
+
578
+ profile.push(`::begin:assistant`);
579
+ for (let x in agent.profile) {
580
+ profile.push(`${x}: ${agent.profile[x]}`);
581
+ }
582
+ profile.push(`::end:assistant`);
583
+
584
+ this.question(`${this.askChr}docs view devas/${this.vars.reply.profile}:corpus`).then(doc => {
585
+ const data = {
586
+ model: agent.model || false,
587
+ header: packet.q.data.header || false,
588
+ profile: profile.join('\n'),
589
+ corpus: doc.a.text,
590
+ history: this.vars.reply.history.slice(-5),
591
+ };
592
+ const msg = [
593
+ packet.q.text,
594
+ `important: Respond in ${this.vars.reply.words} words or less.`,
595
+ ].join('\n');
596
+
597
+ return this.question(`${this.askChr}open relay ${msg}`, data);
598
+ }).then(chat => {
599
+ this.vars.reply.history.push({
600
+ role: chat.a.data.chat.role,
601
+ content: chat.a.data.chat.text,
602
+ });
603
+ return resolve({
604
+ text: chat.a.text,
605
+ html: chat.a.html,
606
+ data: chat.a.data,
607
+ });
608
+ }).catch(err => {
609
+ return this.error(packet, err, reject);
610
+ });
611
+ });
612
+ },
613
+ };
@@ -0,0 +1,25 @@
1
+ ::begin:center
2
+ image: /public/devas/::agent_key::/main.png
3
+ ::end:center
4
+
5
+ # ::agent_name::
6
+
7
+ ::profile::
8
+
9
+ ---
10
+
11
+ talk:#docs view devas/main:global
12
+
13
+ ---
14
+
15
+ talk:#docs view devas/main:security
16
+
17
+ ---
18
+
19
+ copyright: (c)2023 Quinn Michaels
20
+
21
+ ::begin:hidden
22
+ #color = ::agent_color::
23
+ #bgcolor = ::agent_bgcolor::
24
+ #bg = ::agent_background::
25
+ ::end:hidden
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ // Copyright (c)2023 Quinn Michaels
2
+ // Services Deva
3
+ // The Services Deva manages various @SERVICES requests in deva.world.
4
+ const Deva = require('@indra.ai/deva');
5
+ const package = require('./package.json');
6
+ const info = {
7
+ id: package.id,
8
+ name: package.name,
9
+ describe: package.description,
10
+ version: package.version,
11
+ dir: __dirname,
12
+ url: package.homepage,
13
+ git: package.repository.url,
14
+ bugs: package.bugs.url,
15
+ author: package.author,
16
+ license: package.license,
17
+ copyright: package.copyright,
18
+ };
19
+ const {agent,vars} = require('./data.json').DATA;
20
+ const SERVICES = new Deva({
21
+ info,
22
+ agent,
23
+ vars,
24
+ utils: {
25
+ translate(input) {return input.trim();},
26
+ parse(input) {return input.trim();},
27
+ proecess(input) {return input.trim();}
28
+ },
29
+ listeners: {},
30
+ modules: {},
31
+ func: {},
32
+ methods: {},
33
+ onError(err) {
34
+ console.log('ERR', err);
35
+ }
36
+ });
37
+ module.exports = SERVICES
package/index.test.js ADDED
@@ -0,0 +1,19 @@
1
+ // Copyright (c)2023 Quinn Michaels
2
+ // Services Deva test file
3
+
4
+ const {expect} = require('chai')
5
+ const ServicesDeva = require('./index.js');
6
+
7
+ describe(ServicesDeva.me.name, () => {
8
+ beforeEach(() => {
9
+ return ServicesDeva.init()
10
+ });
11
+ it('Check the DEVA Object', () => {
12
+ expect(ServicesDeva).to.be.an('object');
13
+ expect(ServicesDeva).to.have.property('agent');
14
+ expect(ServicesDeva).to.have.property('vars');
15
+ expect(ServicesDeva).to.have.property('listeners');
16
+ expect(ServicesDeva).to.have.property('methods');
17
+ expect(ServicesDeva).to.have.property('modules');
18
+ });
19
+ })
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "id": 4855882658530,
3
+ "name": "@indra.ai/deva.services",
4
+ "version": "0.0.2",
5
+ "author": "Quinn Michaels",
6
+ "license": "MIT",
7
+ "copyright": "2023",
8
+ "description": "The Services Deva handles @SERVICES in deva.world.",
9
+ "main": "index.js",
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/indraai/deva.services.git"
16
+ },
17
+ "keywords": [
18
+ "Services",
19
+ "Deva",
20
+ "Deva.world",
21
+ "Deva.cloud",
22
+ "Deva.space"
23
+ ],
24
+ "bugs": {
25
+ "url": "https://github.com/indraai/deva.services/issues"
26
+ },
27
+ "homepage": "https://deva.space/services",
28
+ "dependencies": {
29
+ "@indra.ai/deva": "^1.2.21"
30
+ }
31
+ }