1.0.6 • Published 11 months ago

@direqt/story-dataset v1.0.6

Weekly downloads
-
License
None
Repository
-
Last release
11 months ago

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:

  1. Click on a registered bot/ register a bot if none available
  2. Navigate to the "Stories" tab under "My Chatbots"
  3. Create a new story if none available: select "import by URL" and paste URL of story
  4. Make sure to populate the "Body text" section with text from the story if no Body text is shown
  5. Once stories are shown, right click on page and navigate to "Inspect -> Network"
  6. Click on "Stories" to get the network activity for the page
  7. Scroll down under "Name" and select the first activity labeled "story?chatApplication=..."
  8. Navigate to "Response"; copy any story data needed starting with "{" and ending with "},"
  9. Paste any new story data into src/testData.ts inside testData array

Sample code

See the ./samples/ folder for sample dataset usage.

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago