aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/GPTPopup/GPTPopup.tsx34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
index 4028ef479..c33b81eb4 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
@@ -188,8 +188,8 @@ export class GPTPopup extends ObservableReactComponent<object> {
const selected = DocumentView.SelectedDocs().lastElement();
- const questionText = 'Question: ' + StrCast(selected['gptInputText']);
- const rubricText = 'Rubric: ' + StrCast(selected['gptRubric']);
+ const questionText = 'Question: ' + StrCast(selected.gptInputText);
+ const rubricText = 'Rubric: ' + StrCast(selected.gptRubric);
const queryText = questionText + ' UserAnswer: ' + this.quizAnswer + '. ' + 'Rubric' + rubricText;
try {
@@ -262,27 +262,15 @@ export class GPTPopup extends ObservableReactComponent<object> {
try {
const questionType = await gptAPICall(this.chatSortPrompt, GPTCallType.TYPE);
- const questionNumber = questionType.split(' ')[0];
- let res = '';
-
- switch (questionNumber) {
- case '1':
- case '2':
- case '4':
- res = await gptAPICall(this.sortDesc, GPTCallType.SUBSET, this.chatSortPrompt);
- break;
- case '6':
- res = await gptAPICall(this.sortDesc, GPTCallType.SORT, this.chatSortPrompt);
- break;
- default:
- {
- const selected = DocumentView.SelectedDocs().lastElement();
- const questionText = StrCast(selected?.gptInputText);
-
- res = await gptAPICall(questionText, GPTCallType.INFO, this.chatSortPrompt);
- }
- break;
- }
+ const questionNumber = questionType.split(' ')[0][0];
+ const res = await (() => {
+ switch (questionNumber) {
+ case '1':
+ case '2':
+ case '4': return gptAPICall(this.sortDesc, GPTCallType.SUBSET, this.chatSortPrompt);
+ case '6': return gptAPICall(this.sortDesc, GPTCallType.SORT, this.chatSortPrompt);
+ default: return gptAPICall(StrCast(DocumentView.SelectedDocs().lastElement()?.gptInputText), GPTCallType.INFO, this.chatSortPrompt);
+ }})(); // prettier-ignore
// Trigger the callback with the result
if (this.onSortComplete) {