mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-11-04 00:18:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			765 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			765 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# frozen_string_literal: true
 | 
						|
 | 
						|
module DiscourseAi
 | 
						|
  module Summarization
 | 
						|
    module Strategies
 | 
						|
      class TruncateContent < ::Summarization::Base
 | 
						|
        def initialize(completion_model)
 | 
						|
          @completion_model = completion_model
 | 
						|
        end
 | 
						|
 | 
						|
        attr_reader :completion_model
 | 
						|
 | 
						|
        delegate :correctly_configured?,
 | 
						|
                 :display_name,
 | 
						|
                 :configuration_hint,
 | 
						|
                 :model,
 | 
						|
                 to: :completion_model
 | 
						|
 | 
						|
        def summarize(content, &on_partial_blk)
 | 
						|
          opts = content.except(:contents)
 | 
						|
 | 
						|
          {
 | 
						|
            summary:
 | 
						|
              completion_model.summarize_with_truncation(content[:contents], opts, &on_partial_blk),
 | 
						|
            chunks: [],
 | 
						|
          }
 | 
						|
        end
 | 
						|
      end
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 |