@learnpack/learnpack 5.0.215 → 5.0.231

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.
@@ -34,19 +34,28 @@ const SyllabusEditor: React.FC = () => {
34
34
  const navigate = useNavigate()
35
35
  const { i18n } = useTranslation()
36
36
 
37
- const { history, auth, setAuth, push, cleanAll, messages, setMessages } =
38
- useStore(
39
- useShallow((state) => ({
40
- history: state.history,
41
- auth: state.auth,
42
- setAuth: state.setAuth,
43
- push: state.push,
44
- cleanAll: state.cleanAll,
45
- messages: state.messages,
46
- // formState: state.formState,
47
- setMessages: state.setMessages,
48
- }))
49
- )
37
+ const {
38
+ history,
39
+ auth,
40
+ setAuth,
41
+ push,
42
+ cleanAll,
43
+ messages,
44
+ setMessages,
45
+ technologies,
46
+ } = useStore(
47
+ useShallow((state) => ({
48
+ history: state.history,
49
+ auth: state.auth,
50
+ setAuth: state.setAuth,
51
+ push: state.push,
52
+ cleanAll: state.cleanAll,
53
+ messages: state.messages,
54
+ // formState: state.formState,
55
+ setMessages: state.setMessages,
56
+ technologies: state.technologies,
57
+ }))
58
+ )
50
59
 
51
60
  const [isGenerating, setIsGenerating] = useState(false)
52
61
  const [showLoginModal, setShowLoginModal] = useState(false)
@@ -120,9 +129,12 @@ const SyllabusEditor: React.FC = () => {
120
129
  { type: "user", content: prompt },
121
130
  { type: "assistant", content: "" },
122
131
  ])
132
+ let isAuthenticated = false
133
+ if (auth.rigoToken) {
134
+ isAuthenticated = await isValidRigoToken(auth.rigoToken)
135
+ }
123
136
 
