agentnet 0.1.4 → 0.1.6
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 +1 -1
- package/package.json +1 -1
- package/src/store/store.js +1 -1
- package/src/utils/conversation.js +13 -7
package/README.md
CHANGED
|
@@ -413,7 +413,7 @@ const compiledTravelAgent = await travelAgent.compile();
|
|
|
413
413
|
|
|
414
414
|
## Examples
|
|
415
415
|
|
|
416
|
-
* **Simple Agent Example**: For beginners, the [`examples/simple/
|
|
416
|
+
* **Simple Agent Example**: For beginners, the [`examples/simple/simple.js`](https://github.com/smartpricing/agentnet/blob/master/examples/simple/simple.js) provides a minimal implementation of an accommodation agent, perfect for understanding the basic concepts of agent definition and tool binding.
|
|
417
417
|
|
|
418
418
|
* **Booking Example**: See a multi-agent system in action for a smart booking scenario in [`examples/smartness/index.js`](https://github.com/smartpricing/agentnet/blob/master/examples/smartness/index.js). This demonstrates concepts like agent discovery, handoffs, and tool usage in a practical setup.
|
|
419
419
|
|
package/package.json
CHANGED
package/src/store/store.js
CHANGED
|
@@ -122,7 +122,7 @@ export function postgresStore(config = null) {
|
|
|
122
122
|
|
|
123
123
|
return {
|
|
124
124
|
connect: async function() {
|
|
125
|
-
if (
|
|
125
|
+
if (db === null) {
|
|
126
126
|
// For URL-style connection string
|
|
127
127
|
if (typeof connectionConfig === 'string') {
|
|
128
128
|
db = pgPromise(connectionConfig);
|
|
@@ -132,8 +132,17 @@ export class Conversation {
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// Check if there's at least one user message in the last maxElements
|
|
136
|
+
const lastMessages = this.messages.slice(-maxElements);
|
|
137
|
+
const hasUserMessage = lastMessages.some(msg => msg.metadata.type === 'user_input');
|
|
138
|
+
|
|
139
|
+
// Only trim if there's at least one user message in the resulting array
|
|
140
|
+
if (!hasUserMessage) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
135
144
|
// First, keep only the latest maxElements
|
|
136
|
-
this.messages =
|
|
145
|
+
this.messages = lastMessages;
|
|
137
146
|
|
|
138
147
|
// Then, ensure we have a user message at the start
|
|
139
148
|
// Find the first user message
|
|
@@ -145,13 +154,10 @@ export class Conversation {
|
|
|
145
154
|
}
|
|
146
155
|
}
|
|
147
156
|
|
|
148
|
-
// If
|
|
149
|
-
if (firstUserMessageIndex
|
|
150
|
-
|
|
157
|
+
// If the first user message is not at the start, trim all messages before it
|
|
158
|
+
if (firstUserMessageIndex > 0) {
|
|
159
|
+
this.messages = this.messages.slice(firstUserMessageIndex);
|
|
151
160
|
}
|
|
152
|
-
|
|
153
|
-
// Otherwise, trim all messages before the first user message
|
|
154
|
-
this.messages = this.messages.slice(firstUserMessageIndex);
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
/**
|