{"repo": "cd-cejas/thesis", "files": {"lib/deepseek_service.dart": {"fdcafe7eb728df5c17b972fc3cd4050953955738": {"t": 1785745913.6045692, "n": 3883, "h": "689e92fe117e756d", "c": "import 'dart:convert';\nimport 'package:http/http.dart' as http;\n\n// Built-in DeepSeek API key — can be overridden via\n// --dart-define=DEEPSEEK_API_KEY=your_key at build/run time.\nconst String _kDeepSeekApiKey = String.fromEnvironment(\n 'DEEPSEEK_API_KEY',\n defaultValue: 'sk-5c3de2bbc15c4931bf33ac6a152db767',\n);\n\nclass DeepSeekService {\n DeepSeekService({http.Client? client, String? apiKey})\n : _client = client ?? http.Client(),\n _apiKey = apiKey ?? _kDeepSeekApiKey;\n\n final http.Client _client;\n final String _apiKey;\n\n static const String _endpoint = 'https://api.deepseek.com/chat/completions';\n\n // System prompt to set the AI's role\n static const String systemPrompt =\n 'You are an AI Career Guidance Assistant for Filipino students. '\n 'You help students discover suitable careers, college courses, and universities '\n 'in the Philippines based on their interests, skills, and RIASEC results. '\n 'Keep responses concise, friendly, and informative. '\n 'When discussing salaries, use Philippine Peso (₱). '\n 'Focus on actionable advice and encourage students in their career exploration. '\n 'Use official Philippine School official websites for reference when suggesting courses/programs and universities.'\n 'IMPORTANT FORMATTING RULES: Do NOT use asterisks (*) or hashtags (#) in your responses. '\n 'For emphasis, use Flutter-renderable bold formatting only — never markdown asterisks. ';\n\n /// Sends a message to DeepSeek API with full conversation history.\n /// Returns the assistant's reply or an error message prefixed with \"Error:\".\n Future sendMessage(List> messageHistory) async {\n if (_apiKey.isEmpty) {\n return 'Error: Missing DeepSeek API key. Provide --dart-define=DEEPSEEK_API_KEY=your_key when building the app.';\n }\n\n try {\n final response = await _client\n .post(\n Uri.parse(_endpoint),\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer $_apiKey',\n },\n body: jsonEncode({\n 'model': 'deepseek-chat',\n 'messages': messageHistory,\n 'temperature': 0.7,\n 'max_tokens': 1024,\n }),\n )\n .timeout(const Duration(seconds: 30));\n\n if (response.statusCode == 200) {\n final data = jsonDecode(response.body);\n final choices = data['choices'] as List?;\n if (choices != null && choices.isNotEmpty) {\n final raw =\n choices[0]['message']['content'] as String? ??\n 'No response received.';\n return _cleanResponse(raw);\n }\n return 'Error: Empty response from AI.';\n } else if (response.statusCode == 401) {\n return 'Error: Invalid API key. Please check your DeepSeek API key.';\n } else if (response.statusCode == 429) {\n return 'Error: Too many requests. Please wait a moment and try again.';\n } else {\n return 'Error: Server returned status ${response.statusCode}. Please try again.';\n }\n } on http.ClientException catch (e) {\n return 'Error: Connection failed. Please check your internet connection. ($e)';\n } catch (e) {\n if (e.toString().contains('TimeoutException')) {\n return 'Error: Request timed out. Please try again.';\n }\n return 'Error: Something went wrong. Please try again. ($e)';\n }\n }\n\n void dispose() => _client.close();\n\n /// Strips markdown asterisks and replaces & with 'and'\n /// so responses render cleanly in plain Flutter Text widgets.\n String _cleanResponse(String text) {\n return text\n .replaceAll('***', '')\n .replaceAll('**', '')\n .replaceAll('*', '')\n .replaceAll('###', '')\n .replaceAll('##', '')\n .replaceAll('#', '')\n .trim();\n }\n}\n"}, "cbc9282cca7be376d2142d68a07154fb1e7ceb58": {"t": 1785757863.9770393, "n": 3883, "h": "689e92fe117e756d", "c": "import 'dart:convert';\nimport 'package:http/http.dart' as http;\n\n// Built-in DeepSeek API key — can be overridden via\n// --dart-define=DEEPSEEK_API_KEY=your_key at build/run time.\nconst String _kDeepSeekApiKey = String.fromEnvironment(\n 'DEEPSEEK_API_KEY',\n defaultValue: 'sk-5c3de2bbc15c4931bf33ac6a152db767',\n);\n\nclass DeepSeekService {\n DeepSeekService({http.Client? client, String? apiKey})\n : _client = client ?? http.Client(),\n _apiKey = apiKey ?? _kDeepSeekApiKey;\n\n final http.Client _client;\n final String _apiKey;\n\n static const String _endpoint = 'https://api.deepseek.com/chat/completions';\n\n // System prompt to set the AI's role\n static const String systemPrompt =\n 'You are an AI Career Guidance Assistant for Filipino students. '\n 'You help students discover suitable careers, college courses, and universities '\n 'in the Philippines based on their interests, skills, and RIASEC results. '\n 'Keep responses concise, friendly, and informative. '\n 'When discussing salaries, use Philippine Peso (₱). '\n 'Focus on actionable advice and encourage students in their career exploration. '\n 'Use official Philippine School official websites for reference when suggesting courses/programs and universities.'\n 'IMPORTANT FORMATTING RULES: Do NOT use asterisks (*) or hashtags (#) in your responses. '\n 'For emphasis, use Flutter-renderable bold formatting only — never markdown asterisks. ';\n\n /// Sends a message to DeepSeek API with full conversation history.\n /// Returns the assistant's reply or an error message prefixed with \"Error:\".\n Future sendMessage(List> messageHistory) async {\n if (_apiKey.isEmpty) {\n return 'Error: Missing DeepSeek API key. Provide --dart-define=DEEPSEEK_API_KEY=your_key when building the app.';\n }\n\n try {\n final response = await _client\n .post(\n Uri.parse(_endpoint),\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer $_apiKey',\n },\n body: jsonEncode({\n 'model': 'deepseek-chat',\n 'messages': messageHistory,\n 'temperature': 0.7,\n 'max_tokens': 1024,\n }),\n )\n .timeout(const Duration(seconds: 30));\n\n if (response.statusCode == 200) {\n final data = jsonDecode(response.body);\n final choices = data['choices'] as List?;\n if (choices != null && choices.isNotEmpty) {\n final raw =\n choices[0]['message']['content'] as String? ??\n 'No response received.';\n return _cleanResponse(raw);\n }\n return 'Error: Empty response from AI.';\n } else if (response.statusCode == 401) {\n return 'Error: Invalid API key. Please check your DeepSeek API key.';\n } else if (response.statusCode == 429) {\n return 'Error: Too many requests. Please wait a moment and try again.';\n } else {\n return 'Error: Server returned status ${response.statusCode}. Please try again.';\n }\n } on http.ClientException catch (e) {\n return 'Error: Connection failed. Please check your internet connection. ($e)';\n } catch (e) {\n if (e.toString().contains('TimeoutException')) {\n return 'Error: Request timed out. Please try again.';\n }\n return 'Error: Something went wrong. Please try again. ($e)';\n }\n }\n\n void dispose() => _client.close();\n\n /// Strips markdown asterisks and replaces & with 'and'\n /// so responses render cleanly in plain Flutter Text widgets.\n String _cleanResponse(String text) {\n return text\n .replaceAll('***', '')\n .replaceAll('**', '')\n .replaceAll('*', '')\n .replaceAll('###', '')\n .replaceAll('##', '')\n .replaceAll('#', '')\n .trim();\n }\n}\n"}, "ad09e992175abb7008cca7a69415844afa28fec9": {"t": 1785757865.4189773, "n": 2566, "h": "479601a3e0061fa8", "c": "import 'dart:convert';\nimport 'package:http/http.dart' as http;\n\nclass DeepSeekService {\n // Replace with your actual DeepSeek API key\n final String _apiKey = 'sk-5c3de2bbc15c4931bf33ac6a152db767';\n final String _endpoint = 'https://api.deepseek.com/chat/completions';\n\n // System prompt to set the AI's role\n static const String systemPrompt =\n 'You are an AI Career Guidance Assistant for Filipino students. '\n 'You help students discover suitable careers, college courses, and universities '\n 'in the Philippines based on their interests, skills, and RIASEC results. '\n 'Keep responses concise, friendly, and informative. '\n 'When discussing salaries, use Philippine Peso (₱). '\n 'Focus on actionable advice and encourage students in their career exploration.';\n\n /// Sends a message to DeepSeek API with full conversation history.\n /// Returns the assistant's reply or an error message prefixed with \"Error:\".\n Future sendMessage(List> messageHistory) async {\n try {\n final response = await http\n .post(\n Uri.parse(_endpoint),\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer $_apiKey',\n },\n body: jsonEncode({\n 'model': 'deepseek-chat',\n 'messages': messageHistory,\n 'temperature': 0.7,\n 'max_tokens': 1024,\n }),\n )\n .timeout(const Duration(seconds: 30));\n\n if (response.statusCode == 200) {\n final data = jsonDecode(response.body);\n final choices = data['choices'] as List?;\n if (choices != null && choices.isNotEmpty) {\n return choices[0]['message']['content'] ?? 'No response received.';\n }\n return 'Error: Empty response from AI.';\n } else if (response.statusCode == 401) {\n return 'Error: Invalid API key. Please check your DeepSeek API key.';\n } else if (response.statusCode == 429) {\n return 'Error: Too many requests. Please wait a moment and try again.';\n } else {\n return 'Error: Server returned status ${response.statusCode}. Please try again.';\n }\n } on http.ClientException catch (e) {\n return 'Error: Connection failed. Please check your internet connection. ($e)';\n } catch (e) {\n if (e.toString().contains('TimeoutException')) {\n return 'Error: Request timed out. Please try again.';\n }\n return 'Error: Something went wrong. Please try again. ($e)';\n }\n }\n}\n"}}}}