@speakableio/core 1.0.12 → 1.0.14
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/dist/index.native.d.mts +26 -6
- package/dist/index.native.d.ts +26 -6
- package/dist/index.native.js +96 -16
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +96 -16
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.d.mts +26 -6
- package/dist/index.web.js +96 -16
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.d.mts
CHANGED
|
@@ -772,6 +772,11 @@ interface PageScore {
|
|
|
772
772
|
hint?: string[];
|
|
773
773
|
reviewed?: boolean;
|
|
774
774
|
error?: ('feedback_error' | 'transcript_error' | 'summary_error' | 'audio_upload_error' | 'unknown' | null)[];
|
|
775
|
+
stagedResponse?: {
|
|
776
|
+
audio?: string | null;
|
|
777
|
+
fileName?: string | null;
|
|
778
|
+
transcript?: string | null;
|
|
779
|
+
} | null;
|
|
775
780
|
}
|
|
776
781
|
|
|
777
782
|
declare enum AssignmentAnalyticsType {
|
|
@@ -993,7 +998,9 @@ declare function useUpdateCardScore({ isAssignment, activityId, userId, cardIds,
|
|
|
993
998
|
}, Error, {
|
|
994
999
|
cardId: string;
|
|
995
1000
|
cardScore: PageScore;
|
|
996
|
-
},
|
|
1001
|
+
}, {
|
|
1002
|
+
previousData: Score | undefined;
|
|
1003
|
+
}>;
|
|
997
1004
|
};
|
|
998
1005
|
declare function useClearScore(): {
|
|
999
1006
|
mutationClearScore: _tanstack_react_query.UseMutationResult<{
|
|
@@ -1007,6 +1014,18 @@ declare function useClearScore(): {
|
|
|
1007
1014
|
activityId: string;
|
|
1008
1015
|
}, unknown>;
|
|
1009
1016
|
};
|
|
1017
|
+
declare function useClearScoreV2(): {
|
|
1018
|
+
mutationClearScore: _tanstack_react_query.UseMutationResult<{
|
|
1019
|
+
update: Partial<Score>;
|
|
1020
|
+
activityId: string;
|
|
1021
|
+
}, Error, {
|
|
1022
|
+
isAssignment: boolean;
|
|
1023
|
+
cardId: string;
|
|
1024
|
+
cardScores: PageScore;
|
|
1025
|
+
userId: string;
|
|
1026
|
+
activityId: string;
|
|
1027
|
+
}, unknown>;
|
|
1028
|
+
};
|
|
1010
1029
|
declare function useSubmitAssignmentScore({ onAssignmentSubmitted, studentName, }: {
|
|
1011
1030
|
onAssignmentSubmitted: (assignmentId: string) => void;
|
|
1012
1031
|
studentName: string;
|
|
@@ -2760,7 +2779,7 @@ declare const useBaseOpenAI: ({ onTranscriptSuccess, onTranscriptError, onComple
|
|
|
2760
2779
|
url: string;
|
|
2761
2780
|
fileName: string;
|
|
2762
2781
|
}>;
|
|
2763
|
-
uploadAudioAndGetTranscript: (audio: string, language: string) => Promise<{
|
|
2782
|
+
uploadAudioAndGetTranscript: (audio: string, language: string, pagePrompt: string | null) => Promise<{
|
|
2764
2783
|
transcript: string;
|
|
2765
2784
|
audioUrl: string;
|
|
2766
2785
|
}>;
|
|
@@ -2773,19 +2792,20 @@ declare const useBaseOpenAI: ({ onTranscriptSuccess, onTranscriptError, onComple
|
|
|
2773
2792
|
url: string;
|
|
2774
2793
|
fileName: string;
|
|
2775
2794
|
}>;
|
|
2776
|
-
uploadAudioAndGetTranscript: (audio: string, language: string) => Promise<{
|
|
2795
|
+
uploadAudioAndGetTranscript: (audio: string, language: string, pagePrompt: string | null) => Promise<{
|
|
2777
2796
|
transcript: string;
|
|
2778
2797
|
audioUrl: string;
|
|
2779
2798
|
}>;
|
|
2780
|
-
getTranscript: (audioUrl: string, language: string) => Promise<
|
|
2799
|
+
getTranscript: (audioUrl: string, language: string, prompt?: string) => Promise<any>;
|
|
2781
2800
|
getFreeResponseCompletion: (messages: string[], isFreeResponse: boolean, feedbackLanguage: string, gradingStandard?: string) => Promise<any>;
|
|
2782
|
-
getFeedback: ({ cardId, language, writtenResponse, audio, autoGrade, file, }: {
|
|
2801
|
+
getFeedback: ({ cardId, language, writtenResponse, audio, autoGrade, file, pagePrompt, }: {
|
|
2783
2802
|
cardId: string;
|
|
2784
2803
|
language: string;
|
|
2785
2804
|
writtenResponse: string | null;
|
|
2786
2805
|
audio: string | null;
|
|
2787
2806
|
autoGrade: boolean;
|
|
2788
2807
|
file: string | null;
|
|
2808
|
+
pagePrompt: string | null;
|
|
2789
2809
|
}) => Promise<{
|
|
2790
2810
|
noFeedbackAvailable: boolean;
|
|
2791
2811
|
success: boolean;
|
|
@@ -3242,4 +3262,4 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent }: FsClientPa
|
|
|
3242
3262
|
};
|
|
3243
3263
|
};
|
|
3244
3264
|
|
|
3245
|
-
export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientNative as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
|
|
3265
|
+
export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientNative as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useClearScoreV2, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
|
package/dist/index.native.d.ts
CHANGED
|
@@ -772,6 +772,11 @@ interface PageScore {
|
|
|
772
772
|
hint?: string[];
|
|
773
773
|
reviewed?: boolean;
|
|
774
774
|
error?: ('feedback_error' | 'transcript_error' | 'summary_error' | 'audio_upload_error' | 'unknown' | null)[];
|
|
775
|
+
stagedResponse?: {
|
|
776
|
+
audio?: string | null;
|
|
777
|
+
fileName?: string | null;
|
|
778
|
+
transcript?: string | null;
|
|
779
|
+
} | null;
|
|
775
780
|
}
|
|
776
781
|
|
|
777
782
|
declare enum AssignmentAnalyticsType {
|
|
@@ -993,7 +998,9 @@ declare function useUpdateCardScore({ isAssignment, activityId, userId, cardIds,
|
|
|
993
998
|
}, Error, {
|
|
994
999
|
cardId: string;
|
|
995
1000
|
cardScore: PageScore;
|
|
996
|
-
},
|
|
1001
|
+
}, {
|
|
1002
|
+
previousData: Score | undefined;
|
|
1003
|
+
}>;
|
|
997
1004
|
};
|
|
998
1005
|
declare function useClearScore(): {
|
|
999
1006
|
mutationClearScore: _tanstack_react_query.UseMutationResult<{
|
|
@@ -1007,6 +1014,18 @@ declare function useClearScore(): {
|
|
|
1007
1014
|
activityId: string;
|
|
1008
1015
|
}, unknown>;
|
|
1009
1016
|
};
|
|
1017
|
+
declare function useClearScoreV2(): {
|
|
1018
|
+
mutationClearScore: _tanstack_react_query.UseMutationResult<{
|
|
1019
|
+
update: Partial<Score>;
|
|
1020
|
+
activityId: string;
|
|
1021
|
+
}, Error, {
|
|
1022
|
+
isAssignment: boolean;
|
|
1023
|
+
cardId: string;
|
|
1024
|
+
cardScores: PageScore;
|
|
1025
|
+
userId: string;
|
|
1026
|
+
activityId: string;
|
|
1027
|
+
}, unknown>;
|
|
1028
|
+
};
|
|
1010
1029
|
declare function useSubmitAssignmentScore({ onAssignmentSubmitted, studentName, }: {
|
|
1011
1030
|
onAssignmentSubmitted: (assignmentId: string) => void;
|
|
1012
1031
|
studentName: string;
|
|
@@ -2760,7 +2779,7 @@ declare const useBaseOpenAI: ({ onTranscriptSuccess, onTranscriptError, onComple
|
|
|
2760
2779
|
url: string;
|
|
2761
2780
|
fileName: string;
|
|
2762
2781
|
}>;
|
|
2763
|
-
uploadAudioAndGetTranscript: (audio: string, language: string) => Promise<{
|
|
2782
|
+
uploadAudioAndGetTranscript: (audio: string, language: string, pagePrompt: string | null) => Promise<{
|
|
2764
2783
|
transcript: string;
|
|
2765
2784
|
audioUrl: string;
|
|
2766
2785
|
}>;
|
|
@@ -2773,19 +2792,20 @@ declare const useBaseOpenAI: ({ onTranscriptSuccess, onTranscriptError, onComple
|
|
|
2773
2792
|
url: string;
|
|
2774
2793
|
fileName: string;
|
|
2775
2794
|
}>;
|
|
2776
|
-
uploadAudioAndGetTranscript: (audio: string, language: string) => Promise<{
|
|
2795
|
+
uploadAudioAndGetTranscript: (audio: string, language: string, pagePrompt: string | null) => Promise<{
|
|
2777
2796
|
transcript: string;
|
|
2778
2797
|
audioUrl: string;
|
|
2779
2798
|
}>;
|
|
2780
|
-
getTranscript: (audioUrl: string, language: string) => Promise<
|
|
2799
|
+
getTranscript: (audioUrl: string, language: string, prompt?: string) => Promise<any>;
|
|
2781
2800
|
getFreeResponseCompletion: (messages: string[], isFreeResponse: boolean, feedbackLanguage: string, gradingStandard?: string) => Promise<any>;
|
|
2782
|
-
getFeedback: ({ cardId, language, writtenResponse, audio, autoGrade, file, }: {
|
|
2801
|
+
getFeedback: ({ cardId, language, writtenResponse, audio, autoGrade, file, pagePrompt, }: {
|
|
2783
2802
|
cardId: string;
|
|
2784
2803
|
language: string;
|
|
2785
2804
|
writtenResponse: string | null;
|
|
2786
2805
|
audio: string | null;
|
|
2787
2806
|
autoGrade: boolean;
|
|
2788
2807
|
file: string | null;
|
|
2808
|
+
pagePrompt: string | null;
|
|
2789
2809
|
}) => Promise<{
|
|
2790
2810
|
noFeedbackAvailable: boolean;
|
|
2791
2811
|
success: boolean;
|
|
@@ -3242,4 +3262,4 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent }: FsClientPa
|
|
|
3242
3262
|
};
|
|
3243
3263
|
};
|
|
3244
3264
|
|
|
3245
|
-
export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientNative as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
|
|
3265
|
+
export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientNative as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useClearScoreV2, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
|
package/dist/index.native.js
CHANGED
|
@@ -86,6 +86,7 @@ __export(index_native_exports, {
|
|
|
86
86
|
useBaseOpenAI: () => useBaseOpenAI,
|
|
87
87
|
useCards: () => useCards,
|
|
88
88
|
useClearScore: () => useClearScore,
|
|
89
|
+
useClearScoreV2: () => useClearScoreV2,
|
|
89
90
|
useCreateCard: () => useCreateCard,
|
|
90
91
|
useCreateCards: () => useCreateCards,
|
|
91
92
|
useCreateNotification: () => useCreateNotification,
|
|
@@ -152,6 +153,8 @@ function withErrorHandler(fn, serviceName) {
|
|
|
152
153
|
try {
|
|
153
154
|
return await fn(...args);
|
|
154
155
|
} catch (error) {
|
|
156
|
+
console.error(`Service ${serviceName} failed with args:`, args);
|
|
157
|
+
console.error("Error details:", error);
|
|
155
158
|
if (error instanceof Error && "code" in error) {
|
|
156
159
|
const firebaseError = error;
|
|
157
160
|
throw new ServiceError(
|
|
@@ -1248,6 +1251,39 @@ async function clearScore(params) {
|
|
|
1248
1251
|
activityId: params.activityId
|
|
1249
1252
|
};
|
|
1250
1253
|
}
|
|
1254
|
+
async function clearScoreV2(params) {
|
|
1255
|
+
var _a, _b, _c, _d, _e;
|
|
1256
|
+
const update = {
|
|
1257
|
+
[`cards.${params.cardId}`]: {
|
|
1258
|
+
...params.cardScores,
|
|
1259
|
+
attempts: ((_a = params.cardScores.attempts) != null ? _a : 1) + 1,
|
|
1260
|
+
correct: (_b = params.cardScores.correct) != null ? _b : 0,
|
|
1261
|
+
history: [
|
|
1262
|
+
{
|
|
1263
|
+
...params.cardScores,
|
|
1264
|
+
attempts: (_c = params.cardScores.attempts) != null ? _c : 1,
|
|
1265
|
+
correct: (_d = params.cardScores.correct) != null ? _d : 0,
|
|
1266
|
+
retryTime: (0, import_dayjs3.default)().format("YYYY-MM-DD HH:mm:ss"),
|
|
1267
|
+
history: null
|
|
1268
|
+
},
|
|
1269
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1270
|
+
...(_e = params.cardScores.history) != null ? _e : []
|
|
1271
|
+
]
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
const path = params.isAssignment ? refsAssignmentFiresotre.assignmentScores({
|
|
1275
|
+
id: params.activityId,
|
|
1276
|
+
userId: params.userId
|
|
1277
|
+
}) : refsScoresPractice.practiceScores({
|
|
1278
|
+
setId: params.activityId,
|
|
1279
|
+
userId: params.userId
|
|
1280
|
+
});
|
|
1281
|
+
await api.updateDoc(path, update);
|
|
1282
|
+
return {
|
|
1283
|
+
update,
|
|
1284
|
+
activityId: params.activityId
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1251
1287
|
|
|
1252
1288
|
// src/domains/assignment/services/submit-assignment-score.service.ts
|
|
1253
1289
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
@@ -1360,7 +1396,7 @@ function useScore({
|
|
|
1360
1396
|
enabled
|
|
1361
1397
|
});
|
|
1362
1398
|
}
|
|
1363
|
-
var debounceUpdateScore = debounce(updateScore,
|
|
1399
|
+
var debounceUpdateScore = debounce(updateScore, 500);
|
|
1364
1400
|
function useUpdateScore() {
|
|
1365
1401
|
const { queryClient } = useSpeakableApi();
|
|
1366
1402
|
const mutation = (0, import_react_query2.useMutation)({
|
|
@@ -1419,6 +1455,7 @@ function useUpdateCardScore({
|
|
|
1419
1455
|
return { cardId, scoresUpdated: newScoreUpdated };
|
|
1420
1456
|
},
|
|
1421
1457
|
onMutate: ({ cardId, cardScore }) => {
|
|
1458
|
+
const previousData = queryClient.getQueryData(queryKey);
|
|
1422
1459
|
queryClient.setQueryData(queryKey, (previousScore) => {
|
|
1423
1460
|
const updates = handleOptimisticScore({
|
|
1424
1461
|
score: previousScore,
|
|
@@ -1432,14 +1469,18 @@ function useUpdateCardScore({
|
|
|
1432
1469
|
...updates
|
|
1433
1470
|
};
|
|
1434
1471
|
});
|
|
1472
|
+
return { previousData };
|
|
1435
1473
|
},
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
if (previousData) {
|
|
1441
|
-
queryClient.setQueryData(queryKey, previousData);
|
|
1474
|
+
onError: (error, variables, context) => {
|
|
1475
|
+
console.log("Error updating card score:", error.message);
|
|
1476
|
+
if (context == null ? void 0 : context.previousData) {
|
|
1477
|
+
queryClient.setQueryData(queryKey, context.previousData);
|
|
1442
1478
|
}
|
|
1479
|
+
},
|
|
1480
|
+
onSettled: () => {
|
|
1481
|
+
queryClient.invalidateQueries({
|
|
1482
|
+
queryKey
|
|
1483
|
+
});
|
|
1443
1484
|
}
|
|
1444
1485
|
});
|
|
1445
1486
|
return {
|
|
@@ -1505,6 +1546,27 @@ function useClearScore() {
|
|
|
1505
1546
|
const { queryClient } = useSpeakableApi();
|
|
1506
1547
|
const mutation = (0, import_react_query2.useMutation)({
|
|
1507
1548
|
mutationFn: clearScore,
|
|
1549
|
+
onError: (error) => {
|
|
1550
|
+
console.log("Error clearing score:", error.message);
|
|
1551
|
+
},
|
|
1552
|
+
onSettled: (result) => {
|
|
1553
|
+
var _a;
|
|
1554
|
+
queryClient.invalidateQueries({
|
|
1555
|
+
queryKey: scoreQueryKeys.byId((_a = result == null ? void 0 : result.activityId) != null ? _a : "")
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
return {
|
|
1560
|
+
mutationClearScore: mutation
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
function useClearScoreV2() {
|
|
1564
|
+
const { queryClient } = useSpeakableApi();
|
|
1565
|
+
const mutation = (0, import_react_query2.useMutation)({
|
|
1566
|
+
mutationFn: clearScoreV2,
|
|
1567
|
+
onError: (error) => {
|
|
1568
|
+
console.log("Error clearing score V2:", error.message);
|
|
1569
|
+
},
|
|
1508
1570
|
onSettled: (result) => {
|
|
1509
1571
|
var _a;
|
|
1510
1572
|
queryClient.invalidateQueries({
|
|
@@ -3097,21 +3159,38 @@ var useBaseOpenAI = ({
|
|
|
3097
3159
|
const { data: feedbackAccess } = useActivityFeedbackAccess({
|
|
3098
3160
|
aiEnabled
|
|
3099
3161
|
});
|
|
3100
|
-
const getTranscript = async (audioUrl, language) => {
|
|
3101
|
-
var _a, _b;
|
|
3162
|
+
const getTranscript = async (audioUrl, language, prompt) => {
|
|
3163
|
+
var _a, _b, _c, _d;
|
|
3164
|
+
const getGeminiTranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "getGeminiTranscript");
|
|
3165
|
+
const getAssemblyAITranscript = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "transcribeAssemblyAIAudio");
|
|
3166
|
+
try {
|
|
3167
|
+
const { data } = await (getGeminiTranscript == null ? void 0 : getGeminiTranscript({
|
|
3168
|
+
audioUrl,
|
|
3169
|
+
targetLanguage: language,
|
|
3170
|
+
prompt: prompt || ""
|
|
3171
|
+
}));
|
|
3172
|
+
const transcript = data.transcript;
|
|
3173
|
+
if (transcript) {
|
|
3174
|
+
return transcript;
|
|
3175
|
+
}
|
|
3176
|
+
} catch (error) {
|
|
3177
|
+
console.log("Gemini transcript failed, trying AssemblyAI fallback:", error);
|
|
3178
|
+
}
|
|
3102
3179
|
try {
|
|
3103
|
-
const getAssemblyAITranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "transcribeAssemblyAIAudio");
|
|
3104
3180
|
const response = await (getAssemblyAITranscript == null ? void 0 : getAssemblyAITranscript({
|
|
3105
3181
|
audioUrl,
|
|
3106
3182
|
language
|
|
3107
3183
|
}));
|
|
3108
3184
|
const transcript = response == null ? void 0 : response.data;
|
|
3109
|
-
|
|
3185
|
+
if (transcript) {
|
|
3186
|
+
return transcript;
|
|
3187
|
+
}
|
|
3188
|
+
throw new Error("Both transcript services failed");
|
|
3110
3189
|
} catch (error) {
|
|
3111
|
-
console.log("
|
|
3190
|
+
console.log("AssemblyAI transcript also failed:", error);
|
|
3112
3191
|
onTranscriptError({
|
|
3113
3192
|
type: "TRANSCRIPT",
|
|
3114
|
-
message: (error == null ? void 0 : error.message) || "Error getting transcript"
|
|
3193
|
+
message: (error == null ? void 0 : error.message) || "Error getting transcript from both services"
|
|
3115
3194
|
});
|
|
3116
3195
|
throw new Error(error);
|
|
3117
3196
|
}
|
|
@@ -3166,7 +3245,8 @@ var useBaseOpenAI = ({
|
|
|
3166
3245
|
// if the type = RESPOND_WRITE
|
|
3167
3246
|
audio = null,
|
|
3168
3247
|
autoGrade = true,
|
|
3169
|
-
file = null
|
|
3248
|
+
file = null,
|
|
3249
|
+
pagePrompt = null
|
|
3170
3250
|
}) => {
|
|
3171
3251
|
try {
|
|
3172
3252
|
if (!(feedbackAccess == null ? void 0 : feedbackAccess.canAccessFeedback)) {
|
|
@@ -3186,7 +3266,7 @@ var useBaseOpenAI = ({
|
|
|
3186
3266
|
onTranscriptSuccess(writtenResponse);
|
|
3187
3267
|
} else if (typeof audio === "string" && file) {
|
|
3188
3268
|
if (feedbackAccess == null ? void 0 : feedbackAccess.canAccessFeedback) {
|
|
3189
|
-
transcript = await getTranscript(audio, language);
|
|
3269
|
+
transcript = await getTranscript(audio, language, pagePrompt != null ? pagePrompt : "");
|
|
3190
3270
|
audioUrl = audio;
|
|
3191
3271
|
onTranscriptSuccess(transcript);
|
|
3192
3272
|
} else {
|
|
@@ -3195,7 +3275,7 @@ var useBaseOpenAI = ({
|
|
|
3195
3275
|
);
|
|
3196
3276
|
}
|
|
3197
3277
|
} else {
|
|
3198
|
-
const response = await uploadAudioAndGetTranscript(audio || "", language);
|
|
3278
|
+
const response = await uploadAudioAndGetTranscript(audio || "", language, pagePrompt != null ? pagePrompt : "");
|
|
3199
3279
|
transcript = response.transcript;
|
|
3200
3280
|
audioUrl = response.audioUrl;
|
|
3201
3281
|
}
|