|
@@ -11,6 +11,12 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+/** Extract text from a PDF file using pdftotext command line tool.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $file Path to the PDF file.
|
|
|
|
|
+ * @return string Extracted text from the PDF.
|
|
|
|
|
+ */
|
|
|
function extractPdfText($file) {
|
|
function extractPdfText($file) {
|
|
|
$tmp = tempnam(sys_get_temp_dir(), 'pdftext');
|
|
$tmp = tempnam(sys_get_temp_dir(), 'pdftext');
|
|
|
exec("pdftotext " . escapeshellarg($file) . " " . escapeshellarg($tmp));
|
|
exec("pdftotext " . escapeshellarg($file) . " " . escapeshellarg($tmp));
|
|
@@ -19,7 +25,7 @@ function extractPdfText($file) {
|
|
|
return $text ?: '';
|
|
return $text ?: '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// ### Build prompt for deepseek
|
|
|
|
|
|
|
+// Build prompt for deepseek
|
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
|
$question = isset($input['question']) ? $input['question'] : '';
|
|
$question = isset($input['question']) ? $input['question'] : '';
|
|
|
$roleFile = __DIR__ . '/data/role.txt';
|
|
$roleFile = __DIR__ . '/data/role.txt';
|
|
@@ -31,6 +37,7 @@ $contextText = "";
|
|
|
foreach ($rows as $row) {
|
|
foreach ($rows as $row) {
|
|
|
$contextText .= "- " . implode(" | ", $row) . "\n";
|
|
$contextText .= "- " . implode(" | ", $row) . "\n";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
$pdf1 = extractPdfText(__DIR__ . '/data/pdf/onboarding.pdf');
|
|
$pdf1 = extractPdfText(__DIR__ . '/data/pdf/onboarding.pdf');
|
|
|
$pdf2 = extractPdfText(__DIR__ . '/data/pdf/urlaub.pdf');
|
|
$pdf2 = extractPdfText(__DIR__ . '/data/pdf/urlaub.pdf');
|
|
|
|
|
|