Skip to main content

EasyAIPy allows extracting precise variables from AI API responses.

Project description

easyaiapi

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 easyaiapi

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: easyaipy-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3eb86e0c708d5d68019a0ffcce887ae7e5bbad32bc4b171a3979d4a6bcbe7a2d
MD5 66c614b9fce3af944e46dc88d2aeb18f
BLAKE2b-256 e5ec44898587f490022a953844ef04675bdf9c92eae56bc0f5aa0e9a4e257282

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easyaipy-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c239344497a957dd8095c06655f5e48c8bd53984c67404eb6c0f14b2120907c
MD5 4ee6137ef9cdea886eee22ccb35e2445
BLAKE2b-256 319a46ef92fbcad54ab88ca9f6e1c45bc27dff3d9ec2a81f6b7085152bba9ed2

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