From 8420e094cfc13f5f1191361176aa8bc24fb643ab Mon Sep 17 00:00:00 2001 From: Mutugi <48474421+Mutugiii@users.noreply.github.com> Date: Wed, 9 Aug 2023 18:57:23 +0300 Subject: [PATCH 1/4] chatapi: install only node production dependencies (fixes #7217) (#7211) Co-authored-by: dogi --- chatapi/package.json | 11 ++++++----- docker/chatapi/amd64-Dockerfile | 4 ++-- docker/chatapi/arm-Dockerfile | 4 ++-- docker/chatapi/arm64-Dockerfile | 4 ++-- package.json | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/chatapi/package.json b/chatapi/package.json index 3ed1a5eadb..519d89bbfa 100644 --- a/chatapi/package.json +++ b/chatapi/package.json @@ -5,6 +5,7 @@ "main": "index.ts", "scripts": { "start": "ts-node src/index.ts", + "build": "tsc", "dev": "nodemon --exec ts-node src/index.ts", "lint": "eslint . --ext .ts", "lint-fix": "eslint . --ext .ts --fix" @@ -32,16 +33,16 @@ "cors": "^2.8.5", "express": "^4.18.2", "nano": "^10.1.2", - "openai": "^3.3.0" + "openai": "^3.3.0", + "dotenv": "^16.1.4", + "ts-node": "^10.9.1", + "typescript": "^5.1.3" }, "devDependencies": { "@types/node": "^20.3.1", "@typescript-eslint/eslint-plugin": "^5.60.0", "@typescript-eslint/parser": "^5.60.0", - "dotenv": "^16.1.4", "eslint": "^8.43.0", - "nodemon": "^2.0.22", - "ts-node": "^10.9.1", - "typescript": "^5.1.3" + "nodemon": "^2.0.22" } } diff --git a/docker/chatapi/amd64-Dockerfile b/docker/chatapi/amd64-Dockerfile index 3ca62aa161..c9de12b172 100644 --- a/docker/chatapi/amd64-Dockerfile +++ b/docker/chatapi/amd64-Dockerfile @@ -3,8 +3,8 @@ FROM treehouses/node RUN apk update # Install dependencies -COPY ./chatapi/package*.json ./ -RUN npm install +COPY ./chatapi/package.json ./ +RUN npm install --production # Copy the application code COPY ./chatapi/src ./src/ diff --git a/docker/chatapi/arm-Dockerfile b/docker/chatapi/arm-Dockerfile index 39068a7e9c..1591c1b3ad 100644 --- a/docker/chatapi/arm-Dockerfile +++ b/docker/chatapi/arm-Dockerfile @@ -10,8 +10,8 @@ FROM treehouses/node-tags:arm RUN apk update -COPY ./chatapi/package*.json ./ -RUN npm install +COPY ./chatapi/package.json ./ +RUN npm install --production COPY ./chatapi/src ./src/ COPY ./chatapi/tsconfig.json ./tsconfig.json diff --git a/docker/chatapi/arm64-Dockerfile b/docker/chatapi/arm64-Dockerfile index e831de5643..b272cf9dab 100644 --- a/docker/chatapi/arm64-Dockerfile +++ b/docker/chatapi/arm64-Dockerfile @@ -10,8 +10,8 @@ FROM treehouses/node-tags:arm64 RUN apk update -COPY ./chatapi/package*.json ./ -RUN npm install +COPY ./chatapi/package.json ./ +RUN npm install --production COPY ./chatapi/src ./src/ COPY ./chatapi/tsconfig.json ./tsconfig.json diff --git a/package.json b/package.json index 1d0eabf059..4ad900b712 100755 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "planet", "license": "AGPL-3.0", - "version": "0.13.25", + "version": "0.13.26", "myplanet": { - "latest": "v0.9.57", - "min": "v0.9.30" + "latest": "v0.9.60", + "min": "v0.9.36" }, "scripts": { "ng": "ng", From 197b87c96757c1287837e740bc5043631068cf5b Mon Sep 17 00:00:00 2001 From: Mutugi <48474421+Mutugiii@users.noreply.github.com> Date: Thu, 10 Aug 2023 19:43:20 +0300 Subject: [PATCH 2/4] landing: refactor template (fixes #3175)(fixes #3176) (#7204) --- src/app/landing/landing.component.html | 8 ----- src/app/landing/landing.component.ts | 41 ++++++++++++++++---------- 2 files changed, 26 insertions(+), 23 deletions(-) delete mode 100644 src/app/landing/landing.component.html diff --git a/src/app/landing/landing.component.html b/src/app/landing/landing.component.html deleted file mode 100644 index 961b7e9c70..0000000000 --- a/src/app/landing/landing.component.html +++ /dev/null @@ -1,8 +0,0 @@ -
- -
- - -
- -
diff --git a/src/app/landing/landing.component.ts b/src/app/landing/landing.component.ts index 0a30d96083..d1424c0d06 100644 --- a/src/app/landing/landing.component.ts +++ b/src/app/landing/landing.component.ts @@ -2,22 +2,33 @@ import { Component } from '@angular/core'; @Component({ selector: 'planet-landing', - templateUrl: './landing.component.html', - styles: [ ` - .layoutbox { - position: relative; - min-height: 100vh; - overflow-x: hidden; - max-width: 100%; - font-family: "Roboto", "Helvetica", "Arial", sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - } + template: ` +
+ +
+ + +
+ +
+ `, + styles: [ + ` + .layoutbox { + position: relative; + min-height: 100vh; + overflow-x: hidden; + max-width: 100%; + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } - .childrenbox { - padding-bottom: 6rem; - } - ` ] + .childrenbox { + padding-bottom: 6rem; + } + `, + ], }) export class LandingComponent { From 07a21d4d8f8b0ad613a4a4ad1177ff5392e39ea4 Mon Sep 17 00:00:00 2001 From: Mutugi <48474421+Mutugiii@users.noreply.github.com> Date: Thu, 10 Aug 2023 19:53:39 +0300 Subject: [PATCH 3/4] markdown: display full wysiwyg box (fixes #7212) (#7213) --- src/app/shared/forms/planet-markdown-textbox.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/forms/planet-markdown-textbox.scss b/src/app/shared/forms/planet-markdown-textbox.scss index cc7eb1cada..cac82c94c1 100644 --- a/src/app/shared/forms/planet-markdown-textbox.scss +++ b/src/app/shared/forms/planet-markdown-textbox.scss @@ -22,7 +22,7 @@ planet-markdown-textbox { .CodeMirror, .CodeMirror-scroll { height: inherit; - min-height: inherit; + min-height: 15vh !important; max-height: 15vh; } From 14881a1284e51a560f10655b59f1817f8fd94a03 Mon Sep 17 00:00:00 2001 From: mutugiii Date: Tue, 15 Aug 2023 15:57:31 +0300 Subject: [PATCH 4/4] Experiment: Course Ratings & suggestions --- .../add-courses/courses-add.component.html | 2 ++ .../add-courses/courses-add.component.ts | 30 ++++++++++++++++++- .../add-courses/courses-step.component.html | 2 ++ .../add-courses/courses-step.component.ts | 19 +++++++++++- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/app/courses/add-courses/courses-add.component.html b/src/app/courses/add-courses/courses-add.component.html index 3a4aa9c6d9..ea5dbdca27 100644 --- a/src/app/courses/add-courses/courses-add.component.html +++ b/src/app/courses/add-courses/courses-add.component.html @@ -42,11 +42,13 @@
+ {{rating}}
+
diff --git a/src/app/courses/add-courses/courses-add.component.ts b/src/app/courses/add-courses/courses-add.component.ts index e50741d9e0..a1101a7cbc 100644 --- a/src/app/courses/add-courses/courses-add.component.ts +++ b/src/app/courses/add-courses/courses-add.component.ts @@ -18,6 +18,7 @@ import { PouchService } from '../../shared/database/pouch.service'; import { debug } from '../../debug-operator'; import { TagsService } from '../../shared/forms/tags.service'; import { showFormErrors } from '../../shared/table-helpers'; +import { ChatService } from '../../shared/chat.service'; @Component({ templateUrl: 'courses-add.component.html', @@ -58,6 +59,7 @@ export class CoursesAddComponent implements OnInit, OnDestroy { languageNames = languages.map(list => list.name); mockStep = { stepTitle: $localize`Add title`, description: '!!!' }; + rating: String; constructor( private router: Router, @@ -71,7 +73,8 @@ export class CoursesAddComponent implements OnInit, OnDestroy { private stateService: StateService, private planetStepListService: PlanetStepListService, private pouchService: PouchService, - private tagsService: TagsService + private tagsService: TagsService, + private chatService: ChatService ) { this.createForm(); this.onFormChanges(); @@ -273,4 +276,29 @@ export class CoursesAddComponent implements OnInit, OnDestroy { return { ...this.coursesService.storeMarkdownImages({ ...course, steps }) }; } + rateCourse() { + if (this.courseForm.valid) { + const stepsContent = this.steps.length > 0 ? + `The course has ${this.steps.length} steps: ${this.steps.map(step => `${step.stepTitle} - ${step.description}`).join('\n')}` + : ''; + + const content = `In 3 clear blobs, 1. provide a rating for this course(granular rating out of 100%), 2. Explain why you gave the rating 3. Explain how to improve the course + Course Title: ${this.courseForm.get('courseTitle').value} + Course Description: ${this.courseForm.get('description').value.text} + Grade Level: ${this.courseForm.get('gradeLevel').value} + Subject Level: ${this.courseForm.get('subjectLevel').value} + ${stepsContent} + `; + + this.chatService.getPrompt(content).subscribe( + (rating) => { + this.rating = rating?.chat; + } + ); + } else { + showFormErrors(this.courseForm.controls); + return; + } + } + } diff --git a/src/app/courses/add-courses/courses-step.component.html b/src/app/courses/add-courses/courses-step.component.html index a5e1111b91..8552d7cc1a 100644 --- a/src/app/courses/add-courses/courses-step.component.html +++ b/src/app/courses/add-courses/courses-step.component.html @@ -29,6 +29,8 @@ + +
{{rating}}
{{activeStep?.exam ? 'Update' : 'Add' }} Test diff --git a/src/app/courses/add-courses/courses-step.component.ts b/src/app/courses/add-courses/courses-step.component.ts index c57e43def1..d0475ba462 100644 --- a/src/app/courses/add-courses/courses-step.component.ts +++ b/src/app/courses/add-courses/courses-step.component.ts @@ -7,6 +7,7 @@ import { takeUntil } from 'rxjs/operators'; import { CoursesService } from '../courses.service'; import { DialogsAddResourcesComponent } from '../../shared/dialogs/dialogs-add-resources.component'; import { DialogsLoadingService } from '../../shared/dialogs/dialogs-loading.service'; +import { ChatService } from '../../shared/chat.service'; @Component({ selector: 'planet-courses-step', @@ -24,6 +25,7 @@ export class CoursesStepComponent implements OnDestroy { dialogRef: MatDialogRef; activeStep: any; activeStepIndex = -1; + rating: Text; private onDestroy$ = new Subject(); constructor( @@ -31,7 +33,8 @@ export class CoursesStepComponent implements OnDestroy { private fb: FormBuilder, private dialog: MatDialog, private coursesService: CoursesService, - private dialogsLoadingService: DialogsLoadingService + private dialogsLoadingService: DialogsLoadingService, + private chatService: ChatService ) { this.stepForm = this.fb.group({ id: '', @@ -100,4 +103,18 @@ export class CoursesStepComponent implements OnDestroy { this.addStepEvent.emit(); } + rateStep() { + const content = `In 3 clear blobs, 1. provide a rating for this course step(granular rating out of 100%), 2. Explain why you gave the rating 3. Explain how to improve the course step + ${this.stepForm.get('stepTitle').value} - ${this.stepForm.get('description').value.text}`; + + this.chatService.getPrompt(content).subscribe( + (completion: any) => { + this.rating = completion?.chat; + }, + (error: any) => { + console.log(error); + } + ); + } + }