Class: RubyAiGemContext::Generator
- Inherits:
-
Object
- Object
- RubyAiGemContext::Generator
- Defined in:
- lib/ruby_ai_gem_context/generator.rb
Overview
Generates context files using RubyLLM
Instance Attribute Summary collapse
-
#file_collector ⇒ Object
readonly
Returns the value of attribute file_collector.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
Instance Method Summary collapse
-
#build_prompt(files) ⇒ Object
Build the full prompt including project context.
-
#generate ⇒ String
Generate content for the platform.
-
#initialize(platform:, file_collector:, **options) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(platform:, file_collector:, **options) ⇒ Generator
Returns a new instance of Generator.
13 14 15 16 17 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 13 def initialize(platform:, file_collector:, **) @platform = platform @file_collector = file_collector @options = end |
Instance Attribute Details
#file_collector ⇒ Object (readonly)
Returns the value of attribute file_collector.
8 9 10 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 8 def file_collector @file_collector end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 8 def @options end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
8 9 10 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 8 def platform @platform end |
Instance Method Details
#build_prompt(files) ⇒ Object
Build the full prompt including project context
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 30 def build_prompt(files) <<~PROMPT #{platform.generation_prompt} --- Here is the project's source code and files for context: #{format_files(files)} PROMPT end |
#generate ⇒ String
Generate content for the platform
21 22 23 24 25 26 27 |
# File 'lib/ruby_ai_gem_context/generator.rb', line 21 def generate files = file_collector.collect prompt = build_prompt(files) response = chat(prompt) response.content end |