@direqt/story-dataset
v1.0.6
Published
Sample story dataset for testing purposes
Downloads
3
Readme
Story Dataset Transformer
This script transforms a dataset of stories into a standardized format suitable for further processing or usage. It takes the testData and converts it into a TransformedStory format, which includes specific properties such as title, description, body, webUrl, primaryImageUrl, additionalMediaUrls, tags, and prompts.
Prerequisites
- Node.js (version X.X.X)
- TypeScript (version X.X.X)
Installation
$ npm i -D @direqt/story-dataset
Get a random story from the transformed dataset
Additional functionality includes accessibility to the data from a random story in the dataset in a simplified and easy to test format.
Here's an example of accessing the random story and printing it to the console:
import { getRandomStory} from "@direqt/story-dataset";
const story = getRandomStory();
console.dir(story);
Access the entire transformed dataset
Here's an example of accessing the entire transformed dataset and outputting to a file type of choice:
import { getTransformedStories} from "@direqt/story-dataset";
const transformedData = getTransformedStories();
// Write transformedData as JSON
fs.writeFileSync('sampleStories.json', JSON.stringify(transformedData, null, 2),
{
encoding: "utf8",
flag: "w"
});
// Write transformedData as JavaScript file
fs.writeFileSync('sampleStories.js', JSON.stringify(transformedData, null, 2),
{
encoding: "utf8",
flag: "w"
});
How to add more stories to the dataset
In the Direqt console:
- Click on a registered bot/ register a bot if none available
- Navigate to the "Stories" tab under "My Chatbots"
- Create a new story if none available: select "import by URL" and paste URL of story
- Make sure to populate the "Body text" section with text from the story if no Body text is shown
- Once stories are shown, right click on page and navigate to "Inspect -> Network"
- Click on "Stories" to get the network activity for the page
- Scroll down under "Name" and select the first activity labeled "story?chatApplication=..."
- Navigate to "Response"; copy any story data needed starting with "{" and ending with "},"
- Paste any new story data into src/testData.ts inside testData array
Sample code
See the ./samples/ folder for sample dataset usage.