FEATURE: Add a markdown table AI helper (#25)

This commit is contained in:
Sam 2023-03-23 03:16:29 +11:00 committed by GitHub
parent 1916bafca0
commit 1d14f7ffaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 3 deletions

View File

@ -61,3 +61,4 @@ en:
translate: Translate to English
generate_titles: Suggest topic titles
proofread: Proofread text
markdown_table: Generate Markdown table

View File

@ -80,3 +80,42 @@ CompletionPrompt.seed do |cp|
TEXT
]
end
CompletionPrompt.seed do |cp|
cp.id = -4
cp.name = "markdown_table"
cp.prompt_type = CompletionPrompt.prompt_types[:diff]
cp.messages = [
{ role: "system", content: <<~TEXT },
You are a markdown table formatter, I will provide you text and you will format it into a markdown table
TEXT
{ role: "user", content: "sam,joe,jane\nage: 22| 10|11" },
{ role: "assistant", content: <<~TEXT },
| | sam | joe | jane |
|---|---|---|---|
| age | 22 | 10 | 11 |
TEXT
{ role: "user", content: <<~TEXT },
sam: speed 100, age 22
jane: age 10
fred: height 22
TEXT
{ role: "assistant", content: <<~TEXT },
| | speed | age | height |
|---|---|---|---|
| sam | 100 | 22 | - |
| jane | - | 10 | - |
| fred | - | - | 22 |
TEXT
{ role: "user", content: <<~TEXT },
chrome 22ms (first load 10ms)
firefox 10ms (first load: 9ms)
TEXT
{ role: "assistant", content: <<~TEXT },
| Browser | Load Time (ms) | First Load Time (ms) |
|---|---|---|
| Chrome | 22 | 10 |
| Firefox | 10 | 9 |
TEXT
]
end

View File

@ -6,7 +6,8 @@ module DiscourseAi
TRANSLATE = "translate"
GENERATE_TITLES = "generate_titles"
PROOFREAD = "proofread"
VALID_TYPES = [TRANSLATE, GENERATE_TITLES, PROOFREAD]
MARKDOWN_TABLE = "markdown_table"
VALID_TYPES = [TRANSLATE, GENERATE_TITLES, PROOFREAD, MARKDOWN_TABLE]
def available_prompts
CompletionPrompt

View File

@ -9,7 +9,7 @@ module ::DiscourseAi
"Content-Type" => "application/json",
}
connection_opts = { request: { write_timeout: 10, read_timeout: 10, open_timeout: 10 } }
connection_opts = { request: { write_timeout: 60, read_timeout: 60, open_timeout: 60 } }
response =
Faraday.new(nil, connection_opts).post(