Skip to main content

EasyAIPy allows extracting precise variables from AI API responses.

Project description

easyaipy

EasyAIPy allows extracting precise variables from AI API responses. It is designed to interact with OpenAI and Gemini developer APIs. It allows programmers to specify the amount and the datatypes of variables they want to receive in their API response.

Installation

pip install easyaipy

A Simple Example with OpenAI API

from easyaipy import openai_easy_prompt

# Define or import your API key
api_key = "YOUR_API_KEY"

# Define the input prompt
prompt = "Generate a brief summary of the importance of AI in education."

# Specify an output schema (optional)
output_schema = {
    "summary": str,
    "word_count": int
}


response = openai_easy_prompt(
    prompt=prompt,
    model="gpt-4o-mini",
    output_schema=output_schema,
    max_retries=3,
    api_key=api_key
)

# Print the validated response
print("Response:", response)

Expected Output

If the OpenAI API responds correctly and matches the schema, the output will look like this:

{
    "summary": "AI in education enhances personalized learning, streamlines administrative tasks, and fosters innovation in teaching.",
    "word_count": 15
}

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

easyaipy-0.1.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

easyaipy-0.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file easyaipy-0.1.3.tar.gz.

File metadata

  • Download URL: easyaipy-0.1.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for easyaipy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e56c65d2b9e37874cf88b79c3556ca9db2e1c9e1d4ca83165e7c5cf19e36dd27
MD5 3261741f9646d0af776b139e0d6e20c4
BLAKE2b-256 24fd6f6cb7f9409dcc2cf29cb9213c0249e25a3bcb2077016d5d90455819bada

See more details on using hashes here.

File details

Details for the file easyaipy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: easyaipy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for easyaipy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ea91fd425981e73b1a5c079c441a81e5e1202f476e9b34228278eb20dd082d1f
MD5 31d36412e22e884d52385f2c336c53d6
BLAKE2b-256 0984faff3f8ce8e07da947d39bf160b676c47389accae6645d4c741449942cad

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