Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
* Removes pointless feedback (old gem dependencies
* Installs Ollama gem
* Includes example ollama+llam3.2 sequence
  • Loading branch information
ewlarson committed Nov 26, 2024
1 parent b7a8e58 commit 64cdb11
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 348 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ gem 'chronic'
gem 'dotenv-rails'

# Feedback
gem 'pointless_feedback'
# gem 'pointless_feedback'
gem 'whenever', '~> 1.0.0', require: false
gem 'sitemap_generator', '~> 6.0.2'

Expand All @@ -159,7 +159,8 @@ gem "vite_rails", "~> 3.0"
# Shrine
gem "aws-sdk-s3", "~> 1.14"

# Progress bar
# Gazetteer
gem "activerecord-import"
gem 'ruby-progressbar', '~> 1.13'
gem 'bzip2-ffi'
gem 'bzip2-ffi'
gem 'ollama-ai', '~> 1.3.0'
42 changes: 20 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ GEM
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
afm (0.2.2)
airrecord (1.0.12)
faraday (>= 1.0, < 3.0)
faraday-net_http_persistent
net-http-persistent
amazing_print (1.6.0)
ansi (1.5.0)
appsignal (4.1.2)
Expand Down Expand Up @@ -359,19 +355,22 @@ GEM
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
faraday (2.12.1)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (3.3.0)
net-http
faraday-net_http (3.4.0)
net-http (>= 0.5.0)
faraday-net_http_persistent (2.3.0)
faraday (~> 2.5)
net-http-persistent (>= 4.0.4, < 5)
faraday-retry (2.2.1)
faraday (~> 2.0)
faraday-typhoeus (1.1.0)
faraday (~> 2.0)
typhoeus (~> 1.4)
fastimage (2.3.1)
ffi (1.17.0)
ffi-compiler (1.3.2)
Expand Down Expand Up @@ -456,7 +455,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.8.1)
json (2.8.2)
json-schema (5.0.1)
addressable (~> 2.8)
kaminari (1.2.2)
Expand Down Expand Up @@ -534,9 +533,9 @@ GEM
rake
mini_magick (4.9.5)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
minitar (1.0.2)
minitest (5.25.1)
minitest (5.25.2)
minitest-ci (3.4.0)
minitest (>= 5.0.6)
minitest-reporters (1.7.1)
Expand All @@ -552,11 +551,11 @@ GEM
net-ftp (0.3.8)
net-protocol
time
net-http (0.4.1)
net-http (0.5.0)
uri
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-imap (0.5.0)
net-imap (0.5.1)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -572,6 +571,10 @@ GEM
noticed (1.6.3)
http (>= 4.0.0)
rails (>= 5.2.0)
ollama-ai (1.3.0)
faraday (~> 2.10)
faraday-typhoeus (~> 1.1)
typhoeus (~> 1.4, >= 1.4.1)
orm_adapter (0.5.0)
ostruct (0.6.0)
pagy (6.5.0)
Expand All @@ -588,11 +591,6 @@ GEM
ruby-rc4
ttfunk
pg (1.5.9)
pointless_feedback (4.1.5)
airrecord (~> 1.0)
jquery-rails (>= 4.0)
rails (>= 4.0)
typhoeus (~> 0.7, >= 0.7.3)
popper_js (1.16.1)
process_executer (1.2.0)
public_suffix (6.0.1)
Expand Down Expand Up @@ -801,12 +799,12 @@ GEM
actionpack (>= 3.1)
jquery-rails
railties (>= 3.1)
typhoeus (0.8.0)
ethon (>= 0.8.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.2.0)
uri (0.13.1)
uri (1.0.2)
view_component (2.83.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -906,9 +904,9 @@ DEPENDENCIES
minitest-reporters
net-ftp
noticed
ollama-ai (~> 1.3.0)
paper_trail
pg
pointless_feedback
popper_js
puma (~> 5.6)
rack-cors
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/pointless_feedback.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PointlessFeedback
=begin
PointlessFeedback.setup do |config|
# ==> Feedback Configuration
# Configure the topics for the user to choose from on the feedback form
Expand All @@ -13,3 +15,4 @@
config.google_captcha_site_key = ENV["GEOBLACKLIGHT_CAPTCHA_SITE_KEY"]
config.google_captcha_secret_key = ENV["GEOBLACKLIGHT_CAPTCHA_SECRET_KEY"]
end
=end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
get '/centroids.json', :to => redirect('/centroids.json')

# Feedback
mount PointlessFeedback::Engine, :at => '/feedback'
# @TODO: PointlessFeedback gem has old typhoeus gem dependency
# mount PointlessFeedback::Engine, :at => '/feedback'

# Error Pages for exception handling - EWL
match '/404' => 'errors#not_found', via: :all
Expand Down
28 changes: 28 additions & 0 deletions docs/ollama.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'ollama-ai'

client = Ollama.new(
credentials: { address: 'http://localhost:11434' },
options: {
format: "json",
stream: false
}
)

prompt_preface = "Extract the named geographic entities from this text: "

prompt_text_to_extract = "Mom and Dad live in Cedar Falls, Iowa. My older sister lives in Harrison, AR. My brother and I live in Minneapolis, MN. I also lived in Madison, Wisconsin for over 10 years. We get around a lot."

prompt_example_response = "[{\"name\": \"name\", \"type\": \"one\"}, {\"name\": \"name\", \"type\": \"two\"}]"

prompt_suffix = "Return the results as an array of JSON objects. Each object should have a \"name\" and \"type\" property. Here is an example: #{prompt_example_response}. Do not prepend or append any text to your response. The response should be a valid JSON array of objects. Do not limit the number of results. Validate your JSON response before returning it."

result = client.generate(
{ model: 'llama3.2',
prompt: prompt_preface + prompt_text_to_extract + prompt_suffix,
stream: false
}
)

json_result = JSON.parse(result.first["response"])

puts json_result
Loading

0 comments on commit 64cdb11

Please sign in to comment.