Skip to content

Commit dda79e3

Browse files
committed
feat: auto generate images
1 parent 7d6193c commit dda79e3

File tree

7 files changed

+59
-2
lines changed

7 files changed

+59
-2
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you would like to make a donation to support development, please use [GitHub
2020
## Features
2121

2222
- Create unique AI-generated artwork from spoken conversations
23-
- Manual or voice-activated summary generation for on-demand art
23+
- Automatic, manual or voice-activated summary generation for on-demand art
2424
- User-friendly UI, optimized for both desktop and mobile
2525
- Real-time updates and remote control via WebSockets
2626
- Integrated config editor for customization
@@ -181,6 +181,21 @@ image:
181181
order: recent
182182
```
183183

184+
### `autogen`
185+
186+
Images can be automatically generated by creating random summaries. This can be scheduled with a cron expression. Keywords can be passed to help guide the summary.
187+
188+
```yaml
189+
# autogen settings (default: shown below)
190+
191+
autogen:
192+
# schedule as a cron expression for processing transcripts (at every 15th and 45th minute)
193+
cron: '15,45 * * * *'
194+
prompt: Provide a random short description to describe a picture. It should be no more than one or two sentences. If keywords are provided select a couple at random to help guide the description.
195+
# keywords to guide the summary
196+
keywords: []
197+
```
198+
184199
### `transcript`
185200

186201
Images are generated by processing transcripts. This can be scheduled with a cron expression. All of the transcripts within X minutes will then be processed by OpenAI using `openai.summary.prompt` to summarize the transcripts.

api/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const start = async () => {
4747
emitter.setup();
4848
socket.connect(server);
4949
cron.transcript();
50+
cron.autogen();
5051
cron.heartbeat();
5152
});
5253
};

api/src/config/default.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ export default {
22
telemetry: true,
33
logs: { level: 'verbose' },
44
time: { timezone: 'UTC', format: null },
5+
autogen: {
6+
cron: '15,45 * * * *',
7+
prompt:
8+
'Provide a random short description to describe a picture. It should be no more than one or two sentences. If keywords are provided select a couple at random to help guide the description.',
9+
keywords: [],
10+
},
511
image: {
612
interval: 60,
713
order: 'recent',

api/src/schemas/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ const schema = z.object({
5959
}),
6060
image: z.union([
6161
z.object({
62+
autogen: z.object({
63+
enable: z.boolean(),
64+
cron: z.string(),
65+
prompt: z.string(),
66+
keywords: z.array(z.string()),
67+
}),
6268
size: z.enum(['1024x1024', '512x512', '256x256']),
6369
style: z.array(z.string()).min(1),
6470
}),

api/src/util/cron.util.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const { version } = require('../../package.json');
1414
const {
1515
TELEMETRY,
1616
TRANSCRIPT: { CRON, MINUTES, MINIMUM },
17+
AUTOGEN,
1718
} = config();
1819

1920
export default {
@@ -94,5 +95,24 @@ export default {
9495
log.error(error.message);
9596
}
9697
},
98+
autogen: async () => {
99+
const { log } = new Log('autogen');
100+
try {
101+
new CronJob(AUTOGEN.CRON, async () => {
102+
const { autogen } = state.get();
103+
if (!autogen) {
104+
log.verbose('paused');
105+
return;
106+
}
107+
const openai = (await import('../ai/openai')).default;
108+
const summary = await new openai().random({
109+
prompt: AUTOGEN.PROMPT,
110+
context: AUTOGEN.KEYWORDS.join(', '),
111+
});
112+
emitter.emit('summary.create', summary);
113+
}).start();
114+
} catch (error: any) {
115+
log.error(error.message);
116+
}
97117
},
98118
};

api/src/util/state.util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
let STATE: { [name: string]: any } = {
1212
processing: false,
1313
cron: true,
14+
autogen: false,
1415
image: {
1516
index: 0,
1617
summary: true,

frontend/src/views/ControllerView.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const getRandomSummary = async () => {
8787
}
8888
};
8989
90-
const toggle = async (key: 'cron' | 'mic' | 'summary') => {
90+
const toggle = async (key: 'cron' | 'mic' | 'summary' | 'autogen') => {
9191
if (key === 'cron') {
9292
socket.emit('state:patch', { cron: state.value.cron });
9393
toast.add({
@@ -115,6 +115,14 @@ const toggle = async (key: 'cron' | 'mic' | 'summary') => {
115115
life: 3000,
116116
});
117117
}
118+
if (key === 'autogen') {
119+
socket.emit('state:patch', { to: 'controller', autogen: state.value.autogen });
120+
toast.add({
121+
severity: 'info',
122+
detail: `Autogen Processing ${state.value.autogen ? 'Enabled' : 'Disabled'}`,
123+
life: 3000,
124+
});
125+
}
118126
};
119127
120128
const imageControl = (task: 'prev' | 'next' | 'toggle') => {

0 commit comments

Comments
 (0)