Class: RailsAi::ContextAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai/context_analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_contextObject (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_contextObject (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_contextObject (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

#generate_with_context(prompt, **opts) ⇒ Object



19
20
21
22
23
# File 'lib/rails_ai/context_analyzer.rb', line 19

def generate_with_context(prompt, **opts)
  enhanced_prompt = build_context_aware_prompt(nil, prompt)
  
  RailsAi.chat(enhanced_prompt, **opts)
end