Skip to content

Add sqlite-vec support #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

CarlQLange
Copy link

This PR adds some support for sqlite-vec.

Unfortunately I am brand new to Ruby so there was plenty of help from professor ChatGPT, so I would strongly recommend a close inspection to make sure I got things right. Having said that, the example script appears to work on my machine. I hope if nothing else that this may be a useful starting point to add SQLite support to this library.

@@ -15,7 +15,12 @@ class VersionError < ScriptError; end
# @raise [VersionError] If the gem is installed, but the version does not meet the requirements
#
def depends_on(gem_name, req: true)
gem(gem_name) # require the gem
if gem_name == "sqlite_vec"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarlQLange Why is this if/else statement needed? Isn't the gem version what gets required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woof, I have no memory of this. I think it was something to do with using the gem locally from something else. Sorry, I pretty much have no idea what I was doing back then!

# @return [Array<Integer>] The ids of the added texts
def add_texts(texts:, ids: nil)
if ids.nil? || ids.empty?
max_rowid = @db.execute("SELECT MAX(rowid) FROM #{table_name}").first.first || 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the rowid auto increment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants