-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_full_request.php
More file actions
63 lines (52 loc) · 2.59 KB
/
debug_full_request.php
File metadata and controls
63 lines (52 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once __DIR__ . '/vendor/autoload.php';
use App\Services\DeepSeekService;
use App\Services\Prompts\AIPrompts;
// Bootstrap Laravel
$app = require_once __DIR__ . '/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
try {
// Test with minimal content to see full request size
$minimalContent = "Hello world.";
echo "Minimal content: '$minimalContent'\n";
echo "Content length: " . strlen($minimalContent) . " characters\n";
echo "Content tokens: ~" . ceil(strlen($minimalContent) / 4) . "\n\n";
// Get the full prompt for study note
$fullPrompt = AIPrompts::studyNotePrompt($minimalContent, 'en');
echo "AIPrompts template length: " . strlen($fullPrompt) . " characters\n";
echo "AIPrompts template tokens: ~" . ceil(strlen($fullPrompt) / 4) . "\n\n";
// Simulate the system prompt (from DeepSeekService)
$systemPrompt = 'You are an expert educational content creator and study assistant. Your role is to transform raw content into comprehensive, detailed study materials that help students deeply understand complex topics. Always respond in valid JSON format with rich, educational content that demonstrates deep understanding and provides maximum learning value.';
echo "System prompt length: " . strlen($systemPrompt) . " characters\n";
echo "System prompt tokens: ~" . ceil(strlen($systemPrompt) / 4) . "\n\n";
// Calculate total request overhead
$totalOverhead = strlen($systemPrompt) + strlen($fullPrompt) - strlen($minimalContent);
echo "Total template overhead: " . $totalOverhead . " characters\n";
echo "Total template overhead tokens: ~" . ceil($totalOverhead / 4) . "\n\n";
// Simulate the complete request structure
$requestStructure = [
'model' => 'gpt-4o',
'messages' => [
[
'role' => 'system',
'content' => $systemPrompt
],
[
'role' => 'user',
'content' => $fullPrompt
]
],
'temperature' => 0.7,
'max_tokens' => 8000,
'response_format' => [
'type' => 'json_object'
]
];
$requestJson = json_encode($requestStructure, JSON_PRETTY_PRINT);
echo "Complete request JSON length: " . strlen($requestJson) . " characters\n";
echo "Complete request JSON tokens: ~" . ceil(strlen($requestJson) / 4) . "\n\n";
echo "Request structure preview (first 800 chars):\n";
echo substr($requestJson, 0, 800) . "...\n\n";
} catch (Exception $e) {
echo "❌ ERROR: " . $e->getMessage() . "\n";
}