Class: RailsAi::ContextAnalyzer
- Inherits:
-
Object
- Object
- RailsAi::ContextAnalyzer
- Defined in:
- lib/rails_ai/context_analyzer.rb
Instance Attribute Summary collapse
-
#image_context ⇒ Object
readonly
Returns the value of attribute image_context.
-
#user_context ⇒ Object
readonly
Returns the value of attribute user_context.
-
#window_context ⇒ Object
readonly
Returns the value of attribute window_context.
Instance Method Summary collapse
- #analyze_with_context(image, prompt, **opts) ⇒ Object
- #generate_image_with_context(prompt, **opts) ⇒ Object
- #generate_with_context(prompt, **opts) ⇒ Object
-
#initialize(user_context: nil, window_context: nil, image_context: nil) ⇒ ContextAnalyzer
constructor
A new instance of ContextAnalyzer.
Constructor Details
#initialize(user_context: nil, window_context: nil, image_context: nil) ⇒ ContextAnalyzer
Returns a new instance of ContextAnalyzer.
7 8 9 10 11 |
# File 'lib/rails_ai/context_analyzer.rb', line 7 def initialize(user_context: nil, window_context: nil, image_context: nil) @user_context = user_context || {} @window_context = window_context || {} @image_context = image_context || {} end |
Instance Attribute Details
#image_context ⇒ Object (readonly)
Returns the value of attribute image_context.
5 6 7 |
# File 'lib/rails_ai/context_analyzer.rb', line 5 def image_context @image_context end |
#user_context ⇒ Object (readonly)
Returns the value of attribute user_context.
5 6 7 |
# File 'lib/rails_ai/context_analyzer.rb', line 5 def user_context @user_context end |
#window_context ⇒ Object (readonly)
Returns the value of attribute window_context.
5 6 7 |
# File 'lib/rails_ai/context_analyzer.rb', line 5 def window_context @window_context end |
Instance Method Details
#analyze_with_context(image, prompt, **opts) ⇒ Object
13 14 15 16 17 |
# File 'lib/rails_ai/context_analyzer.rb', line 13 def analyze_with_context(image, prompt, **opts) enhanced_prompt = build_context_aware_prompt(image, prompt) RailsAi.analyze_image(image, enhanced_prompt, **opts) end |
#generate_image_with_context(prompt, **opts) ⇒ Object
25 26 27 28 29 |
# File 'lib/rails_ai/context_analyzer.rb', line 25 def generate_image_with_context(prompt, **opts) enhanced_prompt = build_context_aware_prompt(nil, prompt) RailsAi.generate_image(enhanced_prompt, **opts) end |