Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| AIRequestLog | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models\FlyMsgAI; |
| 4 | |
| 5 | use App\Http\Models\Moloquent; |
| 6 | |
| 7 | /** |
| 8 | * Represents a logged AI API request. |
| 9 | * |
| 10 | * Stored in the `ai_request_logs` MongoDB collection. |
| 11 | * |
| 12 | * @property string $user_id The authenticated user's ID |
| 13 | * @property string|null $company_id The user's company ID (if applicable) |
| 14 | * @property string $feature Feature that triggered the request (engage_generate, post_generate, rewrite, check_sentences, persona_generate) |
| 15 | * @property string $provider AI provider used (vertex, gpt, claude, grok) |
| 16 | * @property string $model Model identifier (e.g. gemini-2.5-flash) |
| 17 | * @property string $prompt_input The full prompt sent to the AI |
| 18 | * @property string|null $prompt_output The AI-generated response text |
| 19 | * @property mixed|null $context Additional context data for the request |
| 20 | * @property string $status Request status: pending | success | error |
| 21 | * @property int|null $execution_duration_ms Total AI API execution time in milliseconds |
| 22 | * @property int $prompt_tokens Estimated or actual number of input tokens |
| 23 | * @property int $completion_tokens Estimated or actual number of output tokens |
| 24 | * @property int $total_tokens Total tokens (prompt + completion) |
| 25 | * @property float $estimated_cost_usd Estimated cost in USD based on token counts and model pricing |
| 26 | */ |
| 27 | class AIRequestLog extends Moloquent |
| 28 | { |
| 29 | protected $table = 'ai_request_logs'; |
| 30 | |
| 31 | protected $fillable = [ |
| 32 | 'user_id', |
| 33 | 'company_id', |
| 34 | 'feature', |
| 35 | 'provider', |
| 36 | 'model', |
| 37 | 'prompt_input', |
| 38 | 'prompt_output', |
| 39 | 'context', |
| 40 | 'status', |
| 41 | 'execution_duration_ms', |
| 42 | 'prompt_tokens', |
| 43 | 'completion_tokens', |
| 44 | 'total_tokens', |
| 45 | 'estimated_cost_usd', |
| 46 | ]; |
| 47 | |
| 48 | protected $casts = [ |
| 49 | 'execution_duration_ms' => 'integer', |
| 50 | 'prompt_tokens' => 'integer', |
| 51 | 'completion_tokens' => 'integer', |
| 52 | 'total_tokens' => 'integer', |
| 53 | 'estimated_cost_usd' => 'float', |
| 54 | 'created_at' => 'datetime', |
| 55 | 'updated_at' => 'datetime', |
| 56 | ]; |
| 57 | } |