Class: VideoProcessing::SeoService
- Inherits:
-
Object
- Object
- VideoProcessing::SeoService
- Defined in:
- app/services/video_processing/seo_service.rb
Overview
Generates SEO content for videos using the LLM via VideoProcessing::SeoAgent.
Uses RubyLLM with_schema for structured JSON output (sub_header, meta_title,
meta_description, expanded_description).
Instance Method Summary collapse
-
#generate_seo_content ⇒ Object
Generate all SEO content (meta title, meta description, expanded description, sub_header).
-
#initialize(video) ⇒ SeoService
constructor
A new instance of SeoService.
Constructor Details
#initialize(video) ⇒ SeoService
Returns a new instance of SeoService.
9 10 11 |
# File 'app/services/video_processing/seo_service.rb', line 9 def initialize(video) @video = video end |
Instance Method Details
#generate_seo_content ⇒ Object
Generate all SEO content (meta title, meta description, expanded description, sub_header)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/video_processing/seo_service.rb', line 14 def generate_seo_content Rails.logger.info "Generating SEO content for video #{@video.id} using LLM..." # Extract clean transcript text transcript_text = extract_clean_transcript_text unless transcript_text.present? Rails.logger.error "Cannot generate SEO content for video #{@video.id} - no transcript available" return error_response('No transcript available') end Rails.logger.info "Transcript text length: #{transcript_text.length} characters" Rails.logger.info "Transcript text preview: #{transcript_text[0..200]}..." # Generate all SEO content using AssemblyAI LLM Gateway seo_content = generate_all_seo_content(transcript_text) Rails.logger.info "Generated sub_header: #{seo_content['sub_header']}" Rails.logger.info "Generated meta_title: #{seo_content['meta_title']}" Rails.logger.info "Generated meta_description: #{seo_content['meta_description']}" Rails.logger.info "Generated expanded_description: #{seo_content['expanded_description']&.slice(0, 200)}..." # Return the SEO content seo_content end |