Class: Layered::Assistant::SystemPromptService

Inherits:
Object
  • Object
show all
Defined in:
app/services/layered/assistant/system_prompt_service.rb

Instance Method Summary collapse

Instance Method Details

#call(assistant:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/layered/assistant/system_prompt_service.rb', line 4

def call(assistant:)
  parts = []

  if assistant.persona&.instructions.present?
    parts << "## Persona\n\n#{assistant.persona.instructions}"
  end

  skill_sections = assistant.skills.filter_map do |s|
    "### #{s.name}\n\n#{s.instructions}" if s.instructions.present?
  end
  if skill_sections.any?
    parts << "## Skills\n\n#{skill_sections.join("\n\n---\n\n")}"
  end

  parts << assistant.instructions if assistant.instructions.present?

  parts.join("\n\n").presence
end