diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/formattedText/DailyJournal.tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/client/views/nodes/formattedText/DailyJournal.tsx b/src/client/views/nodes/formattedText/DailyJournal.tsx index f308d45a8..26a86bc6e 100644 --- a/src/client/views/nodes/formattedText/DailyJournal.tsx +++ b/src/client/views/nodes/formattedText/DailyJournal.tsx @@ -103,7 +103,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() * Inserts predictive text at the end of what the user is typing */ - @action insertPredictiveQuestion = () => { + @action insertPredictiveQuestion = async () => { const editorView = this._ref.current?.EditorView; if (!editorView) return; @@ -133,8 +133,15 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() const fontColorMark = schema.marks.pFontColor.create({ fontColor: 'lightgray' }); const fontItalicsMark = schema.marks.em.create(); + this.predictiveText = ' ...'; // placeholder for now + + const fullTextUpToCursor = state.doc.textBetween(0, state.selection.to, '\n', '\n'); + const gptPrompt = `Given the following incomplete journal entry, generate a single 2-5 word question that continues the user's thought:\n\n"${fullTextUpToCursor}"`; + const res = await gptAPICall(gptPrompt, GPTCallType.COMPLETION); + if (!res) return; + // styled text node - const text = ' ... why?'; + const text = ` ... ${res.trim()}`; const predictedText = schema.text(text, [fontSizeMark, fontColorMark, fontItalicsMark]); // Insert styled text at cursor position |