Skip to main content

core-genai

A library that provides common utilities AI-related.


PyPI Downloads Python Versions License Pipeline Status Docs Status Security

Installation

pip install core-genai
uv pip install core-genai

Features

  • Unified agent interface: all providers share the same IAgent API: analyze, get_text, get_texts, get_cost, and get_metadata.

  • Multi-provider support: plug-and-play agents for:

    • Google Gemini (GeminiAgent)

    • Anthropic Claude (ClaudeAgent)

    • OpenAI ChatGPT (ChatGPTAgent)

    • xAI Grok (GrokAgent, inherits from ChatGPTAgent)

  • Async-first, sync-friendly: agents are natively async; wrap any agent with SyncWrapper from core-mixins for transparent synchronous access.

  • Normalized usage metadata: get_metadata() always returns a UsageMetadata TypedDict with consistent keys (input_tokens, output_tokens, total_tokens, cost_usd) plus provider-specific optional fields (cached_tokens, cache_creation_tokens, reasoning_tokens).

  • Built-in cost estimation: get_cost() computes the USD cost for any response using per-model pricing tables bundled with each agent.

  • Factory registration: agents are auto-registered by class name; instantiate any agent with IAgent.create_agent("GeminiAgent", api_key=...).

  • Lazy client initialization: the underlying SDK client is created only on first use, so importing an agent has no side effects.

  • Batch job support via IScheduler: Gemini, Claude, ChatGPT, and Grok all implement schedule_job, check_job_status, and extract_job_results for large-scale asynchronous inference at reduced cost. Users pass simple BatchRequest objects; the agents handle provider-specific serialization internally.

  • Normalized batch contracts: ScheduledJobMetadata and ScheduledJobResponse are defined once in base.py and shared across all providers, with a common job_id field and optional timing fields (start_time, end_time) for providers that expose them.

  • Prompt evaluation (core_genai.prompt): model-as-judge evaluation engine for comparing prompt versions. Generates synthetic test datasets, runs prompt functions concurrently via ThreadPoolExecutor, grades outputs against user-defined criteria, and renders an HTML report with per-case scores, strengths, weaknesses, and pass-rate statistics.

Quick Start

pip install core-genai
pip install -e ".[dev]"    # For development

Testing Across Python Versions

A helper script is included to run all functional tests against every virtual environment matching .venv* in the project root, making it easy to verify compatibility across Python versions (CPython and PyPy):

bash tests/run_all_venvs.sh

Each .venv* directory must already exist and have the package installed. The script iterates over every environment, runs all scripts under tests/functional/, prints the exit code for each, and moves on to the next.

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: python manager.py run-tests

  5. Run linting: pylint core_genai

  6. Run security checks: bandit -r core_genai

  7. Submit a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

Metadata

Release files for core-genai 1.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for core-genai 1.1.8
File Size Uploaded Provenance Actions
core_genai-1.1.8.tar.gz 26.2 kB With provenance Details for core_genai-1.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for core-genai 1.1.8
File Interpreter ABI Platform Actions
core_genai-1.1.8-py3-none-any.whl Python 3 none any Details for core_genai-1.1.8-py3-none-any.whl

Total release size: 55.6 kB

Release files / core_genai-1.1.8.tar.gz

Download URL core_genai-1.1.8.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1a38a710f77dbc037687d61517530c87b5efe668574011d4342673468ca76ed9
BLAKE2b-256 checksum
How to use checksums
d9341ade70f8033dfc56c90df5bae55053c819d67ca8928107fe8786a9792849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / core_genai-1.1.8-py3-none-any.whl

Download URL core_genai-1.1.8-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e92325728aa9f81397e76a608733a97e843db9a81c3f2197d3d42dbfcfcd40d4
BLAKE2b-256 checksum
How to use checksums
9875540516cba76c06abf2548a17d07db179c83f7cdc50d078276062ff180a43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.15.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 11, 2026.

Transparency log

Security for core-genai 1.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for core_genai-1.1.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page