@learnpack/learnpack 5.0.313 → 5.0.315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/serve.js +341 -274
- package/lib/utils/creatorUtilities.d.ts +2 -0
- package/lib/utils/creatorUtilities.js +37 -14
- package/lib/utils/rigoActions.d.ts +7 -0
- package/lib/utils/rigoActions.js +17 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +422 -413
- package/src/utils/creatorUtilities.ts +536 -504
- package/src/utils/rigoActions.ts +29 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Lesson } from "../models/creator";
|
|
1
2
|
type TEstimateReadingTimeReturns = {
|
|
2
3
|
minutes: number;
|
|
3
4
|
words: number;
|
|
@@ -97,4 +98,5 @@ export declare function howManyDifficultParagraphs(paragraphs: TFKGLResult[], ma
|
|
|
97
98
|
export declare const appendContentIndex: () => Promise<string | null>;
|
|
98
99
|
export declare const appendAIRules: () => Promise<string | null>;
|
|
99
100
|
export declare const getReadmeExtension: (language: string) => string;
|
|
101
|
+
export declare function insertStepInCorrectPosition(lessons: Lesson[], newLesson: Lesson): Lesson[];
|
|
100
102
|
export {};
|
|
@@ -15,6 +15,7 @@ exports.extractWords = extractWords;
|
|
|
15
15
|
exports.fleschKincaidGrade = fleschKincaidGrade;
|
|
16
16
|
exports.countSentences = countSentences;
|
|
17
17
|
exports.howManyDifficultParagraphs = howManyDifficultParagraphs;
|
|
18
|
+
exports.insertStepInCorrectPosition = insertStepInCorrectPosition;
|
|
18
19
|
const console_1 = require("./console");
|
|
19
20
|
const frontMatter = require("front-matter");
|
|
20
21
|
const MarkdownIt = require("markdown-it");
|
|
@@ -333,13 +334,13 @@ function countSentences(text) {
|
|
|
333
334
|
function howManyDifficultParagraphs(paragraphs, maxFKGL) {
|
|
334
335
|
return paragraphs.filter(paragraph => paragraph.fkgl > maxFKGL).length;
|
|
335
336
|
}
|
|
336
|
-
const example_content = `Write or paste your table of content below this line, each topic should be defined on a new line, here is an example:
|
|
337
|
-
|
|
338
|
-
Introduction to AI: Explain what is AI and its applications
|
|
339
|
-
Introduction to Machine Learning: Explain what is machine learning and its applications
|
|
340
|
-
What is an AI Model: Explain what is an AI model and its applications
|
|
341
|
-
How to use an AI Model: Different APIs, local models, etc.
|
|
342
|
-
How to build an AI Model: Fine-tuning, data collection, cleaning and more.
|
|
337
|
+
const example_content = `Write or paste your table of content below this line, each topic should be defined on a new line, here is an example:
|
|
338
|
+
|
|
339
|
+
Introduction to AI: Explain what is AI and its applications
|
|
340
|
+
Introduction to Machine Learning: Explain what is machine learning and its applications
|
|
341
|
+
What is an AI Model: Explain what is an AI model and its applications
|
|
342
|
+
How to use an AI Model: Different APIs, local models, etc.
|
|
343
|
+
How to build an AI Model: Fine-tuning, data collection, cleaning and more.
|
|
343
344
|
`;
|
|
344
345
|
const appendContentIndex = async () => {
|
|
345
346
|
const choices = await prompts([
|
|
@@ -369,13 +370,13 @@ const appendContentIndex = async () => {
|
|
|
369
370
|
return null;
|
|
370
371
|
};
|
|
371
372
|
exports.appendContentIndex = appendContentIndex;
|
|
372
|
-
const example_airules = `
|
|
373
|
-
Write with an engaging tone, use simple words and avoid complex sentences.
|
|
374
|
-
Write in first person, as if you are talking to the reader.
|
|
375
|
-
Add mental maps to help the reader understand the content.
|
|
376
|
-
Add diagrams to help the reader understand the content.
|
|
377
|
-
No code exercises required
|
|
378
|
-
|
|
373
|
+
const example_airules = `
|
|
374
|
+
Write with an engaging tone, use simple words and avoid complex sentences.
|
|
375
|
+
Write in first person, as if you are talking to the reader.
|
|
376
|
+
Add mental maps to help the reader understand the content.
|
|
377
|
+
Add diagrams to help the reader understand the content.
|
|
378
|
+
No code exercises required
|
|
379
|
+
|
|
379
380
|
`;
|
|
380
381
|
const appendAIRules = async () => {
|
|
381
382
|
const choices = await prompts([
|
|
@@ -409,3 +410,25 @@ const getReadmeExtension = (language) => {
|
|
|
409
410
|
return language === "en" || language === "us" ? ".md" : `.${language}.md`;
|
|
410
411
|
};
|
|
411
412
|
exports.getReadmeExtension = getReadmeExtension;
|
|
413
|
+
const parseId = (id) => {
|
|
414
|
+
return id.split(".").map(part => parseInt(part, 10));
|
|
415
|
+
};
|
|
416
|
+
// Compare function for sorting
|
|
417
|
+
const compareIds = (a, b) => {
|
|
418
|
+
const aParts = parseId(a);
|
|
419
|
+
const bParts = parseId(b);
|
|
420
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
421
|
+
const aVal = aParts[i] || 0;
|
|
422
|
+
const bVal = bParts[i] || 0;
|
|
423
|
+
if (aVal !== bVal)
|
|
424
|
+
return aVal - bVal;
|
|
425
|
+
}
|
|
426
|
+
return 0;
|
|
427
|
+
};
|
|
428
|
+
function insertStepInCorrectPosition(lessons, newLesson) {
|
|
429
|
+
// Parse the id to extract numeric parts for sorting
|
|
430
|
+
// Create new array with the new lesson
|
|
431
|
+
const updatedLessons = [...lessons, newLesson];
|
|
432
|
+
// Sort by id
|
|
433
|
+
return updatedLessons.sort((a, b) => compareIds(a.id, b.id));
|
|
434
|
+
}
|
|
@@ -110,4 +110,11 @@ type TGenerateCodeChallengeInputs = {
|
|
|
110
110
|
challenge_proposal: string;
|
|
111
111
|
};
|
|
112
112
|
export declare const generateCodeChallenge: (token: string, inputs: TGenerateCodeChallengeInputs, webhookUrl?: string) => Promise<any>;
|
|
113
|
+
type TCreateStepInputs = {
|
|
114
|
+
description: string;
|
|
115
|
+
stepIndex: number;
|
|
116
|
+
courseInfo: string;
|
|
117
|
+
lang: string;
|
|
118
|
+
};
|
|
119
|
+
export declare const generateStepSlug: (token: string, inputs: TCreateStepInputs) => Promise<any>;
|
|
113
120
|
export {};
|
package/lib/utils/rigoActions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCodeChallenge = exports.addInteractivity = exports.initialContentGenerator = exports.getLanguageCodes = exports.isPackageAuthor = exports.fillSidebarJSON = exports.generateCourseShortName = exports.isValidRigoToken = exports.translateCourseMetadata = exports.createStructuredPreviewReadme = exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
|
|
3
|
+
exports.generateStepSlug = exports.generateCodeChallenge = exports.addInteractivity = exports.initialContentGenerator = exports.getLanguageCodes = exports.isPackageAuthor = exports.fillSidebarJSON = exports.generateCourseShortName = exports.isValidRigoToken = exports.translateCourseMetadata = exports.createStructuredPreviewReadme = exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
|
|
4
4
|
exports.downloadImage = downloadImage;
|
|
5
5
|
exports.createPreviewReadme = createPreviewReadme;
|
|
6
6
|
exports.makeReadmeReadable = makeReadmeReadable;
|
|
@@ -346,3 +346,19 @@ const generateCodeChallenge = async (token, inputs, webhookUrl) => {
|
|
|
346
346
|
}
|
|
347
347
|
};
|
|
348
348
|
exports.generateCodeChallenge = generateCodeChallenge;
|
|
349
|
+
const generateStepSlug = async (token, inputs) => {
|
|
350
|
+
try {
|
|
351
|
+
const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/prompting/completion/step-slug-generator/`, { inputs, include_purpose_objective: false, execute_async: false }, {
|
|
352
|
+
headers: {
|
|
353
|
+
"Content-Type": "application/json",
|
|
354
|
+
Authorization: "Token " + token.trim(),
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
return response.data;
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
console.error("Error in createStep:", error);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
exports.generateStepSlug = generateStepSlug;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learnpack/learnpack",
|
|
3
3
|
"description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.315",
|
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
|
6
6
|
"contributors": [
|
|
7
7
|
{
|