aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraaravkumar <aarav.kumar1510@gmail.com>2025-04-04 21:43:40 -0400
committeraaravkumar <aarav.kumar1510@gmail.com>2025-04-04 21:43:40 -0400
commitb6823909532bdc727a51b8bda266cf62dd5dff6d (patch)
tree85a8703abe92d0732e3c008b7426e197004da4ac /src
parentf99bf9889fb1c84f211312f478df6046bf1b6b6e (diff)
predictive question replaced from mock text to GPT (actual prediction)
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/formattedText/DailyJournal.tsx11
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