netra-sdk 1.0.5 → 1.0.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/dist/index.cjs +63 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +63 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27429,6 +27429,67 @@ var Simulation = class {
|
|
|
27429
27429
|
}
|
|
27430
27430
|
}
|
|
27431
27431
|
};
|
|
27432
|
+
|
|
27433
|
+
// src/api/prompts/client.ts
|
|
27434
|
+
var PromptsHttpClient = class extends NetraHttpClient {
|
|
27435
|
+
constructor(config2) {
|
|
27436
|
+
super(config2, "NETRA_PROMPTS_TIMEOUT", 30);
|
|
27437
|
+
}
|
|
27438
|
+
/**
|
|
27439
|
+
* Fetch prompt version from backend
|
|
27440
|
+
*/
|
|
27441
|
+
async getPromptVersion(name, label) {
|
|
27442
|
+
if (!this.isInitialized()) {
|
|
27443
|
+
console.error(
|
|
27444
|
+
"netra.prompts: Prompts client is not initialized; cannot fetch prompt"
|
|
27445
|
+
);
|
|
27446
|
+
return null;
|
|
27447
|
+
}
|
|
27448
|
+
try {
|
|
27449
|
+
const payload = {
|
|
27450
|
+
promptName: name,
|
|
27451
|
+
label
|
|
27452
|
+
};
|
|
27453
|
+
const response = await this.post("/sdk/prompts/version", payload);
|
|
27454
|
+
if (!response.ok) {
|
|
27455
|
+
const errorMessage = response.data?.error?.message ?? "Unknown error";
|
|
27456
|
+
console.error(`netra.prompts: Failed to fetch prompt: ${errorMessage}`);
|
|
27457
|
+
return null;
|
|
27458
|
+
}
|
|
27459
|
+
return response.data;
|
|
27460
|
+
} catch (err) {
|
|
27461
|
+
const message = err?.response?.data?.error?.message ?? "";
|
|
27462
|
+
console.error("netra.prompts: Failed to fetch prompt:", message);
|
|
27463
|
+
return null;
|
|
27464
|
+
}
|
|
27465
|
+
}
|
|
27466
|
+
};
|
|
27467
|
+
|
|
27468
|
+
// src/api/prompts/api.ts
|
|
27469
|
+
var Prompts = class {
|
|
27470
|
+
constructor(config2) {
|
|
27471
|
+
this.config = config2;
|
|
27472
|
+
this.client = new PromptsHttpClient(config2);
|
|
27473
|
+
}
|
|
27474
|
+
/**
|
|
27475
|
+
* Fetch prompt version by name and label.
|
|
27476
|
+
*
|
|
27477
|
+
* @param params.name - Name of the prompt (required)
|
|
27478
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
27479
|
+
*/
|
|
27480
|
+
async getPrompt(params) {
|
|
27481
|
+
if (!params || typeof params.name !== "string" || !params.name) {
|
|
27482
|
+
console.error("netra.prompts: name is required to fetch a prompt");
|
|
27483
|
+
return null;
|
|
27484
|
+
}
|
|
27485
|
+
const label = params.label ?? "production";
|
|
27486
|
+
const result = await this.client.getPromptVersion(params.name, label);
|
|
27487
|
+
if (!result) {
|
|
27488
|
+
return null;
|
|
27489
|
+
}
|
|
27490
|
+
return result.data ?? null;
|
|
27491
|
+
}
|
|
27492
|
+
};
|
|
27432
27493
|
function serializeValue(value) {
|
|
27433
27494
|
try {
|
|
27434
27495
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
|
|
@@ -27679,6 +27740,7 @@ var Netra = class {
|
|
|
27679
27740
|
this.evaluation = new Evaluation(cfg);
|
|
27680
27741
|
this.dashboard = new Dashboard(cfg);
|
|
27681
27742
|
this.simulation = new Simulation(cfg);
|
|
27743
|
+
this.prompts = new Prompts(cfg);
|
|
27682
27744
|
this._initialized = true;
|
|
27683
27745
|
console.info("Netra successfully initialized.");
|
|
27684
27746
|
if (cfg.debugMode) {
|
|
@@ -27985,6 +28047,7 @@ exports.Measure = Measure;
|
|
|
27985
28047
|
exports.Netra = Netra;
|
|
27986
28048
|
exports.NetraInstruments = NetraInstruments;
|
|
27987
28049
|
exports.Operator = Operator;
|
|
28050
|
+
exports.Prompts = Prompts;
|
|
27988
28051
|
exports.RunEntryContext = RunEntryContext;
|
|
27989
28052
|
exports.RunStatus = RunStatus;
|
|
27990
28053
|
exports.Scope = Scope;
|