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.d.cts
CHANGED
|
@@ -987,6 +987,32 @@ declare class SpanWrapper {
|
|
|
987
987
|
getCurrentSpan(): Span | undefined;
|
|
988
988
|
}
|
|
989
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
|
+
|
|
990
1016
|
/**
|
|
991
1017
|
* Decorators for easy instrumentation
|
|
992
1018
|
*/
|
|
@@ -1236,6 +1262,11 @@ declare class Netra {
|
|
|
1236
1262
|
*/
|
|
1237
1263
|
static dashboard: Dashboard;
|
|
1238
1264
|
static simulation: Simulation;
|
|
1265
|
+
/**
|
|
1266
|
+
* Prompts API client for prompt versioning
|
|
1267
|
+
* Available after calling Netra.init()
|
|
1268
|
+
*/
|
|
1269
|
+
static prompts: Prompts;
|
|
1239
1270
|
/**
|
|
1240
1271
|
* Get the current Netra configuration
|
|
1241
1272
|
*/
|
|
@@ -1343,4 +1374,4 @@ declare class Netra {
|
|
|
1343
1374
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1344
1375
|
}
|
|
1345
1376
|
|
|
1346
|
-
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
|
@@ -987,6 +987,32 @@ declare class SpanWrapper {
|
|
|
987
987
|
getCurrentSpan(): Span | undefined;
|
|
988
988
|
}
|
|
989
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
|
+
|
|
990
1016
|
/**
|
|
991
1017
|
* Decorators for easy instrumentation
|
|
992
1018
|
*/
|
|
@@ -1236,6 +1262,11 @@ declare class Netra {
|
|
|
1236
1262
|
*/
|
|
1237
1263
|
static dashboard: Dashboard;
|
|
1238
1264
|
static simulation: Simulation;
|
|
1265
|
+
/**
|
|
1266
|
+
* Prompts API client for prompt versioning
|
|
1267
|
+
* Available after calling Netra.init()
|
|
1268
|
+
*/
|
|
1269
|
+
static prompts: Prompts;
|
|
1239
1270
|
/**
|
|
1240
1271
|
* Get the current Netra configuration
|
|
1241
1272
|
*/
|
|
@@ -1343,4 +1374,4 @@ declare class Netra {
|
|
|
1343
1374
|
static withBlockedSpansLocal: typeof withBlockedSpansLocal;
|
|
1344
1375
|
}
|
|
1345
1376
|
|
|
1346
|
-
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
|
@@ -9264,6 +9264,67 @@ var Simulation = class {
|
|
|
9264
9264
|
}
|
|
9265
9265
|
}
|
|
9266
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
|
+
};
|
|
9267
9328
|
function serializeValue(value) {
|
|
9268
9329
|
try {
|
|
9269
9330
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
|
|
@@ -9514,6 +9575,7 @@ var Netra = class {
|
|
|
9514
9575
|
this.evaluation = new Evaluation(cfg);
|
|
9515
9576
|
this.dashboard = new Dashboard(cfg);
|
|
9516
9577
|
this.simulation = new Simulation(cfg);
|
|
9578
|
+
this.prompts = new Prompts(cfg);
|
|
9517
9579
|
this._initialized = true;
|
|
9518
9580
|
console.info("Netra successfully initialized.");
|
|
9519
9581
|
if (cfg.debugMode) {
|
|
@@ -9802,6 +9864,6 @@ Netra._initialized = false;
|
|
|
9802
9864
|
Netra.withBlockedSpansLocal = withBlockedSpansLocal;
|
|
9803
9865
|
var index_default = Netra;
|
|
9804
9866
|
|
|
9805
|
-
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 };
|
|
9806
9868
|
//# sourceMappingURL=index.js.map
|
|
9807
9869
|
//# sourceMappingURL=index.js.map
|