@fallom/trace 0.2.10 → 0.2.13
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/chunk-2NGJF2JZ.mjs +661 -0
- package/dist/chunk-7P6ASYW6.mjs +9 -0
- package/dist/chunk-CCZLSKZ7.mjs +305 -0
- package/dist/core-46Z4Q54J.mjs +21 -0
- package/dist/index.d.mts +103 -33
- package/dist/index.d.ts +103 -33
- package/dist/index.js +1815 -1385
- package/dist/index.mjs +387 -610
- package/dist/models-NKYYGMSR.mjs +9 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -394,22 +394,35 @@ declare namespace prompts {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
/**
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
* Evaluate production outputs or compare different models on your dataset.
|
|
400
|
-
* Results are uploaded to Fallom dashboard for visualization.
|
|
401
|
-
*
|
|
397
|
+
* Type definitions for Fallom Evals.
|
|
402
398
|
*/
|
|
399
|
+
/** Built-in metric names */
|
|
403
400
|
type MetricName = "answer_relevancy" | "hallucination" | "toxicity" | "faithfulness" | "completeness";
|
|
401
|
+
/** List of all available built-in metrics */
|
|
404
402
|
declare const AVAILABLE_METRICS: MetricName[];
|
|
403
|
+
/**
|
|
404
|
+
* Define a custom evaluation metric using G-Eval.
|
|
405
|
+
*/
|
|
406
|
+
interface CustomMetric {
|
|
407
|
+
/** Unique identifier for the metric (e.g., "brand_alignment") */
|
|
408
|
+
name: string;
|
|
409
|
+
/** Description of what the metric evaluates */
|
|
410
|
+
criteria: string;
|
|
411
|
+
/** List of evaluation steps for the LLM judge to follow */
|
|
412
|
+
steps: string[];
|
|
413
|
+
}
|
|
414
|
+
/** Metric can be a built-in name or a custom metric */
|
|
415
|
+
type MetricInput = MetricName | CustomMetric;
|
|
405
416
|
/** Dataset can be a list of items OR a string (dataset key to fetch from Fallom) */
|
|
406
417
|
type DatasetInput = DatasetItem[] | string;
|
|
418
|
+
/** A single item in an evaluation dataset */
|
|
407
419
|
interface DatasetItem {
|
|
408
420
|
input: string;
|
|
409
421
|
output: string;
|
|
410
422
|
systemMessage?: string;
|
|
411
423
|
metadata?: Record<string, unknown>;
|
|
412
424
|
}
|
|
425
|
+
/** Evaluation result for a single item */
|
|
413
426
|
interface EvalResult {
|
|
414
427
|
input: string;
|
|
415
428
|
output: string;
|
|
@@ -449,19 +462,23 @@ interface Model {
|
|
|
449
462
|
name: string;
|
|
450
463
|
callFn?: ModelCallable;
|
|
451
464
|
}
|
|
465
|
+
/** Options for init() */
|
|
452
466
|
interface InitOptions$1 {
|
|
453
467
|
apiKey?: string;
|
|
454
468
|
baseUrl?: string;
|
|
455
469
|
}
|
|
470
|
+
/** Options for evaluate() */
|
|
456
471
|
interface EvaluateOptions {
|
|
457
472
|
dataset: DatasetInput;
|
|
458
|
-
metrics
|
|
473
|
+
/** List of metrics to run (built-in or custom). Default: all built-in metrics */
|
|
474
|
+
metrics?: MetricInput[];
|
|
459
475
|
judgeModel?: string;
|
|
460
476
|
name?: string;
|
|
461
477
|
description?: string;
|
|
462
478
|
verbose?: boolean;
|
|
463
479
|
_skipUpload?: boolean;
|
|
464
480
|
}
|
|
481
|
+
/** Options for compareModels() */
|
|
465
482
|
interface CompareModelsOptions extends EvaluateOptions {
|
|
466
483
|
/**
|
|
467
484
|
* List of models to test. Each can be:
|
|
@@ -472,31 +489,72 @@ interface CompareModelsOptions extends EvaluateOptions {
|
|
|
472
489
|
includeProduction?: boolean;
|
|
473
490
|
modelKwargs?: Record<string, unknown>;
|
|
474
491
|
}
|
|
492
|
+
/** Type guard to check if a metric is a CustomMetric */
|
|
493
|
+
declare function isCustomMetric(metric: MetricInput): metric is CustomMetric;
|
|
494
|
+
/** Get the name of a metric (works for both built-in and custom) */
|
|
495
|
+
declare function getMetricName(metric: MetricInput): string;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* G-Eval prompts for each metric.
|
|
499
|
+
*/
|
|
500
|
+
|
|
501
|
+
/** G-Eval prompts for each built-in metric */
|
|
502
|
+
declare const METRIC_PROMPTS: Record<MetricName, {
|
|
503
|
+
criteria: string;
|
|
504
|
+
steps: string[];
|
|
505
|
+
}>;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Core evaluation functions.
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
declare const DEFAULT_JUDGE_MODEL = "openai/gpt-4o-mini";
|
|
475
512
|
/**
|
|
476
513
|
* Initialize Fallom evals.
|
|
477
514
|
*/
|
|
478
515
|
declare function init$1(options?: InitOptions$1): void;
|
|
479
516
|
/**
|
|
480
517
|
* Evaluate production outputs against specified metrics using G-Eval.
|
|
518
|
+
*
|
|
481
519
|
* Results are automatically uploaded to Fallom dashboard.
|
|
482
520
|
*/
|
|
483
521
|
declare function evaluate(options: EvaluateOptions): Promise<EvalResult[]>;
|
|
484
522
|
/**
|
|
485
|
-
*
|
|
523
|
+
* Compare multiple models on the same dataset.
|
|
524
|
+
*
|
|
525
|
+
* Results are automatically uploaded to Fallom dashboard.
|
|
526
|
+
*/
|
|
527
|
+
declare function compareModels(options: CompareModelsOptions): Promise<Record<string, EvalResult[]>>;
|
|
528
|
+
/**
|
|
529
|
+
* Public function to upload results manually.
|
|
530
|
+
*/
|
|
531
|
+
declare function uploadResultsPublic(results: EvalResult[] | Record<string, EvalResult[]>, options: {
|
|
532
|
+
name: string;
|
|
533
|
+
description?: string;
|
|
534
|
+
judgeModel?: string;
|
|
535
|
+
}): Promise<string>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Helper functions for creating models and datasets.
|
|
539
|
+
*/
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Create a Model using OpenAI directly (for fine-tuned models or Azure OpenAI).
|
|
486
543
|
*
|
|
487
544
|
* @param modelId - The OpenAI model ID (e.g., "gpt-4o" or "ft:gpt-4o-2024-08-06:org::id")
|
|
488
545
|
* @param options - Configuration options
|
|
489
|
-
* @returns
|
|
546
|
+
* @returns Model instance that can be used in compareModels()
|
|
490
547
|
*/
|
|
491
548
|
declare function createOpenAIModel(modelId: string, options?: {
|
|
492
549
|
name?: string;
|
|
493
550
|
apiKey?: string;
|
|
494
|
-
|
|
551
|
+
baseUrl?: string;
|
|
495
552
|
temperature?: number;
|
|
496
553
|
maxTokens?: number;
|
|
497
554
|
}): Model;
|
|
498
555
|
/**
|
|
499
556
|
* Create a Model for any OpenAI-compatible API endpoint.
|
|
557
|
+
*
|
|
500
558
|
* Works with self-hosted models (vLLM, Ollama, LMStudio, etc.), custom endpoints,
|
|
501
559
|
* or any service that follows the OpenAI chat completions API format.
|
|
502
560
|
*
|
|
@@ -510,12 +568,13 @@ declare function createCustomModel(name: string, options: {
|
|
|
510
568
|
headers?: Record<string, string>;
|
|
511
569
|
modelField?: string;
|
|
512
570
|
modelValue?: string;
|
|
513
|
-
|
|
514
|
-
maxTokens?: number;
|
|
571
|
+
extraParams?: Record<string, unknown>;
|
|
515
572
|
}): Model;
|
|
516
573
|
/**
|
|
517
574
|
* Create a Model from any callable function.
|
|
518
|
-
*
|
|
575
|
+
*
|
|
576
|
+
* This is the most flexible option - you provide a function that takes
|
|
577
|
+
* messages and returns a response.
|
|
519
578
|
*
|
|
520
579
|
* @param name - Display name for the model
|
|
521
580
|
* @param callFn - Function that takes messages and returns a response
|
|
@@ -523,17 +582,19 @@ declare function createCustomModel(name: string, options: {
|
|
|
523
582
|
*/
|
|
524
583
|
declare function createModelFromCallable(name: string, callFn: ModelCallable): Model;
|
|
525
584
|
/**
|
|
526
|
-
*
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* so this is only needed for custom scenarios.
|
|
585
|
+
* Create a custom evaluation metric using G-Eval.
|
|
586
|
+
*
|
|
587
|
+
* @param name - Unique identifier for the metric (e.g., "brand_alignment")
|
|
588
|
+
* @param criteria - Description of what the metric evaluates
|
|
589
|
+
* @param steps - List of evaluation steps for the LLM judge to follow
|
|
590
|
+
* @returns A CustomMetric instance
|
|
533
591
|
*/
|
|
534
|
-
declare function
|
|
592
|
+
declare function customMetric(name: string, criteria: string, steps: string[]): CustomMetric;
|
|
535
593
|
/**
|
|
536
594
|
* Create a dataset from Fallom trace data.
|
|
595
|
+
*
|
|
596
|
+
* @param traces - List of trace objects with attributes
|
|
597
|
+
* @returns List of DatasetItem ready for evaluation
|
|
537
598
|
*/
|
|
538
599
|
declare function datasetFromTraces(traces: Array<{
|
|
539
600
|
attributes?: Record<string, unknown>;
|
|
@@ -542,27 +603,34 @@ declare function datasetFromTraces(traces: Array<{
|
|
|
542
603
|
* Fetch a dataset stored in Fallom by its key.
|
|
543
604
|
*
|
|
544
605
|
* @param datasetKey - The unique key of the dataset (e.g., "customer-support-qa")
|
|
545
|
-
* @param version - Specific version number to fetch. If undefined, fetches
|
|
606
|
+
* @param version - Specific version number to fetch. If undefined, fetches latest.
|
|
607
|
+
* @param config - Internal config (api key, base url, initialized flag)
|
|
546
608
|
* @returns List of DatasetItem ready for evaluation
|
|
547
609
|
*/
|
|
548
|
-
declare function datasetFromFallom(datasetKey: string, version?: number
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
610
|
+
declare function datasetFromFallom(datasetKey: string, version?: number, config?: {
|
|
611
|
+
_apiKey?: string | null;
|
|
612
|
+
_baseUrl?: string;
|
|
613
|
+
_initialized?: boolean;
|
|
614
|
+
}): Promise<DatasetItem[]>;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Fallom Evals - Run LLM evaluations locally using G-Eval with LLM as a Judge.
|
|
618
|
+
*
|
|
619
|
+
* Evaluate production outputs or compare different models on your dataset.
|
|
620
|
+
* Results are uploaded to Fallom dashboard for visualization.
|
|
621
|
+
*/
|
|
558
622
|
|
|
559
623
|
declare const evals_AVAILABLE_METRICS: typeof AVAILABLE_METRICS;
|
|
560
624
|
type evals_CompareModelsOptions = CompareModelsOptions;
|
|
625
|
+
type evals_CustomMetric = CustomMetric;
|
|
626
|
+
declare const evals_DEFAULT_JUDGE_MODEL: typeof DEFAULT_JUDGE_MODEL;
|
|
561
627
|
type evals_DatasetInput = DatasetInput;
|
|
562
628
|
type evals_DatasetItem = DatasetItem;
|
|
563
629
|
type evals_EvalResult = EvalResult;
|
|
564
630
|
type evals_EvaluateOptions = EvaluateOptions;
|
|
631
|
+
declare const evals_METRIC_PROMPTS: typeof METRIC_PROMPTS;
|
|
565
632
|
type evals_Message = Message;
|
|
633
|
+
type evals_MetricInput = MetricInput;
|
|
566
634
|
type evals_MetricName = MetricName;
|
|
567
635
|
type evals_Model = Model;
|
|
568
636
|
type evals_ModelCallable = ModelCallable;
|
|
@@ -571,12 +639,14 @@ declare const evals_compareModels: typeof compareModels;
|
|
|
571
639
|
declare const evals_createCustomModel: typeof createCustomModel;
|
|
572
640
|
declare const evals_createModelFromCallable: typeof createModelFromCallable;
|
|
573
641
|
declare const evals_createOpenAIModel: typeof createOpenAIModel;
|
|
642
|
+
declare const evals_customMetric: typeof customMetric;
|
|
574
643
|
declare const evals_datasetFromFallom: typeof datasetFromFallom;
|
|
575
644
|
declare const evals_datasetFromTraces: typeof datasetFromTraces;
|
|
576
645
|
declare const evals_evaluate: typeof evaluate;
|
|
577
|
-
declare const
|
|
646
|
+
declare const evals_getMetricName: typeof getMetricName;
|
|
647
|
+
declare const evals_isCustomMetric: typeof isCustomMetric;
|
|
578
648
|
declare namespace evals {
|
|
579
|
-
export { evals_AVAILABLE_METRICS as AVAILABLE_METRICS, type evals_CompareModelsOptions as CompareModelsOptions, type evals_DatasetInput as DatasetInput, type evals_DatasetItem as DatasetItem, type evals_EvalResult as EvalResult, type evals_EvaluateOptions as EvaluateOptions, type InitOptions$1 as InitOptions, type evals_Message as Message, type evals_MetricName as MetricName, type evals_Model as Model, type evals_ModelCallable as ModelCallable, type evals_ModelResponse as ModelResponse, evals_compareModels as compareModels, evals_createCustomModel as createCustomModel, evals_createModelFromCallable as createModelFromCallable, evals_createOpenAIModel as createOpenAIModel, evals_datasetFromFallom as datasetFromFallom, evals_datasetFromTraces as datasetFromTraces,
|
|
649
|
+
export { evals_AVAILABLE_METRICS as AVAILABLE_METRICS, type evals_CompareModelsOptions as CompareModelsOptions, type evals_CustomMetric as CustomMetric, evals_DEFAULT_JUDGE_MODEL as DEFAULT_JUDGE_MODEL, type evals_DatasetInput as DatasetInput, type evals_DatasetItem as DatasetItem, type evals_EvalResult as EvalResult, type evals_EvaluateOptions as EvaluateOptions, type InitOptions$1 as InitOptions, evals_METRIC_PROMPTS as METRIC_PROMPTS, type evals_Message as Message, type evals_MetricInput as MetricInput, type evals_MetricName as MetricName, type evals_Model as Model, type evals_ModelCallable as ModelCallable, type evals_ModelResponse as ModelResponse, evals_compareModels as compareModels, evals_createCustomModel as createCustomModel, evals_createModelFromCallable as createModelFromCallable, evals_createOpenAIModel as createOpenAIModel, evals_customMetric as customMetric, evals_datasetFromFallom as datasetFromFallom, evals_datasetFromTraces as datasetFromTraces, evals_evaluate as evaluate, evals_getMetricName as getMetricName, init$1 as init, evals_isCustomMetric as isCustomMetric, uploadResultsPublic as uploadResults };
|
|
580
650
|
}
|
|
581
651
|
|
|
582
652
|
/**
|