A library that provides common utilities AI-related.
Project description
core-genai
A library that provides common utilities AI-related.
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.
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:
Fork the repository
Create a feature branch
Write tests for new functionality
Ensure all tests pass: python manager.py run-tests
Run linting: pylint core_genai
Run security checks: bandit -r core_genai
Submit a pull request
License
This project is licensed under the MIT License. See the LICENSE file for details.
Links
Support
For questions or support, please open an issue on GitLab or contact the maintainers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file core_genai-1.0.0.tar.gz.
File metadata
- Download URL: core_genai-1.0.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d2f5796c27f8a998f3b413beafd4aa314ebac103a9401419c34f8a465c43be
|
|
| MD5 |
edb21fa1a8bce84e5aab0df3e90d8ab9
|
|
| BLAKE2b-256 |
afe9cdc32549430f7f0116a8ba48ebff6db0608936e653b10b66f35843a3fa93
|
File details
Details for the file core_genai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: core_genai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ef5b9543d666e2b93e33098d92c22d360633b0e7799edcd55430be607b2e958
|
|
| MD5 |
bbbcd225182357a965dedf295503c8bf
|
|
| BLAKE2b-256 |
b2a51e2e2c70fbfe58f0c180685ef69d38c573740806096893601814b7fe59f8
|