Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/completion_prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CompletionPrompt < ActiveRecord::Base
CUSTOM_PROMPT = -305
EXPLAIN = -306
ILLUSTRATE_POST = -308
DETECT_TEXT_LOCALE = -309

enum :prompt_type, { text: 0, list: 1, diff: 2 }

Expand Down
17 changes: 17 additions & 0 deletions db/fixtures/ai_helper/603_completion_prompts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,20 @@
cp.prompt_type = CompletionPrompt.prompt_types[:list]
cp.messages = {}
end

CompletionPrompt.seed do |cp|
cp.id = -309
cp.name = "detect_text_locale"
cp.prompt_type = CompletionPrompt.prompt_types[:text]
cp.messages = {
insts: <<~TEXT,
I want you to act as a language expert, determining the locale for a set of text.
The locale is a language identifier, such as "en" for English, "de" for German, etc,
and can also include a region identifier, such as "en-GB" for British English, or "zh-Hans" for Simplified Chinese.
I will provide you with text, and you will determine the locale of the text.
You will find the text between <input></input> XML tags.
Include your locale between <output></output> XML tags.
TEXT
examples: [["<input>Hello my favourite colour is red</input>", "<output>en-GB</output>"]],
}
end
6 changes: 4 additions & 2 deletions spec/lib/modules/ai_helper/assistant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@
it "returns all available prompts" do
prompts = subject.available_prompts(user)

expect(prompts.length).to eq(6)
expect(prompts.length).to eq(7)
expect(prompts.map { |p| p[:name] }).to contain_exactly(
"translate",
"generate_titles",
"proofread",
"markdown_table",
"custom_prompt",
"explain",
"detect_text_locale",
)
end

Expand All @@ -73,7 +74,7 @@
it "returns the illustrate_post prompt in the list of all prompts" do
prompts = subject.available_prompts(user)

expect(prompts.length).to eq(7)
expect(prompts.length).to eq(8)
expect(prompts.map { |p| p[:name] }).to contain_exactly(
"translate",
"generate_titles",
Expand All @@ -82,6 +83,7 @@
"custom_prompt",
"explain",
"illustrate_post",
"detect_text_locale",
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

it "returns the available prompts" do
expect(serializer.ai_helper_prompts).to be_present
expect(serializer.ai_helper_prompts.object.count).to eq(6)
expect(serializer.ai_helper_prompts.object.count).to eq(7)
end
end
end