OpenAI integration and Note generation from prompt

This commit is contained in:
Michael Dausmann
2023-04-29 00:00:52 +10:00
parent d00d048b72
commit 3e3c5e57d7
11 changed files with 171 additions and 19 deletions

View File

@@ -2,10 +2,6 @@ import { Note } from ".prisma/client"
import { defineStore, storeToRefs } from "pinia"
import { Ref } from "vue";
interface State {
notes: Note[]
}
/*
Note) the Notes Store needs to be a 'Setup Store' (https://pinia.vuejs.org/core-concepts/#setup-stores)
because this enables the use of the watch on the Account Store
@@ -42,10 +38,16 @@ export const useNotesStore = defineStore('notes', () => {
}
}
async function generateAINoteFromPrompt(user_prompt: string) {
const { $client } = useNuxtApp();
const { noteText } = await $client.notes.generateAINoteFromPrompt.query({user_prompt});
return noteText?noteText:'';
}
// if the active account changes, fetch notes again (i.e dynamic.. probabl overkill)
watch(activeAccountId, async (val, oldVal)=> {
await fetchNotesForCurrentUser()
});
return { notes: _notes, fetchNotesForCurrentUser, createNote, deleteNote }
return { notes: _notes, fetchNotesForCurrentUser, createNote, deleteNote, generateAINoteFromPrompt}
});