Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/andriawan_rodadua-ai.json
T

1 line
6.7 KiB
JSON

{"repo": "andriawan/rodadua-ai", "files": {"backend/app/Services/Ai/Providers/DeepSeekProvider.php": {"d8890af857ac5fdf333a522a7199f37388255fc8": {"t": 1785746151.1458359, "n": 3146, "h": "0ad883d896b7ed70", "c": "<?php\n\nnamespace App\\Services\\Ai\\Providers;\n\nuse App\\Services\\Ai\\Contracts\\AiProviderInterface;\nuse OpenAI\\Client;\nuse OpenAI\\Factory;\n\nclass DeepSeekProvider implements AiProviderInterface\n{\n private Client $client;\n\n private string $model;\n\n private int $maxTokens;\n\n private float $temperature;\n\n public function __construct()\n {\n $config = config('services.deepseek');\n\n $this->client = (new Factory)\n ->withApiKey($config['api_key'] ?? '')\n ->withBaseUri($config['base_url'] ?? 'https://api.deepseek.com/v1')\n ->withHttpHeader('Authorization', 'Bearer '.($config['api_key'] ?? ''))\n ->make();\n\n $this->model = $config['model'] ?? 'deepseek-chat';\n $this->maxTokens = $config['max_tokens'] ?? 2000;\n $this->temperature = $config['temperature'] ?? 0.7;\n }\n\n public function chat(string $prompt, array $context = []): string\n {\n $messages = [];\n\n if (! empty($context)) {\n $messages[] = [\n 'role' => 'system',\n 'content' => $this->buildSystemMessage($context),\n ];\n }\n\n $messages[] = [\n 'role' => 'user',\n 'content' => $prompt,\n ];\n\n $response = $this->client->chat()->create([\n 'model' => $this->model,\n 'messages' => $messages,\n 'max_tokens' => $this->maxTokens,\n 'temperature' => $this->temperature,\n ]);\n\n return $response->choices[0]->message->content ?? '';\n }\n\n public function generateStructured(string $prompt, array $schema): array\n {\n $messages = [\n [\n 'role' => 'system',\n 'content' => 'You are a structured data generator. Respond only with valid JSON matching the requested schema.',\n ],\n [\n 'role' => 'user',\n 'content' => $prompt,\n ],\n ];\n\n $response = $this->client->chat()->create([\n 'model' => $this->model,\n 'messages' => $messages,\n 'max_tokens' => $this->maxTokens,\n 'temperature' => $this->temperature,\n 'response_format' => ['type' => 'json_object'],\n ]);\n\n $content = $response->choices[0]->message->content ?? '{}';\n\n return json_decode($content, true) ?? [];\n }\n\n private function buildSystemMessage(array $context): string\n {\n $parts = [\n 'You are a knowledgeable Indonesian motorcycle assistant.',\n 'Respond in Bahasa Indonesia unless otherwise specified.',\n 'Be specific to Indonesian motorcycle models, roads, and conditions.',\n ];\n\n if (isset($context['motorcycle'])) {\n $parts[] = sprintf(\n 'Motorcycle: %s %s (%d) with %d km odometer.',\n $context['motorcycle']['brand'] ?? '',\n $context['motorcycle']['model'] ?? '',\n $context['motorcycle']['year'] ?? 0,\n $context['motorcycle']['odometer_km'] ?? 0\n );\n }\n\n return implode(\"\\n\", $parts);\n }\n}\n"}, "3f1a0deb79f3b713135e71764a1e9bec135c053b": {"t": 1785760220.7559776, "n": 3150, "h": "b4b2c4ea5f6a35f9", "c": "<?php\n\nnamespace App\\Services\\Ai\\Providers;\n\nuse App\\Services\\Ai\\Contracts\\AiProviderInterface;\nuse OpenAI\\Client;\nuse OpenAI\\Factory;\n\nclass DeepSeekProvider implements AiProviderInterface\n{\n private Client $client;\n\n private string $model;\n\n private int $maxTokens;\n\n private float $temperature;\n\n public function __construct()\n {\n $config = config('services.deepseek');\n\n $this->client = (new Factory())\n ->withApiKey($config['api_key'] ?? '')\n ->withBaseUri($config['base_url'] ?? 'https://api.deepseek.com/v1')\n ->withHttpHeader('Authorization', 'Bearer ' . ($config['api_key'] ?? ''))\n ->make();\n\n $this->model = $config['model'] ?? 'deepseek-chat';\n $this->maxTokens = $config['max_tokens'] ?? 2000;\n $this->temperature = $config['temperature'] ?? 0.7;\n }\n\n public function chat(string $prompt, array $context = []): string\n {\n $messages = [];\n\n if (! empty($context)) {\n $messages[] = [\n 'role' => 'system',\n 'content' => $this->buildSystemMessage($context),\n ];\n }\n\n $messages[] = [\n 'role' => 'user',\n 'content' => $prompt,\n ];\n\n $response = $this->client->chat()->create([\n 'model' => $this->model,\n 'messages' => $messages,\n 'max_tokens' => $this->maxTokens,\n 'temperature' => $this->temperature,\n ]);\n\n return $response->choices[0]->message->content ?? '';\n }\n\n public function generateStructured(string $prompt, array $schema): array\n {\n $messages = [\n [\n 'role' => 'system',\n 'content' => 'You are a structured data generator. Respond only with valid JSON matching the requested schema.',\n ],\n [\n 'role' => 'user',\n 'content' => $prompt,\n ],\n ];\n\n $response = $this->client->chat()->create([\n 'model' => $this->model,\n 'messages' => $messages,\n 'max_tokens' => $this->maxTokens,\n 'temperature' => $this->temperature,\n 'response_format' => ['type' => 'json_object'],\n ]);\n\n $content = $response->choices[0]->message->content ?? '{}';\n\n return json_decode($content, true) ?? [];\n }\n\n private function buildSystemMessage(array $context): string\n {\n $parts = [\n 'You are a knowledgeable Indonesian motorcycle assistant.',\n 'Respond in Bahasa Indonesia unless otherwise specified.',\n 'Be specific to Indonesian motorcycle models, roads, and conditions.',\n ];\n\n if (isset($context['motorcycle'])) {\n $parts[] = sprintf(\n 'Motorcycle: %s %s (%d) with %d km odometer.',\n $context['motorcycle']['brand'] ?? '',\n $context['motorcycle']['model'] ?? '',\n $context['motorcycle']['year'] ?? 0,\n $context['motorcycle']['odometer_km'] ?? 0\n );\n }\n\n return implode(\"\\n\", $parts);\n }\n}\n"}}}}