castedo / copyaid

Mirror of https://gitlab.com/castedo/copyaid
MIT License
0 stars 0 forks source link

enable setting of template placeholder for text format based on file extension #3

Open castedo opened 10 months ago

castedo commented 10 months ago

This is additional functionality beyond #2. Based on the file extension of the source file passed to copyaid, enable the setting of a template placeholder for the chat_system message setting.

Maybe the mapping between filename extension and text to be inserted should be direct like:

".md" -> "Markdown and HTML"
".tex" -> "LaTeX"

Note how "Markdown and HTML" could perform better in the prompt for GPT even though to a human, conceptually, "Markdown" should suffice, in theory.

Or maybe there should be a MIME type indirection in between:

".md" -> "text/markdown" -> "Markdown and HTML"
".tex" -> "application/x-latex" -> "LaTeX"

These mapping could be exclusively in the user copyaid.toml config file or the prompt query settings file. My inclination is that the mapping

".md" -> "text/markdown"
".tex" -> "application/x-latex"

should be in the user config copyaid.toml and the mapping

"text/markdown" -> "Markdown and HTML"
"application/x-latex" -> "LaTeX"

should be in the settings file, along with the OpenAI API settings like the prompt template and the GPT model setting.

castedo commented 10 months ago

Idea for new settings of user config file (`copyaid.toml')

[copybreak]
ids = ["copybreak", "cbr"]

[formats]
default = "markdown"

[formats.markdown]
mime_type = "text/markdown"
extensions = ["md"]
copybreak.delim = ["<!--", "-->"]

[formats.tex]
mime_type = "application/x-latex"
extensions = ["tex"]
copybreak.delim = "%%"
castedo commented 9 months ago

Rather than placing mime_type directly under the format, consider enable generic setting of instruction parameters per format via something like:

[formats.markdown]
instruction.parameters = { mime_type = "text/markdown" }