Skip to main content

High-performance SDK to convert natural language prompts to MongoDB queries using AI (OpenAI GPT or Anthropic Claude)

Project description

Prompt to Query - Python SDK

High-performance Python SDK to convert natural language prompts to MongoDB queries using AI (OpenAI GPT or Anthropic Claude).

Installation

pip install prompt-to-query

Quick Start

from prompt_to_query import PromptToQuery

# Initialize the client
ptq = PromptToQuery(
    llm_provider="openai",
    api_key="your-api-key",
    db_schema_path="schema.json"
)

# Generate a MongoDB query from natural language
result = ptq.generate_query("Get all active users from last month")

print(result['query'])
# Output: {'operation': 'find', 'collection': 'users', 'filter': {...}}

print(result['columnTitles'])
# Output: ['User Name', 'Email', 'Status', 'Created At']

Features

  • 🚀 High Performance: Native Go library with Python bindings
  • 🔄 Cross-Platform: Supports Linux (glibc/musl), macOS (Intel/ARM), and Windows
  • 🎯 Zero External Dependencies: Uses only Python's standard library (ctypes)
  • 🤖 Multiple LLM Providers: OpenAI (GPT-4) and Anthropic (Claude)
  • 📊 Flexible Schema: JSON-based database schema definition
  • 📋 Column Titles: Returns human-readable column titles for query results

Supported Platforms

The package includes pre-built native libraries for:

  • Linux: x86_64 (glibc), x86_64 (musl/Alpine), ARM64 (glibc), ARM64 (musl/Alpine)
  • macOS: x86_64 (Intel), ARM64 (Apple Silicon)
  • Windows: x86_64

Documentation

For complete documentation, examples, and API reference, visit: https://github.com/dimarborda/prompt-to-query

Development

Building from Source

# Install dependencies
pip install -e .

# Build native libraries for current platform
python scripts/build-native.py

# Build for all platforms (requires Docker)
python scripts/build-native.py --all

Running Tests

pytest tests/

License

MIT License - see LICENSE file for details

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prompt_to_query-1.0.2.tar.gz (24.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prompt_to_query-1.0.2-py3-none-any.whl (24.9 MB view details)

Uploaded Python 3

File details

Details for the file prompt_to_query-1.0.2.tar.gz.

File metadata

  • Download URL: prompt_to_query-1.0.2.tar.gz
  • Upload date:
  • Size: 24.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for prompt_to_query-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c08c3902dd5f34c430a6fe919a14994d08008d14a4ef9584f29ee16d6e3cbb7f
MD5 6af0eff0c10e55d24c721c87fa31426e
BLAKE2b-256 bd103661039c10cd53eadf081fd5eae1c98e81085f6872c3f9e5dd1b795030a2

See more details on using hashes here.

File details

Details for the file prompt_to_query-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for prompt_to_query-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e9c4363a4f627ed2e8188250b21fb42ebe39f5ac8edadc9deeb5793c0e6eb73
MD5 e6ce6da7be82b333196733bb65010486
BLAKE2b-256 3f7a496d8cb93f7b5b72845e5b1a6ae4b1646780edb1cb2154382cb1da63b547

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page