Skip to content

Commit

Permalink
style(hound): fix hound violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonaspng committed Jan 5, 2025
1 parent 06814cf commit c9985ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions app/services/rag/chunking_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ def initialize(text: nil, file: nil)
end

def file_chunking
if @file_type == '.pdf'
reader = PDF::Reader.new(@file.path)
text = reader.pages.map(&:text).join(' ')
elsif @file_type == '.txt'
text = File.read(@file.path)
else
raise "Unsupported file type: #{@file_type}"
end
text = case @file_type
when '.pdf'
reader = PDF::Reader.new(@file.path)
reader.pages.map(&:text).join(' ')
when '.txt'
File.read(@file.path)
else
raise "Unsupported file type: #{@file_type}"
end

@text = text.gsub(/\s+/, ' ').strip
fixed_size_chunk_text(500, 100)
end
Expand Down
3 changes: 2 additions & 1 deletion app/services/rag/llm_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def get_image_caption(image)
role: 'user',
content: [
{ type: 'text',
text: 'What is in this image? Do not give a summary of image at the end. Make sure response is less than 80 words' },
text: 'What is in this image? Do not give a summary of image at the end.
Make sure response is less than 80 words' },
{
type: 'image_url',
image_url: {
Expand Down
1 change: 1 addition & 0 deletions config/initializers/llm_langchain.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
if ENV['OPENAI_API_KEY'].present?
require 'langchain'
# Create a global OpenAI client instance
Expand Down

0 comments on commit c9985ff

Please sign in to comment.