124
- const isValid = await isValidRigoToken(auth.rigoToken)
125
- if (!isValid) {
137
+ if (!isAuthenticated && auth.rigoToken) {
126
138
  setAuth({
127
139
  ...auth,
128
140
  rigoToken: "",
@@ -134,19 +146,22 @@ const SyllabusEditor: React.FC = () => {
134
146
 
135
147
  const res = await publicInteractiveCreation(
136
148
  {
137
- courseInfo: JSON.stringify(syllabus.courseInfo),
149
+ courseInfo:
150
+ JSON.stringify(syllabus.courseInfo) +
151
+ `\nThe following technologies are available, choose up to 3 from the following list: <techs>${technologies
152
+ .filter((t) => t.lang === syllabus.courseInfo.language)
153
+ .map((t) => t.slug)
154
+ .join(", ")}</techs>`,
138
155
  prevInteractions:
139
156
  messages
140
157
  .map((message) => `${message.type}: ${message.content}`)
141
158
  .join("\n") + `\nUSER: ${prompt}`,
142
159
  },
143
- auth.rigoToken && isValid ? auth.rigoToken : auth.publicToken,
160
+ auth.rigoToken && isAuthenticated ? auth.rigoToken : auth.publicToken,
144
161
  syllabus?.courseInfo?.purpose || "learnpack-lesson-writer",
145
- auth.rigoToken && isValid ? false : true
162
+ auth.rigoToken && isAuthenticated ? false : true
146
163
  )
147
164
 
148
- console.log(res, "RES from rigobot")
149
-
150
165
  const lessons: Lesson[] = res.parsed.listOfSteps.map((step: any) =>
151
166
  parseLesson(step, syllabus.lessons)
152
167
  )
@@ -54,10 +54,15 @@
54
54
  },
55
55
  "files": {
56
56
  "description": "Upload files",
57
- "descriptionLong": "Upload a PDF or DOCX file or drag it here",
57
+ "descriptionLong": "Upload a PDF file or drag it here",
58
58
  "processing": "Processing...",
59
59
  "drop": "Drop it here",
60
- "finish": "🚀 Finish"
60
+ "finish": "🚀 Finish",
61
+ "maxImagesPerPDFWarning": "⚠️ Only 15 images per PDF are supported in LearnPack beta. You can select what to do if the PDF exceeds this limit.",
62
+ "useOnlyFirstImages": "Use only the first 15 images",
63
+ "cancelAndUploadAnother": "Cancel and upload another PDF",
64
+ "maxImagesPerPDFError": "❌ Only 15 images per PDF are supported in LearnPack beta and this PDF exceeds the limit.",
65
+ "errorProcessingPDF": "❌ Error processing PDF, please try again, if the problem persists, try with a different file."
61
66
  },
62
67
  "youtube": {
63
68
  "description": "Share a Youtube link",
@@ -110,4 +115,4 @@
110
115
  "youDontHaveAnAccount": "You don't have an account?",
111
116
  "registerHere": "Register here."
112
117
  }
113
- }
118
+ }
@@ -54,10 +54,15 @@
54
54
  },
55
55
  "files": {
56
56
  "description": "Subir archivos",
57
- "descriptionLong": "Subir un archivo PDF o DOCX o arrastralo aquí",
57
+ "descriptionLong": "Subir un archivo PDF o arrastralo aquí",
58
58
  "processing": "Procesando...",
59
59
  "drop": "Arrastra el archivo aquí",
60
- "finish": "🚀 Finalizar"
60
+ "finish": "🚀 Finalizar",
61
+ "maxImagesPerPDFWarning": "⚠️ Solo se admiten 15 imágenes por PDF en LearnPack beta. Puedes seleccionar qué hacer si el PDF excede este límite.",
62
+ "useOnlyFirstImages": "Usar solo las primeras 15 imágenes",
63
+ "cancelAndUploadAnother": "Cancelar y subir otro PDF",
64
+ "maxImagesPerPDFError": "❌ Solo se admiten 15 imágenes por PDF en LearnPack beta y este PDF excede el límite.",
65
+ "errorProcessingPDF": "❌ Error procesando PDF, por favor intenta de nuevo, si el problema persiste, intenta con un archivo diferente."
61
66
  },
62
67
  "youtube": {
63
68
  "description": "Compartir un enlace de Youtube",
@@ -2,7 +2,8 @@ export const DEV_MODE = false
2
2
 
3
3
  export const RIGOBOT_HOST = DEV_MODE
4
4
  ? "https://rigobot-test-cca7d841c9d8.herokuapp.com"
5
- : "https://rigobot.herokuapp.com"
5
+ : // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us120.gitpod.io"
6
+ "https://rigobot.herokuapp.com"
6
7
 
7
8
  export const BREATHECODE_HOST = DEV_MODE
8
9
  ? "https://breathecode-test.herokuapp.com"
@@ -1,5 +1,5 @@
1
1
  import axios from "axios"
2
- import { BREATHECODE_HOST, RIGOBOT_HOST } from "./constants"
2
+ import { BREATHECODE_HOST, DEV_MODE, RIGOBOT_HOST } from "./constants"
3
3
  import { Lesson } from "../components/LessonItem"
4
4
  import { randomUUID } from "./creatorUtils"
5
5
  import { Syllabus } from "./store"
@@ -267,6 +267,13 @@ export function getFilenameFromUrl(url: string): string {
267
267
  }
268
268
  }
269
269
 
270
+ export const makeCallbackUrl = (slug: string) => {
271
+ if (DEV_MODE) {
272
+ return `https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us120.gitpod.io/v1/learnpack/tools/images/callback?slug=${slug}`
273
+ }
274
+ return `${window.location.origin}/api/v1/webhooks/images`
275
+ }
276
+
270
277
  type TGenerateImageParams = {
271
278
  prompt: string
272
279
  }
@@ -280,6 +287,7 @@ export const generateImage = async (
280
287
  `${RIGOBOT_HOST}/v1/learnpack/tools/images`,
281
288
  {
282
289
  prompt,
290
+ webhook_callback_url: "https://www.learnpack.co/api/v1/webhooks/images",
283
291
  },
284
292
  {
285
293
  headers: {
@@ -433,3 +441,8 @@ export const fixTitleLength = (title: string) => {
433
441
  fixed = fixed.replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g, "")
434
442
  return fixed
435
443
  }
444
+
445
+ export const getTechnologies = async () => {
446
+ const response = await axios.get(`/technologies`)
447
+ return response.data
448
+ }
@@ -36,6 +36,11 @@ type Consumables = {
36
36
  [key: string]: number
37
37
  }
38
38
 
39
+ type TTechnology = {
40
+ slug: string
41
+ lang: string
42
+ }
43
+
39
44
  type Store = {
40
45
  auth: Auth
41
46
  formState: FormState
@@ -51,6 +56,8 @@ type Store = {
51
56
  setMessages: (messages: TMessage[]) => void
52
57
  cleanHistory: () => void
53
58
  history: Syllabus[]
59
+ technologies: TTechnology[]
60
+ setTechnologies: (technologies: TTechnology[]) => void
54
61
  undo: () => void
55
62
  push: (syllabus: Syllabus) => void
56
63
  cleanAll: () => void
@@ -93,6 +100,8 @@ const useStore = create<Store>()(
93
100
  ],
94
101
  },
95
102
  messages: [],
103
+ technologies: [],
104
+ setTechnologies: (technologies: TTechnology[]) => set({ technologies }),
96
105
  setMessages: (messages: TMessage[]) => set({ messages }),
97
106
  setFormState: (formState: Partial<FormState>) =>
98
107
  set((state) => ({ formState: { ...state.formState, ...formState } })),
@@ -145,6 +154,7 @@ const useStore = create<Store>()(
145
154
  uploadedFiles: [],
146
155
  messages: [],
147
156
  history: [],
157
+ technologies: [],
148
158
  formState: {
149
159
  description: "",
150
160
  duration: 0,