Skip to content

Commit dfe4105

Browse files
authored
Merge pull request #119 from ajcwebdev/form
Refactor Astro Frontend
2 parents 5ad558b + 0a36ec5 commit dfe4105

31 files changed

+657
-5222
lines changed

docs/server.md

Lines changed: 4 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -49,49 +49,13 @@ curl --json '{
4949
}' http://localhost:3000/process
5050
```
5151

52-
### Playlist Type
53-
54-
```bash
55-
curl --json '{
56-
"type": "playlist",
57-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr"
58-
}' http://localhost:3000/process
59-
```
60-
61-
```bash
62-
curl --json '{
63-
"type": "playlist",
64-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
65-
"whisperModel": "tiny",
66-
"llm": "ollama"
67-
}' http://localhost:3000/process
68-
```
69-
70-
### URLs Type
71-
7252
```bash
7353
curl --json '{
74-
"type": "urls",
75-
"filePath": "content/example-urls.md"
76-
}' http://localhost:3000/process
77-
```
78-
79-
```bash
80-
curl --json '{
81-
"type": "urls",
82-
"filePath": "content/example-urls.md",
83-
"whisperModel": "tiny",
84-
"llm": "ollama"
85-
}' http://localhost:3000/process
86-
```
87-
88-
```bash
89-
curl --json '{
90-
"type": "urls",
91-
"filePath": "content/example-urls.md",
92-
"prompts": ["titles", "mediumChapters"],
54+
"type": "video",
55+
"url": "https://www.youtube.com/watch?v=MORMZXEaONk",
9356
"whisperModel": "tiny",
94-
"llm": "ollama"
57+
"llm": "ollama",
58+
"llmModel": "DEEPSEEK_R1_1_5B"
9559
}' http://localhost:3000/process
9660
```
9761

@@ -123,46 +87,6 @@ curl --json '{
12387
}' http://localhost:3000/process
12488
```
12589

126-
### RSS Type
127-
128-
```bash
129-
curl --json '{
130-
"type": "rss",
131-
"url": "https://feeds.transistor.fm/fsjam-podcast/"
132-
}' http://localhost:3000/process
133-
```
134-
135-
```bash
136-
curl --json '{
137-
"type": "rss",
138-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
139-
"whisperModel": "tiny",
140-
"llm": "ollama",
141-
"order": "newest",
142-
"skip": 0
143-
}' http://localhost:3000/process
144-
```
145-
146-
```bash
147-
curl --json '{
148-
"type": "rss",
149-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
150-
"order": "newest",
151-
"skip": 94,
152-
"whisperModel": "tiny"
153-
}' http://localhost:3000/process
154-
```
155-
156-
```bash
157-
curl --json '{
158-
"type": "rss",
159-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
160-
"order": "oldest",
161-
"skip": 94,
162-
"whisperModel": "tiny"
163-
}' http://localhost:3000/process
164-
```
165-
16690
## Language Model (LLM) Options
16791

