Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/atfastrslushymaker_wamiago-webapp.json

1 line
12 KiB
JSON

{"repo": "atfastrslushymaker/wamiago-webapp", "files": {"src/Service/DeepSeekService.php": {"3685a6fff948460a986d9fc5df418b5b2a81c8c0": {"t": 1785746166.3079536, "n": 3886, "h": "2a3e373c8284a3e1", "c": "<?php\n\nnamespace App\\Service;\n\nuse App\\Entity\\Trip;\nuse Symfony\\Contracts\\HttpClient\\HttpClientInterface;\nuse Psr\\Log\\LoggerInterface;\n\nclass DeepSeekService\n{\n private string $apiUrl;\n private HttpClientInterface $httpClient;\n private LoggerInterface $logger;\n public string $apiKey;\n private int $timeout;\n\n public function __construct(\n HttpClientInterface $httpClient,\n LoggerInterface $logger,\n string $apiKey= \"sk-856cd7686cd94dfca0570b605d453812 \",\n string $apiUrl = 'https://api.deepseek.com/v1/chat/completions',\n int $timeout = 10\n ) {\n $this->httpClient = $httpClient;\n $this->logger = $logger;\n $this->apiKey = $apiKey;\n $this->apiUrl = $apiUrl;\n $this->timeout = $timeout;\n }\n public function predictPrice(Trip $trip): ?float\n{\n if (empty($this->apiKey)) {\n $this->logger->error('DeepSeek API key is missing.');\n return null;\n }\n\n $departureCity = $trip->getDepartureCity();\n $arrivalCity = $trip->getArrivalCity();\n $availableSeats = $trip->getAvailableSeats();\n\n $this->logger->info('Sending price prediction request to DeepSeek', [\n 'departure' => $departureCity,\n 'arrival' => $arrivalCity,\n 'seats' => $availableSeats,\n ]);\n\n $prompt = \"Estime un prix pour un trajet entre $departureCity et $arrivalCity avec $availableSeats places disponibles. \" .\n \"Considère la distance et la demande pour donner un prix précis.\";\n\n try {\n $response = $this->httpClient->request('POST', $this->apiUrl, [\n 'headers' => [\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' . $this->apiKey,\n 'Accept' => 'application/json',\n ],\n 'json' => [\n 'model' => 'deepseek-chat',\n 'messages' => [\n [\n 'role' => 'system',\n 'content' => 'You are a price prediction assistant. Respond only with a decimal number representing the estimated price.'\n ],\n [\n 'role' => 'user',\n 'content' => $prompt\n ]\n ],\n 'temperature' => 0.7,\n 'max_tokens' => 10,\n ],\n 'timeout' => $this->timeout,\n ]);\n\n $statusCode = $response->getStatusCode();\n $content = $response->toArray(false);\n\n if ($statusCode === 503) {\n $this->logger->error('DeepSeek API is unavailable', [\n 'status' => $statusCode,\n 'response' => $content,\n ]);\n throw new \\RuntimeException('The prediction service is temporarily unavailable');\n }\n\n if ($statusCode === 429) {\n $this->logger->error('Rate limit exceeded for DeepSeek API');\n throw new \\RuntimeException('Too many requests. Please try again later');\n }\n\n if ($statusCode !== 200) {\n $this->logger->error('DeepSeek API error', [\n 'status' => $statusCode,\n 'response' => $content,\n ]);\n throw new \\RuntimeException('Prediction service returned an error');\n }\n\n if (isset($content['choices'][0]['message']['content'])) {\n $price = (float) $content['choices'][0]['message']['content'];\n return $price;\n } else {\n $this->logger->error('Invalid response format from DeepSeek API', [\n 'response' => $content,\n ]);\n return null;\n }\n } catch (\\Exception $e) {\n $this->logger->error('DeepSeek API call failed', [\n 'exception' => $e->getMessage(),\n 'trace' => $e->getTraceAsString(),\n ]);\n return null;\n }\n}\n\n\n\n\n}"}, "937d622abc534a5cab77aa965edece63facb0872": {"t": 1785760294.4478352, "n": 3886, "h": "2a3e373c8284a3e1", "c": "<?php\n\nnamespace App\\Service;\n\nuse App\\Entity\\Trip;\nuse Symfony\\Contracts\\HttpClient\\HttpClientInterface;\nuse Psr\\Log\\LoggerInterface;\n\nclass DeepSeekService\n{\n private string $apiUrl;\n private HttpClientInterface $httpClient;\n private LoggerInterface $logger;\n public string $apiKey;\n private int $timeout;\n\n public function __construct(\n HttpClientInterface $httpClient,\n LoggerInterface $logger,\n string $apiKey= \"sk-856cd7686cd94dfca0570b605d453812 \",\n string $apiUrl = 'https://api.deepseek.com/v1/chat/completions',\n int $timeout = 10\n ) {\n $this->httpClient = $httpClient;\n $this->logger = $logger;\n $this->apiKey = $apiKey;\n $this->apiUrl = $apiUrl;\n $this->timeout = $timeout;\n }\n public function predictPrice(Trip $trip): ?float\n{\n if (empty($this->apiKey)) {\n $this->logger->error('DeepSeek API key is missing.');\n return null;\n }\n\n $departureCity = $trip->getDepartureCity();\n $arrivalCity = $trip->getArrivalCity();\n $availableSeats = $trip->getAvailableSeats();\n\n $this->logger->info('Sending price prediction request to DeepSeek', [\n 'departure' => $departureCity,\n 'arrival' => $arrivalCity,\n 'seats' => $availableSeats,\n ]);\n\n $prompt = \"Estime un prix pour un trajet entre $departureCity et $arrivalCity avec $availableSeats places disponibles. \" .\n \"Considère la distance et la demande pour donner un prix précis.\";\n\n try {\n $response = $this->httpClient->request('POST', $this->apiUrl, [\n 'headers' => [\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' . $this->apiKey,\n 'Accept' => 'application/json',\n ],\n 'json' => [\n 'model' => 'deepseek-chat',\n 'messages' => [\n [\n 'role' => 'system',\n 'content' => 'You are a price prediction assistant. Respond only with a decimal number representing the estimated price.'\n ],\n [\n 'role' => 'user',\n 'content' => $prompt\n ]\n ],\n 'temperature' => 0.7,\n 'max_tokens' => 10,\n ],\n 'timeout' => $this->timeout,\n ]);\n\n $statusCode = $response->getStatusCode();\n $content = $response->toArray(false);\n\n if ($statusCode === 503) {\n $this->logger->error('DeepSeek API is unavailable', [\n 'status' => $statusCode,\n 'response' => $content,\n ]);\n throw new \\RuntimeException('The prediction service is temporarily unavailable');\n }\n\n if ($statusCode === 429) {\n $this->logger->error('Rate limit exceeded for DeepSeek API');\n throw new \\RuntimeException('Too many requests. Please try again later');\n }\n\n if ($statusCode !== 200) {\n $this->logger->error('DeepSeek API error', [\n 'status' => $statusCode,\n 'response' => $content,\n ]);\n throw new \\RuntimeException('Prediction service returned an error');\n }\n\n if (isset($content['choices'][0]['message']['content'])) {\n $price = (float) $content['choices'][0]['message']['content'];\n return $price;\n } else {\n $this->logger->error('Invalid response format from DeepSeek API', [\n 'response' => $content,\n ]);\n return null;\n }\n } catch (\\Exception $e) {\n $this->logger->error('DeepSeek API call failed', [\n 'exception' => $e->getMessage(),\n 'trace' => $e->getTraceAsString(),\n ]);\n return null;\n }\n}\n\n\n\n\n}"}, "aa41936be488947d681355b8ba3ff90415010a7f": {"t": 1785760296.5428238, "n": 3420, "h": "57c9ca39dafeba6a", "c": "<?php\n\nnamespace App\\Service;\n\nuse App\\Entity\\Trip;\nuse Symfony\\Contracts\\HttpClient\\HttpClientInterface;\nuse Psr\\Log\\LoggerInterface;\n\nclass DeepSeekService\n{\n private string $apiUrl;\n private HttpClientInterface $httpClient;\n private LoggerInterface $logger;\n public string $apiKey;\n private int $timeout;\n\n public function __construct(\n HttpClientInterface $httpClient,\n LoggerInterface $logger,\n string $apiKey,\n string $apiUrl = 'https://api.deepseek.com/v1/chat/completions',\n int $timeout = 10\n ) {\n $this->httpClient = $httpClient;\n $this->logger = $logger;\n $this->apiKey = $apiKey;\n $this->apiUrl = $apiUrl;\n $this->timeout = $timeout;\n }\n\n public function predictPrice(Trip $trip): ?float\n {\n if (empty($this->apiKey)) {\n $this->logger->error('DeepSeek API key is missing.');\n return null;\n }\n\n $departureCity = $trip->getDepartureCity();\n $arrivalCity = $trip->getArrivalCity();\n $availableSeats = $trip->getAvailableSeats();\n\n $this->logger->info('Sending price prediction request to DeepSeek', [\n 'departure' => $departureCity,\n 'arrival' => $arrivalCity,\n 'seats' => $availableSeats,\n ]);\n\n $prompt = \"Estime un prix pour un trajet entre $departureCity et $arrivalCity avec $availableSeats places disponibles. \" .\n \"Considère la distance et la demande pour donner un prix précis.\";\n\n try {\n $response = $this->httpClient->request('POST', $this->apiUrl, [\n 'headers' => [\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' . $this->apiKey,\n ],\n 'json' => [\n 'model' => 'deepseek-chat',\n 'messages' => [\n [\n 'role' => 'system',\n 'content' => 'Tu es un assistant qui prédit les prix de trajets. Réponds uniquement avec un nombre décimal représentant le prix.'\n ],\n [\n 'role' => 'user',\n 'content' => $prompt\n ]\n ],\n ],\n 'timeout' => $this->timeout,\n ]);\n\n $statusCode = $response->getStatusCode();\n if ($statusCode !== 200) {\n $this->logger->error('DeepSeek API returned an error', [\n 'statusCode' => $statusCode,\n 'response' => $response->getContent(false),\n ]);\n return null;\n }\n\n $content = $response->toArray();\n $price = $content['choices'][0]['message']['content'] ?? null;\n\n if (is_numeric($price)) {\n $this->logger->info('Successfully retrieved price from DeepSeek', ['price' => $price]);\n return round((float) $price, 2);\n }\n\n $this->logger->warning('Invalid price format received from DeepSeek', ['response' => $content]);\n return null;\n } catch (\\Exception $e) {\n $this->logger->error('Error during DeepSeek API call', [\n 'exception' => $e->getMessage(),\n ]);\n return null;\n }\n }\n}"}}}}