Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

feat: add Albert API support #366

Merged
merged 1 commit into from
Jul 16, 2025
Merged

feat: add Albert API support #366

merged 1 commit into from
Jul 16, 2025

Conversation

OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Jun 30, 2025

Description

This PR adds support for Albert API, the French government's sovereign AI gateway. Albert provides an OpenAI-compatible API interface for various language models while ensuring data sovereignty and compliance with French/EU regulations.

Key Features

  • 🇫🇷 Sovereign AI: Albert is hosted and operated by the French government
  • 🔧 OpenAI-compatible: Uses the same API structure as OpenAI
  • 🔒 Data Privacy: Ensures data remains within French/EU jurisdiction
  • 🎯 Public Sector Focus: Designed for use by French public administration

Implementation Details

  • Created Albert-specific model clients (GPTModelClient and EmbeddingsModelClient) with configurable base URL
  • Added PlatformFactory for easy Albert API initialization
  • Reuses OpenAI's response converters for compatibility
  • Supports both chat completions and embeddings endpoints

Usage Example

use PhpLlm\LlmChain\Platform\Bridge\Albert\PlatformFactory;
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\GPT;

$platform = PlatformFactory::create(
    apiKey: $_ENV['ALBERT_API_KEY'],
    albertUrl: $_ENV['ALBERT_API_URL']
);

$model = new GPT('gpt-4o');
$chain = new Chain($platform, $model);

Testing

  • Added unit tests for PlatformFactory
  • Added example script demonstrating Albert API usage with RAG context
  • All tests pass and code follows project standards

Documentation

  • Updated README to list Albert as a supported platform
  • Added example file showing how to use Albert API
  • Included context about French AI strategy in the example

This implementation allows French public sector organizations to leverage LLM Chain while maintaining data sovereignty and regulatory compliance.

Closes #346

@OskarStark OskarStark changed the title feat: add Albert API support docs: add Albert API usage example Jun 30, 2025
@OskarStark OskarStark changed the title docs: add Albert API usage example feat: add Albert API support Jun 30, 2025
@chr-hertel chr-hertel marked this pull request as draft June 30, 2025 20:29
@OskarStark OskarStark force-pushed the feat/albert-api-support branch from eca9b78 to 8957546 Compare July 1, 2025 18:25
@OskarStark OskarStark marked this pull request as ready for review July 1, 2025 18:55
@chr-hertel
Copy link
Member

pipeline needs some attention @OskarStark - than we're good to merge I'd say

@OskarStark OskarStark force-pushed the feat/albert-api-support branch from 72fafcb to 3d3113d Compare July 16, 2025 06:26
@OskarStark OskarStark added the enhancement New feature or request label Jul 16, 2025
@OskarStark OskarStark force-pushed the feat/albert-api-support branch from 01542ed to 9d7c0e7 Compare July 16, 2025 09:23
@OskarStark OskarStark force-pushed the feat/albert-api-support branch 2 times, most recently from dab5368 to b197dce Compare July 16, 2025 09:35
@OskarStark OskarStark force-pushed the feat/albert-api-support branch from b197dce to a6370de Compare July 16, 2025 09:42
@OskarStark OskarStark force-pushed the feat/albert-api-support branch 4 times, most recently from 9d696a2 to cc3c51a Compare July 16, 2025 10:20
@OskarStark OskarStark force-pushed the feat/albert-api-support branch from cbb202d to ad8a9b4 Compare July 16, 2025 10:24
@OskarStark
Copy link
Contributor Author

Rebase, added tests, fixed CI, good to merge from my side

@chr-hertel chr-hertel force-pushed the feat/albert-api-support branch 3 times, most recently from a7bf629 to 3311ff2 Compare July 16, 2025 21:04

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
- Add Albert-specific model clients for OpenAI-compatible API
- Add PlatformFactory for easy Albert platform creation
- Add comprehensive unit tests for all components
- Require explicit API version in URL (e.g., /v1, /v2)
- Add strict URL validation (HTTPS required, no trailing slashes)
- Use plain PHP exception handling instead of external assertions
- Apply consistent code style and rector fixes
@chr-hertel chr-hertel force-pushed the feat/albert-api-support branch from 3311ff2 to 0bdf72a Compare July 16, 2025 21:15
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it green - merging it in now 👍

@chr-hertel chr-hertel merged commit 7c7ab2c into main Jul 16, 2025
7 checks passed
@chr-hertel chr-hertel deleted the feat/albert-api-support branch July 16, 2025 21:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using the Albert API model
2 participants