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.2.tar.gz (3.8 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.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easyaipy-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 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.2.tar.gz
Algorithm Hash digest
SHA256 63fee83dc8a1baf287d081226364917fa65eeb86dfb938b15e431aa87e82b1c2
MD5 d826491f3a1d749ca4222060dfae44cd
BLAKE2b-256 9017cc0c54aaa5e62e885d943799ca8c1beddaa3a5f565c250aa6664dc4f10d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easyaipy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f612903014d6f4af02e8583e298cae0a0d5aaf913db6cd83ded07578961d7de
MD5 27c5d6338ad1895f1ea8aebdfbcc2446
BLAKE2b-256 46d8acc3783a68caab4576cbf38fc21630ac776d030d37ac286d999921c9b4c1

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