diff --git a/app/services/llm_service.rb b/app/services/llm_service.rb index e6b5b7227..1f9f0458b 100644 --- a/app/services/llm_service.rb +++ b/app/services/llm_service.rb @@ -11,8 +11,6 @@ def initialize openai_key, _opts = {} def make_judgement judge, query_doc_pair user_prompt = make_user_prompt query_doc_pair results = get_llm_response user_prompt, judge.system_prompt - puts 'Here are the results' - puts results judgement = Judgement.new(query_doc_pair: query_doc_pair, user: judge) judgement.rating = results[:judgment] judgement.explanation = results[:explanation] diff --git a/config/initializers/heroku.rb b/config/initializers/heroku.rb new file mode 100644 index 000000000..bb67ae33c --- /dev/null +++ b/config/initializers/heroku.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# Unpack Jupyterlite on Heroku as part of start up +# See assets.rake for some related code. +puts "about to test out heroku." +if ENV['HEROKU_APP_NAME'].present? + notebooks_gz = Rails.root.join('notebooks.gz') + destination = Rails.public_path + notebooks_dir = Rails.public_path.join('notebooks') + unless File.exist?(notebooks_dir) + + unless File.exist?(notebooks_gz) + puts 'Downloading latest Quepid Notebooks from https://github.com/o19s/quepid-jupyterlite' + system "wget --no-verbose -O #{notebooks_gz} https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz" + end + + puts "Unpacking Jupyterlite into #{destination}" + #system "tar -xzf #{notebooks_gz} --directory #{destination}" + system "tar -xzf #{notebooks_gz} --directory ./eric" + + File.delete(notebooks_gz) + end +end diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index d6860407a..654b86831 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -17,10 +17,15 @@ namespace :assets do system "wget --no-verbose -O #{notebooks_gz} https://github.com/o19s/quepid-jupyterlite/releases/latest/download/jupyter-lite-build.tgz" end - puts "Unpacking Jupyterlite into #{destination}" - system "tar -xzf #{notebooks_gz} --directory #{destination}" + # Heroku limits us to 500 MB slugs which we exceed, so + # only unpack the gzip file if we aren't in Heroku. + # On Heroku we unpack as part of start up. See heroku.rb. + if ENV['HEROKU_APP_NAME'].blank? + puts "Unpacking Jupyterlite into #{destination}" + system "tar -xzf #{notebooks_gz} --directory #{destination}" - File.delete(notebooks_gz) + File.delete(notebooks_gz) + end end end