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.1.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.1-py3-none-any.whl (24.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prompt_to_query-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7c31456052f997285e95387735f2308f0a9968107287c2d37517f6e3258e9715
MD5 6f06b86675d1eaff0072cee526d4580a
BLAKE2b-256 04c3a5edecc024eb72e4d6462b3817414359b2c8515bc505a6718b6e8e9686e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prompt_to_query-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b29293409f09ad7fbc536f4c2c8d3caddf0611455870353805c0e443788e4a2a
MD5 fca7611d9230276c94189ee299f7585c
BLAKE2b-256 e74df1882965c95b5c57abf71619c93b3e14e9c50036dbb86dca4315601be6bd

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