@promptmetrics/sdk 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.1] - 2025-12-30
9
+
10
+ ### Fixed
11
+
12
+ - **Hardcoded baseURL**: API base URL is now hardcoded to `https://api.promptmetrics.dev` - users no longer need to set `BASE_URL` environment variable
13
+ - Simplified configuration - only `PROMPTMETRICS_API_KEY` is required
14
+
15
+ ### Changed
16
+
17
+ - Removed `BASE_URL` requirement from `.env.example`
18
+ - Updated README to remove baseURL configuration instructions
19
+ - Streamlined Quick Start example
20
+
21
+ ---
22
+
8
23
  ## [1.0.0] - 2025-12-30
9
24
 
10
25
  ### 🎉 First Stable Release
package/README.md CHANGED
@@ -1,8 +1,19 @@
1
1
  <div align="center">
2
2
 
3
- # 📊 PromptMetrics SDK
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4
+ <path d="M12 18V5"></path>
5
+ <path d="M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"></path>
6
+ <path d="M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5"></path>
7
+ <path d="M17.997 5.125a4 4 0 0 1 2.526 5.77"></path>
8
+ <path d="M18 18a4 4 0 0 0 2-7.464"></path>
9
+ <path d="M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517"></path>
10
+ <path d="M6 18a4 4 0 0 1-2-7.464"></path>
11
+ <path d="M6.003 5.125a4 4 0 0 0-2.526 5.77"></path>
12
+ </svg>
4
13
 
5
- **The platform built for <span style="background-color: rgb(219, 234, 254);">prompt engineers</span>**
14
+ # PromptMetrics SDK
15
+
16
+ **The platform built for prompt engineers**
6
17
 
7
18
  <a href="https://nodejs.org"><img alt="Node" src="https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white"></a>
8
19
  <a href="https://www.typescriptlang.org/"><img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white"></a>
@@ -64,11 +75,8 @@ const pm = new PromptMetrics({
64
75
  apiKey: process.env.PROMPTMETRICS_API_KEY, // pm_xxxxx
65
76
  });
66
77
 
