Provider Transcript Sanitizer (Model/ProviderTranscript.php)

synaplan · backend/src/Model/ProviderTranscript.php · php · Apache-2.0
ai, security, infra, lang:php

Creates sanitized LLM request transcripts with secrets removed and length caps enforced. Reuse when logging or auditing AI model prompts securely.

// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
<?php

declare(strict_types=1);

namespace App\Model;

/**
 * The text a provider was actually given for one request, with secrets removed
 * and a hard length cap. No I/O.
 */
final readonly class ProviderTranscript
{
    public const MAX_CHARS = 32000;

    /**
     * @param list<array{role: string, text: string}> $messages
     */
    private function __construct(
        private array $messages,
        private bool $truncated,
    ) {
    }

    /**
     * @param list<array<string, mixed>> $messages
     */
    public static function fromMessages(array $messages): self
    {
      

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key