DOC: <Issue related to /evaluation/how_to_guides/manage_datasets_programmatically> #90

Closed
opened 2026-02-21 17:17:09 -05:00 by yindo · 0 comments
Owner

Originally created by @birdglove2 on GitHub (Aug 21, 2025).

Cannot create examples in a dataset using documentation.
Error 422: Unprocessable entity: invalid Content-Type

Code from the documentation
Link: https://docs.smith.langchain.com/evaluation/how_to_guides/manage_datasets_programmatically#create-a-dataset-from-list-of-values

Image
const client = new Client({
  apiKey,
  apiUrl: "https://api.smith.langchain.com",
});

const exampleInputs: [string, string][] = [
  ["What is the largest mammal?", "The blue whale"],
  ["What do mammals and birds have in common?", "They are both warm-blooded"],
  ["What are reptiles known for?", "Having scales"],
  [
    "What's the main characteristic of amphibians?",
    "They live both in water and on land",
  ],
];

const datasetName = "Elementary Animal Questions";

// Storing inputs in a dataset lets us
// run chains and LLMs over a shared set of examples.
const dataset = await client.createDataset(datasetName, {
  description: "Questions and answers about animal phylogenetics",
});

// Prepare inputs, outputs, and metadata for bulk creation
const inputs = exampleInputs.map(([inputPrompt]) => ({
  question: inputPrompt,
}));
const outputs = exampleInputs.map(([, outputAnswer]) => ({
  answer: outputAnswer,
}));
const metadata = exampleInputs.map(() => ({ source: "Wikipedia" }));

// Use the bulk createExamples method
await client.createExample({
  inputs,
  outputs,
  metadata,
  dataset_id: dataset.id,
});
Originally created by @birdglove2 on GitHub (Aug 21, 2025). Cannot create examples in a dataset using documentation. Error 422: Unprocessable entity: invalid Content-Type Code from the documentation Link: https://docs.smith.langchain.com/evaluation/how_to_guides/manage_datasets_programmatically#create-a-dataset-from-list-of-values <img width="791" height="769" alt="Image" src="https://github.com/user-attachments/assets/bfe87d47-0de8-4507-922f-2d389eeff3de" /> ``` const client = new Client({ apiKey, apiUrl: "https://api.smith.langchain.com", }); const exampleInputs: [string, string][] = [ ["What is the largest mammal?", "The blue whale"], ["What do mammals and birds have in common?", "They are both warm-blooded"], ["What are reptiles known for?", "Having scales"], [ "What's the main characteristic of amphibians?", "They live both in water and on land", ], ]; const datasetName = "Elementary Animal Questions"; // Storing inputs in a dataset lets us // run chains and LLMs over a shared set of examples. const dataset = await client.createDataset(datasetName, { description: "Questions and answers about animal phylogenetics", }); // Prepare inputs, outputs, and metadata for bulk creation const inputs = exampleInputs.map(([inputPrompt]) => ({ question: inputPrompt, })); const outputs = exampleInputs.map(([, outputAnswer]) => ({ answer: outputAnswer, })); const metadata = exampleInputs.map(() => ({ source: "Wikipedia" })); // Use the bulk createExamples method await client.createExample({ inputs, outputs, metadata, dataset_id: dataset.id, }); ```
yindo closed this issue 2026-02-21 17:17:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langsmith-docs#90