Skip to content

Commit

Permalink
consolidate jsdoc to types file
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcwebdev committed Sep 26, 2024
1 parent 088c176 commit aa1ba7b
Show file tree
Hide file tree
Showing 24 changed files with 395 additions and 347 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ package-lock.json
src/llms/models
.idea
build
deno.lock
deno.lock
out
130 changes: 34 additions & 96 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,100 +379,38 @@ npm run test-local
This can be a useful way of creating a single markdown file of the entire project for giving to an LLM as context to develop new features or debug code. I'll usually start a conversation by including this along with a prompt that explains what I want changed or added.

```bash
cat README.md >> LLM.md && \
echo '\n\n```' >> LLM.md && \
tree >> LLM.md && \
echo '\n```' >> LLM.md && \
echo '\n\n' >> LLM.md && \
cat docs/examples.md >> LLM.md && \
echo '\n## AutoShow CLI Entry Point' >> LLM.md && \
echo '\n\n```js' >> LLM.md && \
cat src/autoshow.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '## Utility Functions\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/utils/cleanUpFiles.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/utils/downloadAudio.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/utils/generateMarkdown.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/utils/runLLM.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/utils/runTranscription.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '## Transcription Functions\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/transcription/whisper.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/transcription/deepgram.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/transcription/assembly.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '## LLM Functions\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/prompt.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/chatgpt.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/claude.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/cohere.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/gemini.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/llama.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/llamacpp.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/mistral.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/llms/octo.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '## Process Commands\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/commands/processVideo.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/commands/processURLs.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/commands/processRSS.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/commands/processPlaylist.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```js' >> LLM.md && \
cat src/commands/processFile.js >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '## Docker Files\n' >> LLM.md && \
echo '```Dockerfile' >> LLM.md && \
cat .github/whisper.Dockerfile >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```Dockerfile' >> LLM.md && \
cat .github/llama.Dockerfile >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```Dockerfile' >> LLM.md && \
cat Dockerfile >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```yml' >> LLM.md && \
cat docker-compose.yml >> LLM.md && \
echo '\n```\n' >> LLM.md && \
echo '```bash' >> LLM.md && \
cat docker-entrypoint.sh >> LLM.md && \
echo '\n```\n' >> LLM.md
export MD="LLM.md" && export COMMANDS="src/commands" && export UTILS="src/utils" && \
export LLMS="src/llms" && export TRANSCRIPT="src/transcription" && \
export OPEN="\n\n\`\`\`js" && export CLOSE="\n\`\`\`\n\n" && cat README.md >> $MD && \
echo '\n\n### Directory and File Structure\n\n```' >> $MD && tree >> $MD && \
echo '```\n\n## Example CLI Commands Test Suite'$OPEN'' >> $MD && cat test/all.test.js >> $MD && \
echo ''$CLOSE'## JSDoc Types'$OPEN'' >> $MD && cat src/types.js >> $MD && \
echo ''$CLOSE'## AutoShow CLI Entry Point'$OPEN'' >> $MD && cat src/autoshow.js >> $MD && \
echo ''$CLOSE'## Utility Functions\n\n### Generate Markdown'$OPEN'' >> $MD && cat $UTILS/generateMarkdown.js >> $MD && \
echo ''$CLOSE'### Download Audio'$OPEN'' >> $MD && cat $UTILS/downloadAudio.js >> $MD && \
echo ''$CLOSE'### Run Transcription'$OPEN'' >> $MD && cat $UTILS/runTranscription.js >> $MD && \
echo ''$CLOSE'### Run LLM'$OPEN'' >> $MD && cat $UTILS/runLLM.js >> $MD && \
echo ''$CLOSE'### Clean Up Files'$OPEN'' >> $MD && cat $UTILS/cleanUpFiles.js >> $MD && \
echo ''$CLOSE'## Process Commands\n\n### Process Video'$OPEN'' >> $MD && cat $COMMANDS/processVideo.js >> $MD && \
echo ''$CLOSE'### Process Playlist'$OPEN'' >> $MD && cat $COMMANDS/processPlaylist.js >> $MD && \
echo ''$CLOSE'### Process URLs'$OPEN'' >> $MD && cat $COMMANDS/processURLs.js >> $MD && \
echo ''$CLOSE'### Process RSS'$OPEN'' >> $MD && cat $COMMANDS/processRSS.js >> $MD && \
echo ''$CLOSE'### Process File'$OPEN'' >> $MD && cat $COMMANDS/processFile.js >> $MD && \
echo ''$CLOSE'## Transcription Functions\n\n### Call Whisper'$OPEN'' >> $MD && cat $TRANSCRIPT/whisper.js >> $MD && \
echo ''$CLOSE'### Call Deepgram'$OPEN'' >> $MD && cat $TRANSCRIPT/deepgram.js >> $MD && \
echo ''$CLOSE'### Call Assembly'$OPEN'' >> $MD && cat $TRANSCRIPT/assembly.js >> $MD && \
echo ''$CLOSE'## LLM Functions\n\n### Prompt Function'$OPEN'' >> $MD && cat $LLMS/prompt.js >> $MD && \
echo ''$CLOSE'### Call ChatGPT'$OPEN'' >> $MD && cat $LLMS/chatgpt.js >> $MD && \
echo ''$CLOSE'### Call Claude'$OPEN'' >> $MD && cat $LLMS/claude.js >> $MD && \
echo ''$CLOSE'### Call Cohere'$OPEN'' >> $MD && cat $LLMS/cohere.js >> $MD && \
echo ''$CLOSE'### Call Gemini'$OPEN'' >> $MD && cat $LLMS/gemini.js >> $MD && \
echo ''$CLOSE'### Call Llama.cpp'$OPEN'' >> $MD && cat $LLMS/llama.js >> $MD && \
echo ''$CLOSE'### Call Mistral'$OPEN'' >> $MD && cat $LLMS/mistral.js >> $MD && \
echo ''$CLOSE'### Call Octo'$OPEN'' >> $MD && cat $LLMS/octo.js >> $MD && \
echo ''$CLOSE'## Docker Files\n\n```Dockerfile' >> $MD && cat .github/whisper.Dockerfile >> $MD && \
echo ''$CLOSE'```Dockerfile' >> $MD && cat .github/llama.Dockerfile >> $MD && \
echo ''$CLOSE'```Dockerfile' >> $MD && cat Dockerfile >> $MD && \
echo ''$CLOSE'```yml' >> $MD && cat docker-compose.yml >> $MD && \
echo ''$CLOSE'```bash' >> $MD && cat docker-entrypoint.sh >> $MD && \
echo '\n```\n' >> $MD
```
21 changes: 7 additions & 14 deletions src/autoshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,8 @@ import { processURLs } from './commands/processURLs.js'
import { processFile } from './commands/processFile.js'
import { processRSS } from './commands/processRSS.js'
import { argv } from 'node:process'
import './types.js'

/**
* Custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
* @typedef {InquirerAnswers} InquirerAnswers
* @typedef {HandlerFunction} HandlerFunction
*/
/** @import { ProcessingOptions, InquirerAnswers, InquirerQuestions, HandlerFunction, LLMOption, TranscriptOption, WhisperModelType } from './types.js' */

// Initialize the command-line interface
const program = new Command()
Expand Down Expand Up @@ -58,6 +50,7 @@ program
.option('--noCleanUp', 'Do not delete intermediary files after processing')

// Interactive prompts using inquirer
/** @type {InquirerQuestions} */
const INQUIRER_PROMPT = [
{
type: 'list',
Expand Down Expand Up @@ -170,7 +163,7 @@ const INQUIRER_PROMPT = [
type: 'list',
name: 'whisperModel',
message: 'Select the Whisper model type:',
choices: ['tiny', 'base', 'small', 'medium', 'large'],
choices: ['tiny', 'tiny.en', 'base', 'base.en', 'small', 'small.en', 'medium', 'medium.en', 'large', 'large-v1', 'large-v2'],
when: (answers) => answers.transcriptOpt === 'whisper',
default: 'large',
},
Expand Down Expand Up @@ -225,9 +218,9 @@ async function handleInteractivePrompt(options) {
// Handle transcription options
if (answers.transcriptOpt === 'whisper') {
if (answers.useDocker) {
options.whisperDocker = answers.whisperModel
options.whisperDocker = /** @type {WhisperModelType} */ (answers.whisperModel)
} else {
options.whisper = answers.whisperModel
options.whisper = /** @type {WhisperModelType} */ (answers.whisperModel)
}
} else {
options[answers.transcriptOpt] = true
Expand Down Expand Up @@ -277,15 +270,15 @@ program.action(async (options) => {
* Determine the selected LLM option
* @type {LLMOption | undefined}
*/
const llmOpt = /** @type {LLMOption} */ (['chatgpt', 'claude', 'cohere', 'mistral', 'octo', 'llama', 'gemini'].find(
const llmOpt = /** @type {LLMOption | undefined} */ (['chatgpt', 'claude', 'cohere', 'mistral', 'octo', 'llama', 'gemini'].find(
(option) => options[option]
))

/**
* Determine the transcription service to use
* @type {TranscriptOption | undefined}
*/
const transcriptOpt = /** @type {TranscriptOption} */ (['whisper', 'whisperDocker', 'deepgram', 'assembly'].find(
const transcriptOpt = /** @type {TranscriptOption | undefined} */ (['whisper', 'whisperDocker', 'deepgram', 'assembly'].find(
(option) => options[option]
))

Expand Down
12 changes: 3 additions & 9 deletions src/commands/processFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ import { downloadFileAudio } from '../utils/downloadAudio.js'
import { runTranscription } from '../utils/runTranscription.js'
import { runLLM } from '../utils/runLLM.js'
import { cleanUpFiles } from '../utils/cleanUpFiles.js'
import '../types.js'

/**
* Import custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
*/
/** @import { LLMOption, TranscriptOption, ProcessingOptions } from '../types.js' */

/**
* Main function to process a local audio or video file.
* @param {string} filePath - The path to the local file to process.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down
14 changes: 4 additions & 10 deletions src/commands/processPlaylist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ import { writeFile } from 'node:fs/promises'
import { processVideo } from './processVideo.js'
import { execFile } from 'node:child_process'
import { promisify } from 'node:util'
import '../types.js'

const execFilePromise = promisify(execFile)
/** @import { LLMOption, TranscriptOption, ProcessingOptions } from '../types.js' */

/**
* Custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
*/
const execFilePromise = promisify(execFile)

/**
* Main function to process a YouTube playlist.
* @param {string} playlistUrl - The URL of the YouTube playlist to process.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down
17 changes: 5 additions & 12 deletions src/commands/processRSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ import { downloadAudio } from '../utils/downloadAudio.js'
import { runTranscription } from '../utils/runTranscription.js'
import { runLLM } from '../utils/runLLM.js'
import { cleanUpFiles } from '../utils/cleanUpFiles.js'
import '../types.js'

/**
* Import custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
* @typedef {RSSItem} RSSItem
*/
/** @import { LLMOption, TranscriptOption, ProcessingOptions, RSSItem } from '../types.js' */

// Initialize XML parser with specific options
const parser = new XMLParser({
Expand All @@ -31,8 +24,8 @@ const parser = new XMLParser({
/**
* Process a single item from the RSS feed.
* @param {RSSItem} item - The item to process.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down Expand Up @@ -63,8 +56,8 @@ async function processItem(item, transcriptOpt, llmOpt, options) {
/**
* Main function to process an RSS feed.
* @param {string} rssUrl - The URL of the RSS feed to process.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down
12 changes: 3 additions & 9 deletions src/commands/processURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
import { readFile } from 'node:fs/promises'
import { processVideo } from './processVideo.js'
import { resolve } from 'node:path'
import '../types.js'

/**
* Import custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
*/
/** @import { LLMOption, TranscriptOption, ProcessingOptions } from '../types.js' */

/**
* Main function to process URLs from a file.
* @param {string} filePath - The path to the file containing URLs.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down
12 changes: 3 additions & 9 deletions src/commands/processVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ import { downloadAudio } from '../utils/downloadAudio.js'
import { runTranscription } from '../utils/runTranscription.js'
import { runLLM } from '../utils/runLLM.js'
import { cleanUpFiles } from '../utils/cleanUpFiles.js'
import '../types.js'

/**
* Custom types
* @typedef {LLMOption} LLMOption
* @typedef {TranscriptOption} TranscriptOption
* @typedef {ProcessingOptions} ProcessingOptions
*/
/** @import { LLMOption, TranscriptOption, ProcessingOptions } from '../types.js' */

/**
* Main function to process a single video.
* @param {string} url - The URL of the video to process.
* @param {LLMOption} llmOpt - The selected Language Model option.
* @param {TranscriptOption} transcriptOpt - The transcription service to use.
* @param {LLMOption} [llmOpt] - The selected Language Model option.
* @param {TranscriptOption} [transcriptOpt] - The transcription service to use.
* @param {ProcessingOptions} options - Additional options for processing.
* @returns {Promise<void>}
*/
Expand Down
Loading

0 comments on commit aa1ba7b

Please sign in to comment.