jekyll_ai_related_posts 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b3f80af93fac9879714b6ee8806b101b1a2ede2337f285b19091888a9105718
4
- data.tar.gz: 94d1b81c2c3ea6bde9628795e7ca24c1df5bf33108229d6a16cb72f336fcb676
3
+ metadata.gz: bd10032e0e9758acac7f0dc26d79aaa2a8de36e8872be41ecd62f915b4422847
4
+ data.tar.gz: f999747d95b4b9dce7c1fd6fcad198959a1734c13dfc50cbdd57bdb267f0fcdc
5
5
  SHA512:
6
- metadata.gz: 74cc6e541c458483e3891a3b10d0dc6f49266fec3e06312dceb733593c37c97c686e73f79e43d8c5d26e4edcf696c10f3695fc1d79e6941dceaf3983b9938f51
7
- data.tar.gz: ab0d010676d87c601cdcb8237bc1b5275ecd2ca1dc39ae2648c83e4ae729c5acd6e3d5642d1a712ad5b5017dc8864e968b3d2a9e7308f97e45499155e7f44e41
6
+ metadata.gz: ea9b61e8f8e3b9148146eece6a453abc57e720c295db1b99d11d6ef6786c206a4efdca194c6c0d8287133699517775b242aa9b4cae5af1cc10ee40903be3c0ab
7
+ data.tar.gz: 9d43069c05704e7c032840e4fc6409da6fd2ca437b5b2cf282021a84b0c64fa9b1761c03ab3694759261cf10b26cd087a49ace883f1d4c85e5f365d90d0b8bb2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2024-04-18
3
+ ## [0.1.2] - 2024-04-24
4
+
5
+ - [Bugfix] Include up to 10 related posts (like native Jekyll does) instead of just 3.
6
+
7
+ ## [0.1.1] - 2024-04-23
8
+
9
+ - [Bugfix] Exception when running in cache-only mode.
10
+
11
+ ## [0.1.0] - 2024-04-23
4
12
 
5
13
  - Initial release
