Skip to content

Commit

Permalink
feat: pass optional context for random summary generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Jun 22, 2023
1 parent 5c569f4 commit bb7899f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/src/controllers/summary.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ router.get('/random', async (req, res) => {
return res.status(BAD_REQUEST).send({ error: 'Open AI not configured' });

const openai = (await import('../ai/openai')).default;
const summary = await new openai().random();
const summary = await new openai().random({ context: req.query?.summary?.toString() });
res.send(summary);
});

Expand Down
24 changes: 21 additions & 3 deletions frontend/src/views/ControllerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ const transcripts = reactive<{
count: number | null;
all: { id: number }[];
summary: string;
lastSummary: string;
selected: number[];
}>({
count: null,
all: [],
summary: '',
lastSummary: '',
selected: [],
});
const iosAddressBarHeight = ref(0);
Expand All @@ -64,6 +66,7 @@ const processManualSummary = async () => {
emitter.emit('error', error);
}
transcripts.summary = '';
transcripts.lastSummary = '';
};
const getState = async () => {
Expand All @@ -78,8 +81,13 @@ const getState = async () => {
const getRandomSummary = async () => {
try {
loadingRandom.value = true;
const { data } = await ApiService.get('summary/random');
const summary = transcripts.summary !== transcripts.lastSummary ? transcripts.summary : null;
transcripts.summary = '';
const { data } = await ApiService.get('summary/random', {
summary,
});
transcripts.summary = data;
transcripts.lastSummary = data;
loadingRandom.value = false;
} catch (error) {
loadingRandom.value = false;
Expand Down Expand Up @@ -436,17 +444,27 @@ watch(
v-model="transcripts.summary"
class="w-full h-full"
style="resize: none; padding-right: 100px"
:disabled="loadingRandom"
/>
<div class="action-buttons">
<Button
v-tooltip.left="'Generate Random AI Summary'"
v-tooltip.left="
transcripts.summary && transcripts.summary !== transcripts.lastSummary
? 'Generate Random AI Summary About: ' + transcripts.summary
: 'Generate Random AI Summary'
"
:icon="loadingRandom ? 'pi pi-spinner pi-spin' : 'fa-solid fa-shuffle'"
size="small"
class="mr-2"
@click="getRandomSummary"
:disabled="loadingRandom"
/>
<Button icon="pi pi-check" size="small" @click="processManualSummary" :disabled="!transcripts.summary" />
<Button
icon="pi pi-check"
size="small"
@click="processManualSummary"
:disabled="!transcripts.summary || loadingRandom"
/>
</div>
</div>
</div>
Expand Down

0 comments on commit bb7899f

Please sign in to comment.