@peopl-health/nexus 3.7.1 → 3.7.3

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.
@@ -121,7 +121,7 @@ class EvalProvider {
121
121
  try {
122
122
  assistant = getAssistantById(assistantId, thread);
123
123
  toolSchemas = assistant.getToolSchemas?.() || [];
124
- if (assistant.tools?.size) {
124
+ if (assistant.tools?.size && !Object.keys(this.promptVersions).length) {
125
125
  const toolNames = Array.from(assistant.tools.keys()).join(', ');
126
126
  devContent += `\n\nYou only have access to these tools: ${toolNames}. Do not call or reference any tools not listed here.`;
127
127
  }
@@ -152,7 +152,9 @@ class EvalProvider {
152
152
  apiConfig.tool_choice = this.toolChoice;
153
153
  }
154
154
 
155
- if (toolSchemas.length > 0) {
155
+ // Only send local tool schemas if NOT using a stored prompt with version
156
+ // (stored prompts have their own tool definitions on the platform)
157
+ if (toolSchemas.length > 0 && !apiConfig.prompt?.version) {
156
158
  apiConfig.tools = toolSchemas.map(schema => {
157
159
  if (schema.type === 'function' && schema.function) {
158
160
  const { name, description, parameters, strict } = schema.function;
@@ -8,7 +8,6 @@ const predictionMetricsSchema = new mongoose.Schema({
8
8
  message_id: { type: String, required: true, index: true },
9
9
  numero: { type: String, required: true, index: true },
10
10
  assistant_id: { type: String, required: true, index: true },
11
- thread_id: { type: String },
12
11
  prediction_time_ms: { type: Number },
13
12
  retry_count: { type: Number, default: 1 },
14
13
  completed: { type: Boolean, default: true },
@@ -20,6 +19,12 @@ const predictionMetricsSchema = new mongoose.Schema({
20
19
  total_tokens: { type: Number, default: 0 },
21
20
  model: { type: String },
22
21
  },
22
+ prompt_config: { type: Object, default: null },
23
+ response_id: { type: String, default: null, index: true },
24
+ context_message_count: { type: Number, default: null },
25
+ resolved_prompt: { type: String, default: null },
26
+ snippet_ids: { type: [String], default: [] },
27
+ tool_ids: { type: [String], default: [] },
23
28
  source: { type: String, default: () => process.env.USER_DB_MONGO }
24
29
  }, { timestamps: true });
25
30
 
@@ -291,6 +291,9 @@ const replyAssistantCore = async (code, message_ = null, thread_ = null, runOpti
291
291
  completed: completed,
292
292
  timing_breakdown: timings,
293
293
  token_usage: tokenUsage,
294
+ prompt_config: prompt || null,
295
+ response_id: response_id || null,
296
+ context_message_count: lastMessage?.length || null,
294
297
  }).catch(err => logger.error('[replyAssistant] Failed to store metrics', { error: err.message }));
295
298
 
296
299
  const alertThreshold = parseInt(process.env.TOKEN_ALERT_THRESHOLD, 10);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "3.7.1",
3
+ "version": "3.7.3",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",