data/README.md CHANGED
@@ -16,6 +16,13 @@ embeddings API that allows us to easily get the embedding vector (in one of
16
16
  OpenAI's models) of some text. We can use these vectors to compute related
17
17
  posts with the accuracy of OpenAI's models (or any other LLM, for that matter).
18
18
 
19
+ ### Used in Production at
20
+
21
+ - [MikeKasberg.com](https://www.mikekasberg.com)
22
+
23
+ (Feel free to open a PR to add your website if you're using this gem in
24
+ production!)
25
+
19
26
  ## Installation
20
27
 
21
28
  Jekyll AI Related Posts is a [Jekyll
@@ -27,6 +34,16 @@ plugins:
27
34
  - jekyll_ai_related_posts
28
35
  ```
29
36
 
37
+ You should also ignore the cache files that this plugin generates. (This will
38
+ help avoid a regeneration loop when using `jekyll serve`.)
39
+
40
+ ```yaml
41
+ exclude:
42
+ - .ai_related_posts_cache.sqlite3
43
+ - .ai_related_posts_cache.sqlite3-journal
44
+ ```
45
+
46
+
30
47
  ## Configuration
31
48
 
32
49
  All config for this plugin sits under a top-level `ai_related_posts` key.
@@ -71,6 +88,13 @@ Based on some light testing, this took me 0.5 sec per post, or about 50 sec for
71
88
  a blog with 100 posts. All subsequent runs will be faster since embeddings will
72
89
  be cached.
73
90
 
91
+ ### Performance
92
+
93
+ On an example blog with ~100 posts, this plugin produces more accurate results
94
+ than classifier-reborn (LSI) in about the same amount of time. See [this blog
95
+ post](https://www.mikekasberg.com/blog/2024/04/23/better-related-posts-in-jekyll-using-ai.html)
96
+ for details.
97
+
74
98
  ### Cost
75
99
 
76
100
  The API costs to use this plugin with OpenAI's API are minimal. I ran this
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jekyll_ai_related_posts.gemspec
6
+ gemspec path: '../'
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+ gem "rubocop-rails-omakase", require: false
14
+
15
+ gem "debug"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "~> 3.9"
6
+ gem "kramdown-parser-gfm"
7
+
8
+ # Specify your gem's dependencies in jekyll_ai_related_posts.gemspec
9
+ gemspec path: '../'
10
+
11
+ gem "rake", "~> 13.0"
12
+
13
+ gem "rspec", "~> 3.0"
14
+
15
+ gem "rubocop", "~> 1.21"
16
+ gem "rubocop-rails-omakase", require: false
17
+
18
+ gem "debug"
@@ -9,6 +9,8 @@ require "json"
9
9
  module JekyllAiRelatedPosts
10
10
  class Generator < Jekyll::Generator
11
11
  def generate(site)
12
+ Jekyll.logger.info "AI Related Posts:", "Generating related posts..."
13
+
12
14
  @site = site
13
15
  setup_database
14
16
 
@@ -18,7 +20,6 @@ module JekyllAiRelatedPosts
18
20
  end
19
21
 
20
22
  if fetch_enabled?
21
- Jekyll.logger.info "[ai_related_posts] Generating related posts..."
22
23
  @embeddings_fetcher = new_fetcher
23
24
 
24
25
  @site.posts.docs.each do |p|
@@ -29,7 +30,7 @@ module JekyllAiRelatedPosts
29
30
  find_related(p)
30
31
  end
31
32
  else
32
- Jekyll.logger.info "[ai_related_posts] Using cached related posts data..."
33
+ Jekyll.logger.info "AI Related Posts:", "Fetch disabled. Using cached related posts data."
33
34
 
34
35
  @site.posts.docs.each do |p|
35
36
  fallback_generate_related(p)
@@ -111,7 +112,7 @@ module JekyllAiRelatedPosts
111
112
  relative_path: post.relative_path
112
113
  } ]))
113
114
  # The first result is the post itself, with a distance of 0.
114
- rowids = results.sort_by { |r| r["distance"] }.drop(1).first(3).map { |r| r["rowid"] }
115
+ rowids = results.sort_by { |r| r["distance"] }.drop(1).first(10).map { |r| r["rowid"] }
115
116
 
116
117
  posts_by_rowid = {}
117
118
  rowids.each do |rowid|
@@ -139,7 +140,7 @@ module JekyllAiRelatedPosts
139
140
  end
140
141
 
141
142
  def embedding_for(post)
142
- Jekyll.logger.info "[ai_related_posts] Fetching embedding for #{post.relative_path}"
143
+ Jekyll.logger.info "AI Related Posts:", "Fetching embedding for #{post.relative_path}"
143
144
  input = embedding_text(post)
144
145
 
145
146
  @embeddings_fetcher.embedding_for(input)
@@ -175,7 +176,7 @@ module JekyllAiRelatedPosts
175
176
  SQL
176
177
  ActiveRecord::Base.connection.execute(create_vss_posts)
177
178
 
178
- Jekyll.logger.debug("ai_related_posts db setup complete")
179
+ Jekyll.logger.debug "AI Related Posts:", "DB setup complete"
179
180
  end
180
181
  end
181
182
  end
@@ -29,8 +29,8 @@ module JekyllAiRelatedPosts
29
29
 
30
30
  res.body["data"].first["embedding"]
31
31
  rescue Faraday::Error => e
32
- Jekyll.logger.error "Error response from OpanAI API!"
33
- Jekyll.logger.error e.inspect
32
+ Jekyll.logger.error "AI Related Posts:", "Error response from OpenAI API!"
33
+ Jekyll.logger.error "AI Related Posts:", e.inspect
34
34
 
35
35
  raise
36
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllAiRelatedPosts
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_ai_related_posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kasberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-23 00:00:00.000000000 Z
11
+ date: 2024-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -107,6 +107,8 @@ files:
107
107
  - LICENSE.txt
108
108
  - README.md
109
109
  - Rakefile
110
+ - gemfiles/current.gemfile
111
+ - gemfiles/jekyll3.gemfile
110
112
  - lib/jekyll_ai_related_posts.rb
111
113
  - lib/jekyll_ai_related_posts/generator.rb
112
114
  - lib/jekyll_ai_related_posts/models/post.rb
@@ -119,7 +121,7 @@ metadata:
119
121
  allowed_push_host: https://rubygems.org
120
122
  homepage_uri: https://github.com/mkasberg/jekyll_ai_related_posts
121
123
  source_code_uri: https://github.com/mkasberg/jekyll_ai_related_posts
122
- changelog_uri: https://github.com/mkasberg/jekyll_ai_related_posts
124
+ changelog_uri: https://github.com/mkasberg/jekyll_ai_related_posts/blob/main/CHANGELOG.md
123
125
  post_install_message:
124
126
  rdoc_options: []
125
127
  require_paths: