SDKs & toolsTypeScript referenceEvaluations and prompts

TypeScript SDK: Evaluations and prompts

⚠️
Preview — this feature is being built; the design below is the spec.

Datasets, graders, runs, prompt tools and templates.

import Syntic from '@syntic/sdk'
 
const client = new Syntic() // reads SYNTIC_API_KEY
MethodEndpointReturns
evals.datasets.createPOST /v1/evals/datasetsEvalDataset
evals.datasets.items.addPOST /v1/evals/datasets/{dataset_id}/itemsItemsAdded
evals.graders.createPOST /v1/evals/gradersEvalGrader
evals.runs.createPOST /v1/evals/runsEvalRun
evals.runs.wait(helper; polls GET /v1/evals/runs/{eval_run_id})EvalRun
evals.runs.resultsGET /v1/evals/runs/{eval_run_id}/resultsSyncPage[EvalResult]
prompts.improvePOST /v1/prompts/improveImprovedPrompt
prompts.templates.setLabelPUT /v1/prompts/templates/{template}/labels/{label}PromptTemplate

Methods

evals.datasets.create

Create a dataset. Maps to POST /v1/evals/datasets.

const result = await client.evals.datasets.create({
  name: "support-replies-v3"
})

evals.datasets.items.add

Add up to 1,000 items. Maps to POST /v1/evals/datasets/{dataset_id}/items.

const result = await client.evals.datasets.items.add("evds_01JD13B5D7F9H1K3M5P7", {
  items: [
    {
      input: {
        ticket: "…"
      },
      ideal: "…"
    }
  ]
})

evals.graders.create

Define a grader. Maps to POST /v1/evals/graders.

const result = await client.evals.graders.create({
  name: "no-guarantees",
  kind: "contains",
  config: {
    not: [
      "guarantee"
    ]
  }
})

evals.runs.create

Start a run with up to four variants. Maps to POST /v1/evals/runs.

const result = await client.evals.runs.create({
  dataset_id: "evds_01JD13B5D7F9H1K3M5P7",
  variants: [
    {
      label: "baseline",
      model: "Amara S1.2",
      prompt_version: "support@production"
    }
  ],
  grader_ids: [
    "evgr_01JD46E8G0J2L4N6Q8S0"
  ]
})

evals.runs.wait

Helper: wait for a run to finish.

const result = await client.evals.runs.wait("evrun_01JD35D7F9H1K3M5P7R9")

evals.runs.results

Iterate graded results. Maps to GET /v1/evals/runs/{eval_run_id}/results.

for await (const item of client.evals.runs.results("evrun_01JD35D7F9H1K3M5P7R9", {
  passed: false
})) {
  console.log(item)
}

prompts.improve

Rewrite a prompt against feedback. Maps to POST /v1/prompts/improve.

const result = await client.prompts.improve({
  system: "…",
  feedback: "Too long."
})

prompts.templates.setLabel

Promote a version. Maps to PUT /v1/prompts/templates/{template}/labels/{label}.

const result = await client.prompts.templates.setLabel("support", "production", {
  version: 13
})

Conventions

Every method accepts a final options object with headers, query, timeout, maxRetries and signal (an AbortSignal). List methods return pages that work with for await across all pages.

See the TypeScript SDK overview for installation, errors and retries.

Was this page helpful?