netra-sdk 1.0.4 → 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 +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +65 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -110,7 +110,9 @@ declare enum Measure {
|
|
|
110
110
|
REQUEST_COUNT = "Request Count",
|
|
111
111
|
TOTAL_COST = "Total Cost",
|
|
112
112
|
VIOLATIONS = "Violations",
|
|
113
|
-
TOTAL_TOKENS = "Total Tokens"
|
|
113
|
+
TOTAL_TOKENS = "Total Tokens",
|
|
114
|
+
AUDIO_DURATION = "Audio Duration",
|
|
115
|
+
CHARACTER_COUNT = "Character Count"
|
|
114
116
|
}
|
|
115
117
|
declare enum Aggregation {
|
|
116
118
|
AVERAGE = "Average",
|
|
@@ -985,6 +987,32 @@ declare class SpanWrapper {
|
|
|
985
987
|
getCurrentSpan(): Span | undefined;
|
|
986
988
|
}
|
|
987
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Prompts API Models
|
|
992
|
+
*/
|
|
993
|
+
interface GetPromptParams {
|
|
994
|
+
name: string;
|
|
995
|
+
label?: string;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Prompt response is intentionally flexible because
|
|
999
|
+
* backend prompt structures may evolve (variables, templates, metadata etc.)
|
|
1000
|
+
*/
|
|
1001
|
+
type PromptResponse = Record<string, any>;
|
|
1002
|
+
|
|
1003
|
+
declare class Prompts {
|
|
1004
|
+
private config;
|
|
1005
|
+
private client;
|
|
1006
|
+
constructor(config: Config);
|
|
1007
|
+
/**
|
|
1008
|
+
* Fetch prompt version by name and label.
|
|
1009
|
+
*
|
|
1010
|
+
* @param params.name - Name of the prompt (required)
|
|
1011
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
1012
|
+
*/
|
|
1013
|
+
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
988
1016
|
/**
|
|
989
1017
|
* Decorators for easy instrumentation
|
|
990
1018
|
*/
|
|
@@ -1234,6 +1262,11 @@ declare class Netra {
|
|
|
1234
1262
|
*/
|
|
1235
1263
|
static dashboard: Dashboard;
|
|
1236
1264
|
static simulation: Simulation;
|
|
1265
|
+
/**
|
|
1266
|
+
* Prompts API client for prompt versioning
|
|
1267
|
+
* Available after calling Netra.init()
|
|
1268
|
+
*/
|
|
1269
|
+
static prompts: Prompts;
|
|
1237
1270
|
/**
|
|
1238
1271
|
* Get the current Netra configuration
|
|
1239
1272
|
*/
|
|
@@ -1341,4 +1374,4 @@ declare class Netra {
|
|
|
1341
1374
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1342
1375
|
}
|
|
1343
1376
|
|
|
1344
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraInstruments, type NumberResponse, Operator, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
|
1377
|
+
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraInstruments, type NumberResponse, Operator, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,9 @@ declare enum Measure {
|
|
|
110
110
|
REQUEST_COUNT = "Request Count",
|
|
111
111
|
TOTAL_COST = "Total Cost",
|
|
112
112
|
VIOLATIONS = "Violations",
|
|
113
|
-
TOTAL_TOKENS = "Total Tokens"
|
|
113
|
+
TOTAL_TOKENS = "Total Tokens",
|
|
114
|
+
AUDIO_DURATION = "Audio Duration",
|
|
115
|
+
CHARACTER_COUNT = "Character Count"
|
|
114
116
|
}
|
|
115
117
|
declare enum Aggregation {
|
|
116
118
|
AVERAGE = "Average",
|
|
@@ -985,6 +987,32 @@ declare class SpanWrapper {
|
|
|
985
987
|
getCurrentSpan(): Span | undefined;
|
|
986
988
|
}
|
|
987
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Prompts API Models
|
|
992
|
+
*/
|
|
993
|
+
interface GetPromptParams {
|
|
994
|
+
name: string;
|
|
995
|
+
label?: string;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Prompt response is intentionally flexible because
|
|
999
|
+
* backend prompt structures may evolve (variables, templates, metadata etc.)
|
|
1000
|
+
*/
|
|
1001
|
+
type PromptResponse = Record<string, any>;
|
|
1002
|
+
|
|
1003
|
+
declare class Prompts {
|
|
1004
|
+
private config;
|
|
1005
|
+
private client;
|
|
1006
|
+
constructor(config: Config);
|
|
1007
|
+
/**
|
|
1008
|
+
* Fetch prompt version by name and label.
|
|
1009
|
+
*
|
|
1010
|
+
* @param params.name - Name of the prompt (required)
|
|
1011
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
1012
|
+
*/
|
|
1013
|
+
getPrompt(params: GetPromptParams): Promise<PromptResponse | null>;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
988
1016
|
/**
|
|
989
1017
|
* Decorators for easy instrumentation
|
|
990
1018
|
*/
|
|
@@ -1234,6 +1262,11 @@ declare class Netra {
|
|
|
1234
1262
|
*/
|
|
1235
1263
|
static dashboard: Dashboard;
|
|
1236
1264
|
static simulation: Simulation;
|
|
1265
|
+
/**
|
|
1266
|
+
* Prompts API client for prompt versioning
|
|
1267
|
+
* Available after calling Netra.init()
|
|
1268
|
+
*/
|
|
1269
|
+
static prompts: Prompts;
|
|
1237
1270
|
/**
|
|
1238
1271
|
* Get the current Netra configuration
|
|
1239
1272
|
*/
|
|
@@ -1341,4 +1374,4 @@ declare class Netra {
|
|
|
1341
1374
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1342
1375
|
}
|
|
1343
1376
|
|
|
1344
|
-
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraInstruments, type NumberResponse, Operator, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
|
1377
|
+
export { type ActionModel, Aggregation, BaseTask, type CategoricalDataPoint, ChartType, Config, type ConversationResponse, type ConversationResult, ConversationType, type CreateDatasetParams, type CreateRunResult, Dashboard, type DashboardData, type Dataset, type DatasetEntry, type DatasetItem, type Dimension, DimensionField, type DimensionValue, EntryStatus, Evaluation, type EvaluationScore, type EvaluatorFunction, type Filter, type FilterConfig, FilterField, FilterType, FilteringSpanExporter, type GetPromptParams, GroupBy, InstrumentationSpanProcessor, type ListSpansParams, type ListTracesParams, Measure, type Metrics, Netra, NetraInstruments, type NumberResponse, Operator, type PromptResponse, Prompts, type QueryDataParams, type QueryResponse, type Run, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, type SessionUsageData, Simulation, type SimulationItem, type SimulationOptions, type SimulationResult, SpanType, type SpansPage, type TaskFunction, type TaskResult, type TenantUsageData, type TestSuiteResult, type TimeRange, type TimeSeriesDataPoint, type TimeSeriesResponse, type TimeSeriesWithDimension, type TraceSpan, type TraceSummary, type TracesPage, TrialAwareOTLPExporter, Usage, type UsageModel, agent, Netra as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
package/dist/index.js
CHANGED
|
@@ -350,6 +350,8 @@ var Measure = /* @__PURE__ */ ((Measure2) => {
|
|
|
350
350
|
Measure2["TOTAL_COST"] = "Total Cost";
|
|
351
351
|
Measure2["VIOLATIONS"] = "Violations";
|
|
352
352
|
Measure2["TOTAL_TOKENS"] = "Total Tokens";
|
|
353
|
+
Measure2["AUDIO_DURATION"] = "Audio Duration";
|
|
354
|
+
Measure2["CHARACTER_COUNT"] = "Character Count";
|
|
353
355
|
return Measure2;
|
|
354
356
|
})(Measure || {});
|
|
355
357
|
var Aggregation = /* @__PURE__ */ ((Aggregation2) => {
|
|
@@ -9262,6 +9264,67 @@ var Simulation = class {
|
|
|
9262
9264
|
}
|
|
9263
9265
|
}
|
|
9264
9266
|
};
|
|
9267
|
+
|
|
9268
|
+
// src/api/prompts/client.ts
|
|
9269
|
+
var PromptsHttpClient = class extends NetraHttpClient {
|
|
9270
|
+
constructor(config2) {
|
|
9271
|
+
super(config2, "NETRA_PROMPTS_TIMEOUT", 30);
|
|
9272
|
+
}
|
|
9273
|
+
/**
|
|
9274
|
+
* Fetch prompt version from backend
|
|
9275
|
+
*/
|
|
9276
|
+
async getPromptVersion(name, label) {
|
|
9277
|
+
if (!this.isInitialized()) {
|
|
9278
|
+
console.error(
|
|
9279
|
+
"netra.prompts: Prompts client is not initialized; cannot fetch prompt"
|
|
9280
|
+
);
|
|
9281
|
+
return null;
|
|
9282
|
+
}
|
|
9283
|
+
try {
|
|
9284
|
+
const payload = {
|
|
9285
|
+
promptName: name,
|
|
9286
|
+
label
|
|
9287
|
+
};
|
|
9288
|
+
const response = await this.post("/sdk/prompts/version", payload);
|
|
9289
|
+
if (!response.ok) {
|
|
9290
|
+
const errorMessage = response.data?.error?.message ?? "Unknown error";
|
|
9291
|
+
console.error(`netra.prompts: Failed to fetch prompt: ${errorMessage}`);
|
|
9292
|
+
return null;
|
|
9293
|
+
}
|
|
9294
|
+
return response.data;
|
|
9295
|
+
} catch (err) {
|
|
9296
|
+
const message = err?.response?.data?.error?.message ?? "";
|
|
9297
|
+
console.error("netra.prompts: Failed to fetch prompt:", message);
|
|
9298
|
+
return null;
|
|
9299
|
+
}
|
|
9300
|
+
}
|
|
9301
|
+
};
|
|
9302
|
+
|
|
9303
|
+
// src/api/prompts/api.ts
|
|
9304
|
+
var Prompts = class {
|
|
9305
|
+
constructor(config2) {
|
|
9306
|
+
this.config = config2;
|
|
9307
|
+
this.client = new PromptsHttpClient(config2);
|
|
9308
|
+
}
|
|
9309
|
+
/**
|
|
9310
|
+
* Fetch prompt version by name and label.
|
|
9311
|
+
*
|
|
9312
|
+
* @param params.name - Name of the prompt (required)
|
|
9313
|
+
* @param params.label - Label of the prompt version (default: "production")
|
|
9314
|
+
*/
|
|
9315
|
+
async getPrompt(params) {
|
|
9316
|
+
if (!params || typeof params.name !== "string" || !params.name) {
|
|
9317
|
+
console.error("netra.prompts: name is required to fetch a prompt");
|
|
9318
|
+
return null;
|
|
9319
|
+
}
|
|
9320
|
+
const label = params.label ?? "production";
|
|
9321
|
+
const result = await this.client.getPromptVersion(params.name, label);
|
|
9322
|
+
if (!result) {
|
|
9323
|
+
return null;
|
|
9324
|
+
}
|
|
9325
|
+
return result.data ?? null;
|
|
9326
|
+
}
|
|
9327
|
+
};
|
|
9265
9328
|
function serializeValue(value) {
|
|
9266
9329
|
try {
|
|
9267
9330
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
|
|
@@ -9512,6 +9575,7 @@ var Netra = class {
|
|
|
9512
9575
|
this.evaluation = new Evaluation(cfg);
|
|
9513
9576
|
this.dashboard = new Dashboard(cfg);
|
|
9514
9577
|
this.simulation = new Simulation(cfg);
|
|
9578
|
+
this.prompts = new Prompts(cfg);
|
|
9515
9579
|
this._initialized = true;
|
|
9516
9580
|
console.info("Netra successfully initialized.");
|
|
9517
9581
|
if (cfg.debugMode) {
|
|
@@ -9800,6 +9864,6 @@ Netra._initialized = false;
|
|
|
9800
9864
|
Netra.withBlockedSpansLocal = withBlockedSpansLocal;
|
|
9801
9865
|
var index_default = Netra;
|
|
9802
9866
|
|
|
9803
|
-
export { Aggregation, BaseTask, ChartType, Config, ConversationType, Dashboard, DimensionField, EntryStatus, Evaluation, FilterField, FilterType, FilteringSpanExporter, GroupBy, InstrumentationSpanProcessor, Measure, Netra, NetraInstruments, Operator, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, Simulation, SpanType, TrialAwareOTLPExporter, Usage, agent, index_default as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
|
9867
|
+
export { Aggregation, BaseTask, ChartType, Config, ConversationType, Dashboard, DimensionField, EntryStatus, Evaluation, FilterField, FilterType, FilteringSpanExporter, GroupBy, InstrumentationSpanProcessor, Measure, Netra, NetraInstruments, Operator, Prompts, RunEntryContext, RunStatus, Scope, ScrubbingSpanProcessor, SessionSpanProcessor, Simulation, SpanType, TrialAwareOTLPExporter, Usage, agent, index_default as default, metadataField, mistralAIInstrumentor, span, task, workflow };
|
|
9804
9868
|
//# sourceMappingURL=index.js.map
|
|
9805
9869
|
//# sourceMappingURL=index.js.map
|