symposium 0.10.7 → 0.10.9
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/Agent.js +11 -16
- package/Thread.js +4 -2
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -57,10 +57,13 @@ export default class Agent {
|
|
|
57
57
|
async doInitThread(thread) {
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async getThread(id) {
|
|
60
|
+
async getThread(id, i) {
|
|
61
61
|
let thread = this.threads.get(id);
|
|
62
|
-
if (
|
|
63
|
-
thread
|
|
62
|
+
if (thread) {
|
|
63
|
+
if (thread.interface !== i)
|
|
64
|
+
throw new Error('Required thread is not from the same interface');
|
|
65
|
+
} else {
|
|
66
|
+
thread = new Thread(id, i, this);
|
|
64
67
|
|
|
65
68
|
if (!(await thread.loadState())) {
|
|
66
69
|
await this.resetState(thread);
|
|
@@ -73,24 +76,16 @@ export default class Agent {
|
|
|
73
76
|
return thread;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
async
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const thread = new Thread(id, this);
|
|
79
|
+
async message(thread, content) {
|
|
80
|
+
if (typeof thread !== 'object')
|
|
81
|
+
thread = await this.getThread(thread);
|
|
81
82
|
|
|
82
|
-
if (await thread.loadState())
|
|
83
|
-
return thread;
|
|
84
|
-
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async message(thread_id, content) {
|
|
89
|
-
const thread = await this.getThread(thread_id);
|
|
90
83
|
await this.log('user_message', content);
|
|
91
84
|
thread.addMessage('user', content);
|
|
92
85
|
|
|
93
86
|
await this.execute(thread);
|
|
87
|
+
|
|
88
|
+
return thread;
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
async beforeExecute(thread) {
|
package/Thread.js
CHANGED
|
@@ -8,15 +8,17 @@ export default class Thread {
|
|
|
8
8
|
reply;
|
|
9
9
|
messages = [];
|
|
10
10
|
state = {};
|
|
11
|
+
interface = null;
|
|
11
12
|
|
|
12
|
-
constructor(id, agent) {
|
|
13
|
+
constructor(id, i, agent) {
|
|
13
14
|
this.id = id;
|
|
14
15
|
this.unique = agent.name + '-' + id;
|
|
15
16
|
this.agent = agent;
|
|
17
|
+
this.interface = i;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
clone(keepMessages = true) {
|
|
19
|
-
let newThread = new Thread(this.id, this.agent);
|
|
21
|
+
let newThread = new Thread(this.id, this.interface, this.agent);
|
|
20
22
|
newThread.reply = this.reply;
|
|
21
23
|
newThread.state = this.state;
|
|
22
24
|
if (keepMessages)
|