Skip to main content

Python SDK for PromptQL Natural Language API

Project description

PromptQL Natural Language API SDK for Python

A Python SDK for interacting with the PromptQL Natural Language API.

Installation

pip install promptql-api-sdk

Or with Poetry:

poetry add promptql-api-sdk

Features

  • Full support for the PromptQL Natural Language API
  • Type-safe interface with Pydantic models
  • Support for streaming responses
  • Conversation management
  • Support for all LLM providers (Hasura, Anthropic, OpenAI)

Quick Start

from promptql_api_sdk import PromptQLClient
from promptql_api_sdk.types.models import HasuraLLMProvider

# Initialize the client
client = PromptQLClient(
    api_key="your-promptql-api-key",
    ddn_url="your-ddn-url",
    llm_provider=HasuraLLMProvider(),
    timezone="America/Los_Angeles",
)

# Send a simple query
response = client.query("What is the average temperature in San Francisco?")
print(response.assistant_actions[0].message)

# Use streaming for real-time responses
for chunk in client.query("Tell me about the weather in New York", stream=True):
    if hasattr(chunk, "message") and chunk.message:
        print(chunk.message, end="", flush=True)

Conversation Management

The SDK provides a Conversation class to help manage multi-turn conversations:

# Create a conversation
conversation = client.create_conversation(
    system_instructions="You are a helpful assistant that provides weather information."
)

# Send messages in the conversation
response = conversation.send_message("What's the weather like in London?")
print(response.message)

# Send a follow-up message
response = conversation.send_message("How about tomorrow?")
print(response.message)

# Get all artifacts created during the conversation
artifacts = conversation.get_artifacts()

LLM Provider Configuration

The SDK supports multiple LLM providers:

from promptql_api_sdk.types.models import HasuraLLMProvider, AnthropicLLMProvider, OpenAILLMProvider

# Hasura (default)
hasura_provider = HasuraLLMProvider()

# Anthropic
anthropic_provider = AnthropicLLMProvider(api_key="your-anthropic-api-key")

# OpenAI
openai_provider = OpenAILLMProvider(api_key="your-openai-api-key")

# Use with the client
client = PromptQLClient(
    api_key="your-promptql-api-key",
    ddn_url="your-ddn-url",
    llm_provider=anthropic_provider,
)

Error Handling

from promptql_api_sdk import PromptQLClient
from promptql_api_sdk.exceptions import PromptQLAPIError

client = PromptQLClient(...)

try:
    response = client.query("What is the weather like?")
except PromptQLAPIError as e:
    print(f"API Error: {e}")

License

MIT

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

promptql_api_sdk-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

promptql_api_sdk-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file promptql_api_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: promptql_api_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Linux/6.14.2-arch1-1

File hashes

Hashes for promptql_api_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 815d88461a265b5a9962e42d5619ee59e122dd4774096f02d06b9549aea8396a
MD5 6f9d2cf1b57e5619bcf71ed5454f1db2
BLAKE2b-256 2643914c0c889bec2f758624f3ec46bb17e4322384866a1992b10109f3c5ef40

See more details on using hashes here.

File details

Details for the file promptql_api_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: promptql_api_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Linux/6.14.2-arch1-1

File hashes

Hashes for promptql_api_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54533115cfbcf9e124165831382116f6206a4fcac7c2acd0667d5f55636f6469
MD5 d96c17dc95c1403c5ebaeb01ca1279cc
BLAKE2b-256 1988bead38b67d311c9cbe9350fe7060b30b26bb561f3b8f1def11cb9ae47eaa

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