16892
### ChatGPT
@@ -357,81 +281,9 @@ curl --json '{
357281
}' http://localhost:3000/process
358282
```
359283

360-
```bash
361-
curl --json '{
362-
"type": "playlist",
363-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
364-
"prompts": ["titles", "mediumChapters"],
365-
"whisperModel": "tiny",
366-
"llm": "ollama"
367-
}' http://localhost:3000/process
368-
```
369-
370-
```bash
371-
curl --json '{
372-
"type": "playlist",
373-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
374-
"prompts": ["titles", "mediumChapters"],
375-
"whisperModel": "tiny",
376-
"llm": "ollama"
377-
}' http://localhost:3000/process
378-
```
379-
380284
## Test Requests
381285

382286
```js
383-
const TEST_REQ_01 = {
384-
"type": "playlist",
385-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr"
386-
}
387-
388-
const TEST_REQ_02 = {
389-
"type": "playlist",
390-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
391-
"whisperModel": "tiny"
392-
}
393-
394-
const TEST_REQ_03 = {
395-
"type": "playlist",
396-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
397-
"whisperModel": "tiny",
398-
"llm": "ollama"
399-
}
400-
401-
const TEST_REQ_04 = {
402-
"type": "playlist",
403-
"url": "https://www.youtube.com/playlist?list=PLCVnrVv4KhXPz0SoAVu8Rc1emAdGPbSbr",
404-
"prompts": ["titles", "mediumChapters"],
405-
"whisperModel": "tiny",
406-
"llm": "ollama"
407-
}
408-
409-
const TEST_REQ_05 = {
410-
"type": "urls",
411-
"filePath": "content/example-urls.md"
412-
}
413-
414-
const TEST_REQ_06 = {
415-
"type": "urls",
416-
"filePath": "content/example-urls.md",
417-
"whisperModel": "tiny"
418-
}
419-
420-
const TEST_REQ_07 = {
421-
"type": "urls",
422-
"filePath": "content/example-urls.md",
423-
"whisperModel": "tiny",
424-
"llm": "ollama"
425-
}
426-
427-
const TEST_REQ_08 = {
428-
"type": "urls",
429-
"filePath": "content/example-urls.md",
430-
"prompts": ["titles", "mediumChapters"],
431-
"whisperModel": "tiny",
432-
"llm": "ollama"
433-
}
434-
435287
const TEST_REQ_09 = {
436288
"type": "file",
437289
"filePath": "content/audio.mp3"
@@ -458,40 +310,6 @@ const TEST_REQ_12 = {
458310
"llm": "ollama"
459311
}
460312

461-
const TEST_REQ_13 = {
462-
"type": "rss",
463-
"url": "https://feeds.transistor.fm/fsjam-podcast/"
464-
}
465-
466-
const TEST_REQ_14 = {
467-
"type": "rss",
468-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
469-
"whisperModel": "tiny"
470-
}
471-
472-
const TEST_REQ_15 = {
473-
"type": "rss",
474-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
475-
"whisperModel": "tiny",
476-
"llm": "ollama"
477-
}
478-
479-
const TEST_REQ_16 = {
480-
"type": "rss",
481-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
482-
"whisperModel": "tiny",
483-
"order": "newest",
484-
"skip": 94
485-
}
486-
487-
const TEST_REQ_17 = {
488-
"type": "rss",
489-
"url": "https://feeds.transistor.fm/fsjam-podcast/",
490-
"whisperModel": "tiny",
491-
"order": "oldest",
492-
"skip": 94
493-
}
494-
495313
const TEST_REQ_18 = {
496314
"url": "https://www.youtube.com/watch?v=MORMZXEaONk"
497315
}

src/server/routes/process.ts

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// src/server/routes/process.ts
22

33
import { processVideo } from '../../process-commands/video'
4-
import { processURLs } from '../../process-commands/urls'
5-
import { processRSS } from '../../process-commands/rss'
6-
import { processPlaylist } from '../../process-commands/playlist'
7-
import { processChannel } from '../../process-commands/channel'
84
import { processFile } from '../../process-commands/file'
95
import { validateRequest, validateServerProcessAction } from '../utils/validation'
106
import { l, err } from '../../../src/utils/logging'
@@ -44,6 +40,11 @@ export const handleProcessRequest = async (
4440
// Map request data to processing options
4541
const { options, llmServices, transcriptServices } = validateRequest(requestData)
4642

43+
// Ensure the user-selected LLM model is passed through to the options object
44+
if (llmServices && requestData['llmModel']) {
45+
options[llmServices] = requestData['llmModel']
46+
}
47+
4748
// Process based on type
4849
switch (type) {
4950
case 'video': {
@@ -53,11 +54,7 @@ export const handleProcessRequest = async (
5354
return
5455
}
5556
options.video = url
56-
57-
// Grab the object that includes frontMatter, prompt, llmOutput, and transcript
5857
const result = await processVideo(options, url, llmServices, transcriptServices)
59-
60-
// Return the object, if there is no LLM output, it will be ''
6158
reply.send({
6259
frontMatter: result.frontMatter,
6360
prompt: result.prompt,
@@ -67,63 +64,20 @@ export const handleProcessRequest = async (
6764
break
6865
}
6966

70-
case 'channel': {
71-
const { url } = requestData
72-
if (!url) {
73-
reply.status(400).send({ error: 'Channel URL is required' })
74-
return
75-
}
76-
options.channel = url
77-
const content = await processChannel(options, url, llmServices, transcriptServices)
78-
reply.send({ content })
79-
break
80-
}
81-
82-
case 'urls': {
83-
const { filePath } = requestData
84-
if (!filePath) {
85-
reply.status(400).send({ error: 'File path is required' })
86-
return
87-
}
88-
options.urls = filePath
89-
await processURLs(options, filePath, llmServices, transcriptServices)
90-
reply.send({ message: 'URLs processed successfully.' })
91-
break
92-
}
93-
94-
case 'rss': {
95-
const { url } = requestData
96-
if (!url) {
97-
reply.status(400).send({ error: 'RSS URL is required' })
98-
return
99-
}
100-
options.rss = url
101-
await processRSS(options, url, llmServices, transcriptServices)
102-
reply.send({ message: 'RSS feed processed successfully.' })
103-
break
104-
}
105-
106-
case 'playlist': {
107-
const { url } = requestData
108-
if (!url) {
109-
reply.status(400).send({ error: 'Playlist URL is required' })
110-
return
111-
}
112-
options.playlist = url
113-
await processPlaylist(options, url, llmServices, transcriptServices)
114-
reply.send({ message: 'Playlist processed successfully.' })
115-
break
116-
}
117-
11867
case 'file': {
11968
const { filePath } = requestData
12069
if (!filePath) {
12170
reply.status(400).send({ error: 'File path is required' })
12271
return
12372
}
12473
options.file = filePath
125-
await processFile(options, filePath, llmServices, transcriptServices)
126-
reply.send({ message: 'File processed successfully.' })
74+
const result = await processFile(options, filePath, llmServices, transcriptServices)
75+
reply.send({
76+
frontMatter: result.frontMatter,
77+
prompt: result.prompt,
78+
llmOutput: result.llmOutput,
79+
transcript: result.transcript,
80+
})
12781
break
12882
}
12983
}

0 commit comments

Comments
 (0)