Skip to main content

Python SDK for Semantic Equivalence API - optimize prompts for semantic equivalence

Project description

Semantic EQ SDK

This package provides a simple Python client for the Semantic EQ API.

Installation

pip install semantic-eq

Usage

from semantic_eq_sdk import SemanticEQ
import openai

# Initialize SemanticEQ client, compress your system prompt
seq_client = SemanticEQ(api_key="YOUR_SEMANTIC_EQ_API_KEY", system_prompt="<your-input-system-prompt>")

# Compress the original user prompt and system prompt
compressed = seq_client.compress_prompt(user_prompt="Your long and detailed prompt...")

# Call OpenAI's GPT-4 with the compressed prompt
openai.api_key = "YOUR_OPENAI_API_KEY"
response = openai.ChatCompletion.create(
    model="gpt-4o",  # or "gpt-4" if preferred
    messages=[
        {"role": "system", "content": compressed.compressed_system_prompt},
        {"role": "user", "content": compressed.compressed_user_prompt}
    ]
)

# Print the response from GPT-4
print(response["choices"][0]["message"]["content"])

Publishing a New Version (for Maintainers)

Publishing the SDK is handled by a script that automates the entire process.

Prerequisites:

  1. PyPI Account: You need an account on PyPI and an API token.
  2. Twine Configuration: Your local machine must be configured to authenticate with PyPI. You can do this by setting the TWINE_USERNAME and TWINE_PASSWORD environment variables.

To publish a new version:

  1. Navigate to the SDK directory: cd semantic_eq_sdk
  2. Run the publishing script. You have two options:
    • To automatically bump the patch version (e.g., 1.0.1 -> 1.0.2), run the script without arguments:
      ./publish_sdk.sh
      
    • To specify an exact version (e.g., for a major release like 2.0.0), provide it as an argument:
      ./publish_sdk.sh 2.0.0
      
  3. The script will handle everything else automatically.

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

semantic_eq-1.0.5.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

semantic_eq-1.0.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file semantic_eq-1.0.5.tar.gz.

File metadata

  • Download URL: semantic_eq-1.0.5.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for semantic_eq-1.0.5.tar.gz
Algorithm Hash digest
SHA256 7f653bc7818cb827f864afd5bc8e20ca6459484bf73a334495fd26d26c3aaa9a
MD5 a80e55920ca48e5f1d681d7028e7eb28
BLAKE2b-256 447da9e5e282c3b378ed9cba12a523cfc00772901a765fa0b7a80434c39e0b57

See more details on using hashes here.

File details

Details for the file semantic_eq-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: semantic_eq-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for semantic_eq-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ea9b0b18e1be2971925f121e9bd84380924dd8a06b4b6293f703dbcb26be7a7b
MD5 567585e07095cbeaaecd8822f9f17f79
BLAKE2b-256 68612c0737392f1f2227ef76c0fff7c1fb2aafc1a9d7a3fdde6980b7db0b9b58

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