0.1.1 • Published 1 year ago

sqlitegpt v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

SQLiteGPT

SQL function for SQLite to directly query OpenAI's ChatGPT.

CLI

Installation

npm install --global sqlitegpt

Usage

export OPENAI_API_KEY="sk-XXX"
sqlitegpt example.sqlite "SELECT gpt('Name of tallest mountain')"

Library Usage

import { sqliteGpt } from "sqlitegpt"

sqliteGpt(
  ":memory:",
  "SELECT gpt('Name of tallest mountain') as tallest_mountain"
)

sqliteGpt(
  "example.sqlite",
  `
    SELECT
      country,
      gpt('capital of ' || country || ', no explanation') as capital
    FROM users
  `
)

Known Issues

  • This implementation currently uses sync-request which forces HTTP requests to be synchronous. You should not use this in production! However, it's currently the only way to make it work with better-sqlite3.
  • It's only implemented as an application-defined SQL function and can therefore only be used in JavaScript projects. To make it work in every SQLite environment, it should be implemented as a loadable extension.

If you like SQLiteGPT, please star the project and I will re-implement it as a proper loadable extension in Rust with sqlite-loadable-rs.


0.1.1

1 year ago

0.1.0

1 year ago