Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

1.0 KB
Raw Blame
import type { EvalTemplateType } from "@langfuse/shared";

import { MANAGED_TEMPLATES_CATALOG } from "@/src/features/evals/v2/constants/managedTemplatesCatalog";

export const managedEvaluatorTemplateService = {
  list({
    search,
    category,
    type,
  }: {
    search?: string;
    category?: string;
    type?: EvalTemplateType;
  } = {}) {
    const query = search?.trim().toLowerCase();

    return {
      schemaVersion: MANAGED_TEMPLATES_CATALOG.schemaVersion,
      categories: MANAGED_TEMPLATES_CATALOG.categories,
      templates: MANAGED_TEMPLATES_CATALOG.templates.filter(
        (template) =>
          (!query ||
            template.name.toLowerCase().includes(query) ||
            template.description.toLowerCase().includes(query)) &&
          (!category || template.categories.includes(category)) &&
          (!type || template.evaluator.type === type),
      ),
    };
  },

  get(key: string) {
    return MANAGED_TEMPLATES_CATALOG.templates.find(
      (template) => template.key === key,
    );
  },
};