mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 19:22:18 +08:00
108 lines
3.7 KiB
Ruby
Vendored
108 lines
3.7 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Agents
|
|
class Proofreader < Agent
|
|
def self.default_enabled
|
|
false
|
|
end
|
|
|
|
def system_prompt
|
|
<<~PROMPT.strip
|
|
You are a markdown proofreader. You correct egregious typos and phrasing issues but keep the user's original voice.
|
|
You do not touch quoted text, code blocks, or inline code.
|
|
Treat markdown blockquotes (lines starting with >) and Discourse quote blocks ([quote]...[/quote], including their metadata lines) as verbatim copies and return them exactly as provided, even if they contain typos.
|
|
Only proofread text the user wrote outside quoted or code sections. If nothing outside those sections needs fixing, echo the text back exactly.
|
|
You will find the text between <input></input> XML tags.
|
|
|
|
Format your response as a JSON object with a single key named "output", which has the proofread version as the value.
|
|
Your output should be in the following format:
|
|
|
|
{"output": "xx"}
|
|
|
|
Where "xx" is replaced by the proofread version.
|
|
reply with valid JSON only
|
|
PROMPT
|
|
end
|
|
|
|
def response_format
|
|
[{ "key" => "output", "type" => "string" }]
|
|
end
|
|
|
|
def examples
|
|
[
|
|
[
|
|
"<input></input>",
|
|
{ output: "" }.to_json,
|
|
],
|
|
[
|
|
"<input>The rain in spain stays mainly in the plane.</input>",
|
|
{ output: "The rain in Spain, stays mainly in the Plane." }.to_json,
|
|
],
|
|
[
|
|
"<input>The rain in Spain, stays mainly in the Plane.</input>",
|
|
{ output: "The rain in Spain, stays mainly in the Plane." }.to_json,
|
|
],
|
|
[<<~TEXT, { output: <<~TEXT }.to_json],
|
|
<input>
|
|
Hello,
|
|
|
|
Sometimes the logo isn't changing automatically when color scheme changes.
|
|
|
|

|
|
</input>
|
|
TEXT
|
|
Hello,
|
|
Sometimes the logo does not change automatically when the color scheme changes.
|
|

|
|
TEXT
|
|
[<<~TEXT, { output: <<~TEXT }.to_json],
|
|
<input>
|
|
Any ideas what is wrong with this peace of code?
|
|
> This quot contains a typo
|
|
```ruby
|
|
# this has speling mistakes
|
|
testin.atypo = 11
|
|
baad = "bad"
|
|
```
|
|
</input>
|
|
TEXT
|
|
Any ideas what is wrong with this piece of code?
|
|
> This quot contains a typo
|
|
```ruby
|
|
# this has speling mistakes
|
|
testin.atypo = 11
|
|
baad = "bad"
|
|
```
|
|
TEXT
|
|
[<<~TEXT, { output: <<~TEXT }.to_json],
|
|
<input>
|
|
Thanks for sharin this.
|
|
|
|
> I cant believe this happend.
|
|
</input>
|
|
TEXT
|
|
Thanks for sharing this.
|
|
|
|
> I cant believe this happend.
|
|
TEXT
|
|
[<<~TEXT, { output: <<~TEXT }.to_json],
|
|
<input>
|
|
[quote="sam, post:2, topic:456"]
|
|
Ths original poster has a typo.
|
|
[/quote]
|
|
|
|
I realy appreciate the context.
|
|
</input>
|
|
TEXT
|
|
[quote="sam, post:2, topic:456"]
|
|
Ths original poster has a typo.
|
|
[/quote]
|
|
|
|
I really appreciate the context.
|
|
TEXT
|
|
]
|
|
end
|
|
end
|
|
end
|
|
end
|