67
- // Get a template and run it
68
- const template = await pm.templates.get("customer-support");
69
- const version = template.versions[0];
70
-
71
- const result = await pm.versions.run(version._id, {
78
+ // Run a template directly
79
+ const result = await pm.templates.run("customer-support", {
72
80
  variables: {
73
81
  customer_name: "John Doe",
74
82
  issue: "billing problem",
@@ -104,9 +112,6 @@ const pm = new PromptMetrics({
104
112
  ### Environment Variables
105
113
 
106
114
  ```bash
107
- # Required
108
- BASE_URL=https://api.promptmetrics.com
109
-
110
115
  # Optional (can also be passed in config)
111
116
  PROMPTMETRICS_API_KEY=pm_xxxxx
112
117
  ```
@@ -146,6 +151,31 @@ const template = await pm.templates.get("customer-support", {
146
151
  });
147
152
  ```
148
153
 
154
+ #### Run a Template
155
+
156
+ ```typescript
157
+ // Run template directly (uses production version with canary support)
158
+ const result = await pm.templates.run("customer-support", {
159
+ variables: {
160
+ customer_name: "John Doe",
161
+ issue: "billing problem",
162
+ },
163
+ });
164
+
165
+ // Run with environment label
166
+ const result = await pm.templates.run("customer-support", {
167
+ env_label: "staging",
168
+ variables: { customer_name: "John" },
169
+ });
170
+
171
+ // Run with model override
172
+ const result = await pm.templates.run("customer-support", {
173
+ variables: { customer_name: "John" },
174
+ model: "gpt-4",
175
+ pm_tags: ["production", "customer-support"],
176
+ });
177
+ ```
178
+
149
179
  #### List Templates
150
180
 
151
181
  ```typescript
@@ -240,54 +270,6 @@ console.log(result.logs);
240
270
  console.log(result.pagination);
241
271
  ```
242
272
 
243
- #### Log Structure
244
-
245
- ```typescript
246
- interface PromptLog {
247
- _id: string;
248
- template_version_id: string;
249
- template_id: string;
250
- workspace_id: string;
251
-
252
- // Request/Response
253
- request_object: {
254
- model: string;
255
- messages: Message[];
256
- temperature?: number;
257
- // ... other parameters
258
- };
259
- response_object: {
260
- id: string;
261
- choices: Array<{
262
- message: Message;
263
- finish_reason: string;
264
- }>;
265
- usage: {
266
- prompt_tokens: number;
267
- completion_tokens: number;
268
- total_tokens: number;
269
- };
270
- };
271
-
272
- // Performance
273
- latency: number; // seconds
274
- status: "SUCCESS" | "ERROR";
275
-
276
- // Costs
277
- prompt_cost: number;
278
- completion_cost: number;
279
- total_cost: number;
280
-
281
- // Trace correlation (if called from @traceable)
282
- trace_id?: string;
283
- span_id?: string;
284
- group_id?: string;
285
-
286
- created_at: string;
287
- updated_at: string;
288
- }
289
- ```
290
-
291
273
  ---
292
274
 
293
275
  ### LLM Providers
@@ -570,7 +552,7 @@ class TraceBuffer {
570
552
 
571
553
  ### LLM Request Correlation
572
554
 
573
- When you call `pm.versions.run()` inside a `@traceable` function, the LLM request is automatically linked to your trace.
555
+ When you call `pm.templates.run()` or `pm.versions.run()` inside a `@traceable` function, the LLM request is automatically linked to your trace.
574
556
 
575
557
  #### Automatic Correlation
576
558
 
@@ -578,14 +560,19 @@ When you call `pm.versions.run()` inside a `@traceable` function, the LLM reques
578
560
  class AIService {
579
561
  @pm.traceable({ name: "generate_support_response" })
580
562
  async generateResponse(customerMessage: string) {
581
- // This LLM call is automatically linked to the trace!
582
- const result = await pm.versions.run("version_123", {
563
+ // Option 1: Run template directly (auto-linked to trace!)
564
+ const result = await pm.templates.run("support-template", {
583
565
  variables: {
584
566
  customer_message: customerMessage,
585
567
  context: "support",
586
568
  },
587
569
  });
588
570
 
571
+ // Option 2: Run specific version (also auto-linked!)
572
+ const result2 = await pm.versions.run("version_123", {
573
+ variables: { customer_message: customerMessage },
574
+ });
575
+
589
576
  // The prompt_log will have:
590
577
  // - trace_id: current trace ID
591
578
  // - span_id: current span ID
@@ -613,8 +600,8 @@ class CustomerSupportWorkflow {
613
600
  // Step 1: Custom function (traced)
614
601
  const enriched = await this.enrichCustomerData(message);
615
602
 
616
- // Step 2: LLM call (auto-linked!)
617
- const response = await pm.versions.run("support-template", {
603
+ // Step 2: LLM call using template.run() (auto-linked!)
604
+ const response = await pm.templates.run("support-template", {
618
605
  variables: { message: enriched.text },
619
606
  });
620
607
 
@@ -836,7 +823,7 @@ await bot.handleMessage("How are you?", "conv_123");
836
823
  ## Support
837
824
 
838
825
  - **Documentation**: [docs.promptmetrics.com](https://docs.promptmetrics.com)
839
- - **GitHub Issues**: [github.com/Xomatic/promptmetrics-sdk/issues](https://github.com/Xomatic/promptmetrics-sdk/issues)
826
+ <!-- - **GitHub Issues**: [github.com/Xomatic/promptmetrics-sdk/issues](https://github.com/Xomatic/promptmetrics-sdk/issues) -->
840
827
  - **Email**: support@promptmetrics.com
841
828
 
842
829
  ---
@@ -847,8 +834,8 @@ MIT
847
834
 
848
835
  ---
849
836
 
850
- ## Additional Resources
837
+ <!-- ## Additional Resources
851
838
 
852
839
  - **[TRACING.md](./TRACING.md)** - Comprehensive tracing guide with advanced examples
853
840
  - **[Examples](./examples/)** - Code examples for common use cases
854
- - **[Changelog](./CHANGELOG.md)** - Version history and updates
841
+ - **[Changelog](./CHANGELOG.md)** - Version history and updates -->
package/dist/index.d.mts CHANGED
@@ -1315,6 +1315,6 @@ declare class TimeoutError extends PromptMetricsError {
1315
1315
  * ```
1316
1316
  */
1317
1317
 
1318
- declare const VERSION = "1.0.0";
1318
+ declare const VERSION = "1.0.1";
1319
1319
 
1320
1320
  export { type AddTraceScoreOptions, AuthenticationError, AuthorizationError, type CreateTraceOptions, type GetTemplateOptions, type LLMModel, type LLMProvider, type ListLogsOptions, type ListPromptsOptions, type ListPromptsResponse, type ListTracesOptions, type Message, NetworkError, NotFoundError, type PromptLog, PromptMetrics, type PromptMetricsConfig, PromptMetricsError, type PromptMetricsErrorResponse, type ProviderWithModels, RateLimitError, type RunTemplateOptions, type RunVersionOptions, ServerError, type Template, type TemplateMetadata, type TemplateOptions, type TemplateVersion, TimeoutError, type Trace, type TraceAnalytics, type TraceError, type TraceListResponse, type TraceScore, type TraceStatus, type TraceTreeNode, type TraceableOptions, type UpdateTraceMetadataOptions, type UpdateVersionOptions, VERSION, ValidationError };
package/dist/index.d.ts CHANGED
@@ -1315,6 +1315,6 @@ declare class TimeoutError extends PromptMetricsError {
1315
1315
  * ```
1316
1316
  */
1317
1317
 
1318
- declare const VERSION = "1.0.0";
1318
+ declare const VERSION = "1.0.1";
1319
1319
 
1320
1320
  export { type AddTraceScoreOptions, AuthenticationError, AuthorizationError, type CreateTraceOptions, type GetTemplateOptions, type LLMModel, type LLMProvider, type ListLogsOptions, type ListPromptsOptions, type ListPromptsResponse, type ListTracesOptions, type Message, NetworkError, NotFoundError, type PromptLog, PromptMetrics, type PromptMetricsConfig, PromptMetricsError, type PromptMetricsErrorResponse, type ProviderWithModels, RateLimitError, type RunTemplateOptions, type RunVersionOptions, ServerError, type Template, type TemplateMetadata, type TemplateOptions, type TemplateVersion, TimeoutError, type Trace, type TraceAnalytics, type TraceError, type TraceListResponse, type TraceScore, type TraceStatus, type TraceTreeNode, type TraceableOptions, type UpdateTraceMetadataOptions, type UpdateVersionOptions, VERSION, ValidationError };
package/dist/index.js CHANGED
@@ -1278,14 +1278,8 @@ var PromptMetrics = class {
1278
1278
  */
1279
1279
  constructor(config) {
1280
1280
  this.validateConfig(config);
1281
- const baseURL = process.env.BASE_URL;
1282
- if (!baseURL) {
1283
- throw new ValidationError(
1284
- "BASE_URL environment variable is required. Please set it in your .env file."
1285
- );
1286
- }
1287
1281
  this.httpClient = new HttpClient({
1288
- baseURL,
1282
+ baseURL: "https://api.promptmetrics.dev",
1289
1283
  apiKey: config.apiKey,
1290
1284
  timeout: config.timeout,
1291
1285
  maxRetries: config.maxRetries,
@@ -1356,7 +1350,7 @@ var PromptMetrics = class {
1356
1350
  };
1357
1351
 
1358
1352
  // src/index.ts
1359
- var VERSION = "1.0.0";
1353
+ var VERSION = "1.0.1";
1360
1354
  // Annotate the CommonJS export names for ESM import in node:
1361
1355
  0 && (module.exports = {
1362
1356
  AuthenticationError,
package/dist/index.mjs CHANGED
@@ -1232,14 +1232,8 @@ var PromptMetrics = class {
1232
1232
  */
1233
1233
  constructor(config) {
1234
1234
  this.validateConfig(config);
1235
- const baseURL = process.env.BASE_URL;
1236
- if (!baseURL) {
1237
- throw new ValidationError(
1238
- "BASE_URL environment variable is required. Please set it in your .env file."
1239
- );
1240
- }
1241
1235
  this.httpClient = new HttpClient({
1242
- baseURL,
1236
+ baseURL: "https://api.promptmetrics.dev",
1243
1237
  apiKey: config.apiKey,
1244
1238
  timeout: config.timeout,
1245
1239
  maxRetries: config.maxRetries,
@@ -1310,7 +1304,7 @@ var PromptMetrics = class {
1310
1304
  };
1311
1305
 
1312
1306
  // src/index.ts
1313
- var VERSION = "1.0.0";
1307
+ var VERSION = "1.0.1";
1314
1308
  export {
1315
1309
  AuthenticationError,
1316
1310
  AuthorizationError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptmetrics/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Official TypeScript/JavaScript SDK for PromptMetrics API - Manage and execute LLM prompts with version control, monitoring, and analytics",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",