Skip to main content

A library that provides common utilities AI-related.

Project description

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

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

core_genai-1.1.2.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

core_genai-1.1.2-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file core_genai-1.1.2.tar.gz.

File metadata

  • Download URL: core_genai-1.1.2.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for core_genai-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e279709fd81348f3ec56712c5e740ff7a80f4186d64ae688333317134744db1e
MD5 b4dc116b6e17d712a9444139cc58a22e
BLAKE2b-256 1ac1b9169b4e7dcafa7cee5540b5be6e8e2f04735135060beb799df8e422d0f4

See more details on using hashes here.

File details

Details for the file core_genai-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: core_genai-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for core_genai-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1595f84be79cb5266d58f0afbe76257590ab6fe4754c43f81ae37b90b739a6dc
MD5 7a194ced1f17cf76cdc63fba84047478
BLAKE2b-256 0d895d96efe51ef98dbfb4dce5e50cd4103cf3a348a3b07f5bc99011f99e75d5

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