wishful-search  by hrishioa

Natural language search module for JSON arrays, with AI Quickstart

created 1 year ago
408 stars

Top 72.5% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

WishfulSearch enables natural language querying of JSON arrays, transforming complex questions into SQL queries for an embedded SQLite database. It's designed for developers needing to filter and retrieve data from structured JSON without writing manual query logic, offering a flexible, multi-model LLM approach.

How It Works

The core mechanism involves converting JSON objects into relational tables within an sql.js SQLite database. An AI Quickstart feature analyzes a single JSON object to automatically generate the necessary DDL schema, object-to-relational mapping functions, and few-shot examples for LLM prompting. User queries are then enriched with context (schema, data samples, history) and sent to an LLM (GPT, Claude, Mistral) to generate SQL queries, which are executed against the database.

Quick Start & Requirements

  • Installation: npm i wishful-search (server-side), or use the bundled wishfulsearch.js (client-side).
  • Prerequisites: LLM API keys (OpenAI, Anthropic, or Ollama for Mistral). For client-side use, a sql.js WASM file URL is required.
  • Demo: Kaggle movies dataset example requires downloading movies_metadata.csv and running tests/movies.run.ts.
  • Docs: AI Quickstart, Search

Highlighted Details

  • AI Quickstart: Generates schema, data mapping, and few-shot examples from a single JSON object.
  • Multi-model Support: Adapters for OpenAI, Anthropic, and Ollama (Mistral).
  • Dynamic Enums: Automatically generates or infers example values for columns to improve LLM context.
  • Search History: Maintains conversational context for follow-up questions.

Maintenance & Community

This project is primarily maintained by a single developer. Community contributions for testing and development are welcomed.

Licensing & Compatibility

  • License: Apache 2.0.
  • Compatibility: Suitable for commercial use. The single production dependency is sql.js.

Limitations & Caveats

The project is marked as being for educational purposes and to be used at the user's own risk. Robust tests are noted as missing, and client-side testing is limited. Security is a concern, as LLM-generated queries can never be fully safe, and the system is best used where full database exposure isn't a security risk.

Health Check
Last commit

1 year ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
13 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.