jekyll_ai_related_posts 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -5
- data/lib/jekyll_ai_related_posts/generator.rb +5 -5
- data/lib/jekyll_ai_related_posts/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b3f80af93fac9879714b6ee8806b101b1a2ede2337f285b19091888a9105718
|
4
|
+
data.tar.gz: 94d1b81c2c3ea6bde9628795e7ca24c1df5bf33108229d6a16cb72f336fcb676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74cc6e541c458483e3891a3b10d0dc6f49266fec3e06312dceb733593c37c97c686e73f79e43d8c5d26e4edcf696c10f3695fc1d79e6941dceaf3983b9938f51
|
7
|
+
data.tar.gz: ab0d010676d87c601cdcb8237bc1b5275ecd2ca1dc39ae2648c83e4ae729c5acd6e3d5642d1a712ad5b5017dc8864e968b3d2a9e7308f97e45499155e7f44e41
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Jekyll AI Related Posts 🪄
|
2
2
|
|
3
|
+
Rubygems: [jekyll_ai_related_posts](https://rubygems.org/gems/jekyll_ai_related_posts)
|
4
|
+
|
3
5
|
Jekyll ships with functionality that populates
|
4
6
|
[related_posts](https://jekyllrb.com/docs/variables/) with the ten most recent
|
5
7
|
posts. If you install
|
@@ -18,7 +20,12 @@ posts with the accuracy of OpenAI's models (or any other LLM, for that matter).
|
|
18
20
|
|
19
21
|
Jekyll AI Related Posts is a [Jekyll
|
20
22
|
plugin](https://jekyllrb.com/docs/plugins/installation/). It can be installed
|
21
|
-
using any Jekyll plugin installation method.
|
23
|
+
using any Jekyll plugin installation method. For example, in your `_config.yml`:
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
plugins:
|
27
|
+
- jekyll_ai_related_posts
|
28
|
+
```
|
22
29
|
|
23
30
|
## Configuration
|
24
31
|
|
@@ -57,6 +64,20 @@ to use it:
|
|
57
64
|
</ul>
|
58
65
|
```
|
59
66
|
|
67
|
+
### First Run
|
68
|
+
|
69
|
+
The first time the plugin runs, it will fetch embeddings for all your posts.
|
70
|
+
Based on some light testing, this took me 0.5 sec per post, or about 50 sec for
|
71
|
+
a blog with 100 posts. All subsequent runs will be faster since embeddings will
|
72
|
+
be cached.
|
73
|
+
|
74
|
+
### Cost
|
75
|
+
|
76
|
+
The API costs to use this plugin with OpenAI's API are minimal. I ran this
|
77
|
+
plugin for all 84 posts on [mikekasberg.com](https://www.mikekasberg.com) for
|
78
|
+
$0.00 in API fees (1,277 tokens on the text-embedding-3-small model). (Your
|
79
|
+
results may vary, but should remain inexpensive.)
|
80
|
+
|
60
81
|
### Upgrading from Built-In Related Posts
|
61
82
|
|
62
83
|
If you're already using Jekyll's built-in `site.related_posts` and you want to
|
@@ -68,6 +89,17 @@ upgrade to AI related posts:
|
|
68
89
|
option to the `jekyll` command. You can remove the `classifier-reborn` gem and
|
69
90
|
its dependencies (Numo).
|
70
91
|
|
92
|
+
### Cache File (.ai_related_posts_cache.sqlite3)
|
93
|
+
|
94
|
+
This plugin will cache embeddings in `.ai_related_posts_cache.sqlite3` in your
|
95
|
+
Jekyll source root (typically the root of your project directory). The file
|
96
|
+
itself is a SQLite database file. For most cases, I'd recommend adding this file
|
97
|
+
to your `.gitignore` since it's a binary cache file. However, you _may_ choose
|
98
|
+
to check it in to git if, for example, you want to share cached embeddings
|
99
|
+
across many machines (and are willing to check in a binary file on the order of
|
100
|
+
1-10Mb to do so). If the file is not present, it will be re-created and
|
101
|
+
embeddings will be fetched from the API (which may result in higher API usage
|
102
|
+
fees if done frequently).
|
71
103
|
|
72
104
|
## How It Works
|
73
105
|
|
@@ -88,10 +120,9 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
88
120
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
89
121
|
prompt that will allow you to experiment.
|
90
122
|
|
91
|
-
To
|
92
|
-
|
93
|
-
|
94
|
-
git commits and the created tag, and push the `.gem` file to
|
123
|
+
To release a new version, update the version number in `version.rb`, and then
|
124
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
125
|
+
push git commits and the created tag, and push the `.gem` file to
|
95
126
|
[rubygems.org](https://rubygems.org).
|
96
127
|
|
97
128
|
## Contributing
|
@@ -12,6 +12,11 @@ module JekyllAiRelatedPosts
|
|
12
12
|
@site = site
|
13
13
|
setup_database
|
14
14
|
|
15
|
+
@indexed_posts = {}
|
16
|
+
site.posts.docs.each do |p|
|
17
|
+
@indexed_posts[p.relative_path] = p
|
18
|
+
end
|
19
|
+
|
15
20
|
if fetch_enabled?
|
16
21
|
Jekyll.logger.info "[ai_related_posts] Generating related posts..."
|
17
22
|
@embeddings_fetcher = new_fetcher
|
@@ -20,11 +25,6 @@ module JekyllAiRelatedPosts
|
|
20
25
|
ensure_embedding_cached(p)
|
21
26
|
end
|
22
27
|
|
23
|
-
@indexed_posts = {}
|
24
|
-
site.posts.docs.each do |p|
|
25
|
-
@indexed_posts[p.relative_path] = p
|
26
|
-
end
|
27
|
-
|
28
28
|
@site.posts.docs.each do |p|
|
29
29
|
find_related(p)
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_ai_related_posts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kasberg
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7.
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '7.
|
26
|
+
version: '7.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|