FEATURE: add researcher persona (#181)

The researcher persona has access to Google and can perform
various internet research tasks. At the moment it can not read
web pages, but that is under consideration
This commit is contained in:
Sam 2023-09-04 12:05:27 +10:00 committed by GitHub
parent 3f9973586e
commit e3abbd9f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 1 deletions

View File

@ -107,6 +107,9 @@ en:
settings_explorer:
name: Settings Explorer
description: "AI Bot specialized in helping explore Discourse site settings"
researcher:
name: Researcher
description: "AI Bot with Google access that can research information for you"
default_pm_prefix: "[Untitled AI bot PM]"
topic_not_found: "Summary unavailable, topic not found!"
command_summary:

View File

@ -217,12 +217,13 @@ discourse_ai:
- time
ai_bot_enabled_personas:
type: list
default: "general|artist|sql_helper|settings_explorer"
default: "general|artist|sql_helper|settings_explorer|researcher"
choices:
- general
- artist
- sql_helper
- settings_explorer
- researcher
ai_bot_add_to_header:
default: true
client: true

View File

@ -46,6 +46,7 @@ module DiscourseAi
require_relative "personas/general"
require_relative "personas/sql_helper"
require_relative "personas/settings_explorer"
require_relative "personas/researcher"
end
def inject_into(plugin)

View File

@ -7,6 +7,7 @@ module DiscourseAi
personas = [Personas::General, Personas::SqlHelper]
personas << Personas::Artist if SiteSetting.ai_stability_api_key.present?
personas << Personas::SettingsExplorer
personas << Personas::Researcher if SiteSetting.ai_google_custom_search_api_key.present?
personas_allowed = SiteSetting.ai_bot_enabled_personas.split("|")
personas.filter { |persona| personas_allowed.include?(persona.to_s.demodulize.underscore) }

View File

@ -0,0 +1,26 @@
#frozen_string_literal: true
module DiscourseAi
module AiBot
module Personas
class Researcher < Persona
def commands
[Commands::GoogleCommand]
end
def system_prompt
<<~PROMPT
You are research bot. With access to the internet you can find information for users.
- You fully understand Discourse Markdown and generate it.
- When generating responses you always cite your sources.
- When possible you also quote the sources.
{commands}
PROMPT
end
end
end
end
end

View File

@ -64,12 +64,22 @@ module DiscourseAi::AiBot::Personas
it "includes all personas by default" do
# must be enabled to see it
SiteSetting.ai_stability_api_key = "abc"
SiteSetting.ai_google_custom_search_api_key = "abc"
expect(DiscourseAi::AiBot::Personas.all).to contain_exactly(
General,
SqlHelper,
Artist,
SettingsExplorer,
Researcher,
)
end
it "does not include personas that require api keys by default" do
expect(DiscourseAi::AiBot::Personas.all).to contain_exactly(
General,
SqlHelper,
SettingsExplorer,
)
end

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
RSpec.describe DiscourseAi::AiBot::Personas::Researcher do
let :researcher do
subject
end
it "renders schema" do
expect(researcher.commands).to eq([DiscourseAi::AiBot::Commands::GoogleCommand])
end
end