deepseek-request.php 907 B

1234567891011121314151617181920212223242526
  1. <?php
  2. $frage = isset($_POST['frage']) ? $_POST['frage'] : '';
  3. $kontext = isset($_POST['kontext']) ? $_POST['kontext'] : '';
  4. $prompt = "Du bist ein HR-Bot. Antworte ausschließlich basierend auf dem folgenden Kontext:\n\n" . $kontext . "\n\nFrage: " . $frage . "\nAntwort:";
  5. $payload = json_encode(array(
  6. "model" => "deepseek-r1",
  7. "prompt" => $prompt,
  8. "stream" => false
  9. ));
  10. $ch = curl_init('http://localhost:11434/api/generate');
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  12. curl_setopt($ch, CURLOPT_POST, true);
  13. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  15. $response = curl_exec($ch);
  16. curl_close($ch);
  17. $data = json_decode($response, true);
  18. $antwort = isset($data['response']) ? $data['response'] : 'Fehler bei DeepSeek';
  19. echo "<h3>Antwort vom HR-Bot:</h3><pre>" . htmlspecialchars($antwort) . "</pre>";