Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
1 line
23 KiB
JSON
1 line
23 KiB
JSON
{"repo": "ahmadalkryan/general-blog", "files": {"Infrastructure/Service/DeepSeekService.cs": {"98bf5d973a521bead110c260a0b3a53aae7d8b5f": {"t": 1786068393.0325148, "n": 21948, "h": "99dc380921469710", "c": "//////using System;\n//////using System.Collections.Generic;\n//////using System.Linq;\n//////using System.Text;\n//////using System.Threading.Tasks;\n\n//////namespace Infrastructure.Service\n//////{\n\n//////}\n////using Applicarion.IService;\n////using Microsoft.Extensions.Configuration;\n////using Microsoft.Extensions.Logging;\n////using System;\n////using System.Collections.Generic;\n////using System.Linq;\n////using System.Net.Http;\n////using System.Net.Http.Json;\n////using System.Text;\n////using System.Text.Json;\n////using System.Threading.Tasks;\n\n////namespace Infrastructure.Service\n////{\n//// public class DeepSeekService : IAIService\n//// {\n//// private readonly HttpClient _httpClient;\n//// private readonly IConfiguration _configuration;\n//// private readonly ILogger<DeepSeekService> _logger;\n\n//// public DeepSeekService(\n//// ILogger<DeepSeekService> logger,\n//// IConfiguration configuration,\n//// HttpClient httpClient)\n//// {\n//// _configuration = configuration;\n//// _httpClient = httpClient;\n//// _logger = logger;\n\n//// // إعداد API Key لـ DeepSeek\n//// var apiKey = _configuration[\"DeepSeek:ApiKey\"] ?? \"sk-9b01d4933ded4567ac27412951ee600c\";\n//// _httpClient.DefaultRequestHeaders.Add(\"Authorization\", $\"Bearer {apiKey}\");\n//// }\n\n//// public string ServiceName => \"DeepSeek\";\n\n//// public async Task<string> GenerateAnswerAsync(string context, string question)\n//// {\n//// var apiUrl = \"https://api.deepseek.com/v1/chat/completions\";\n\n//// var messages = new[]\n//// {\n//// new\n//// {\n//// role = \"system\",\n//// content = @\"أنت مساعد ذكي. قم بالإجابة على الأسئلة بناءً على المحتوى المقدم فقط.\n//// - أجب بناءً على المحتوى المقدم فقط\n//// - إذا لم يكن المحتوى كافياً، قل 'لا أستطيع الإجابة بناءً على المحتوى المتاح'\n//// - استخدم لغة عربية واضحة وسليمة\n//// - كن مفيداً ودقيقاً\n//// - لا تختلق معلومات\"\n//// },\n//// new\n//// {\n//// role = \"user\",\n//// content = $\"المحتوى المرجعي:\\n{context}\\n\\nالسؤال: {question}\"\n//// }\n//// };\n\n//// var request = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = messages,\n//// max_tokens = 1000,\n//// temperature = 0.3\n//// };\n\n//// try\n//// {\n//// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n//// if (response.IsSuccessStatusCode)\n//// {\n//// var result = await response.Content.ReadFromJsonAsync<DeepSeekResponse>();\n//// return CleanResponse(result.choices[0].message.content);\n//// }\n\n//// _logger.LogWarning(\"DeepSeek API returned: {StatusCode}\", response.StatusCode);\n//// return \"عذراً، حدث خطأ في معالجة سؤالك. يرجى المحاولة لاحقاً.\";\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error calling DeepSeek API\");\n//// return \"عذراً، تعذر الوصول إلى خدمة الذكاء الاصطناعي حالياً.\";\n//// }\n//// }\n\n//// public async Task<string> SummarizeTextAsync(string text)\n//// {\n//// var apiUrl = \"https://api.deepseek.com/v1/chat/completions\";\n\n//// var messages = new[]\n//// {\n//// new\n//// {\n//// role = \"system\",\n//// content = @\"قم بتلخيص النص في نقاط رئيسية واضحة باللغة العربية.\n//// - ركز على الأفكار الرئيسية\n//// - استخدم صياغة واضحة وسهلة الفهم\n//// - لا تزيد عن 4-5 نقاط رئيسية\n//// - لا تضيف معلومات خارج النص\"\n//// },\n//// new\n//// {\n//// role = \"user\",\n//// content = $\"النص:\\n{text}\"\n//// }\n//// };\n\n//// var request = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = messages,\n//// max_tokens = 800,\n//// temperature = 0.3\n//// };\n\n//// try\n//// {\n//// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n//// if (response.IsSuccessStatusCode)\n//// {\n//// var result = await response.Content.ReadFromJsonAsync<DeepSeekResponse>();\n//// return CleanResponse(result.choices[0].message.content);\n//// }\n\n//// return GenerateFallbackSummary(text);\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error generating summary with DeepSeek\");\n//// return GenerateFallbackSummary(text);\n//// }\n//// }\n\n//// public async Task<bool> IsServiceAvailableAsync()\n//// {\n//// try\n//// {\n//// // اختبار بسيط للخدمة\n//// var testRequest = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = new[]\n//// {\n//// new { role = \"user\", content = \"Say 'hello'\" }\n//// },\n//// max_tokens = 5\n//// };\n\n//// var response = await _httpClient.PostAsJsonAsync(\n//// \"https://api.deepseek.com/v1/chat/completions\",\n//// testRequest\n//// );\n\n//// return response.IsSuccessStatusCode;\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error checking DeepSeek service availability.\");\n//// return false;\n//// }\n//// }\n\n//// private string CleanResponse(string response)\n//// {\n//// if (string.IsNullOrEmpty(response))\n//// return response;\n\n//// var cleanResponse = response.Trim();\n\n//// // إزالة البادئات الشائعة\n//// var prefixes = new[] {\n//// \"ملخص:\", \"الملخص:\",\n//// \"إجابة:\", \"الإجابة:\",\n//// \"**ملخص:**\", \"**إجابة:**\"\n//// };\n\n//// foreach (var prefix in prefixes)\n//// {\n//// if (cleanResponse.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))\n//// {\n//// cleanResponse = cleanResponse.Substring(prefix.Length).Trim();\n//// break;\n//// }\n//// }\n\n//// return cleanResponse.TrimStart(':', '-', '*', ' ', '\\n', '\\r');\n//// }\n\n//// private string GenerateFallbackSummary(string text)\n//// {\n//// if (string.IsNullOrWhiteSpace(text))\n//// return \"لا يوجد محتوى لتلخيصه.\";\n\n//// try\n//// {\n//// var sentences = text.Split(new[] { '.', '!', '?' }, StringSplitOptions.RemoveEmptyEntries)\n//// .Where(s => !string.IsNullOrWhiteSpace(s))\n//// .Take(3)\n//// .Select(s => s.Trim())\n//// .ToArray();\n\n//// return sentences.Any() ?\n//// $\"النقاط الرئيسية:\\n• {string.Join(\"\\n• \", sentences)}.\" :\n//// \"تعذر توليد ملخص للمحتوى المقدم.\";\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error in fallback summary generation\");\n//// return \"عذراً، تعذر توليد ملخص للمحتوى.\";\n//// }\n//// }\n//// }\n\n//// public class DeepSeekResponse\n//// {\n//// public Choice[] choices { get; set; }\n//// }\n\n//// public class Choice\n//// {\n//// public Message message { get; set; }\n//// }\n\n//// public class Message\n//// {\n//// public string role { get; set; }\n//// public string content { get; set; }\n//// }\n////}\n\n////using Applicarion.IService;\n////using Microsoft.Extensions.Configuration;\n////using Microsoft.Extensions.Logging;\n////using System;\n////using System.Linq;\n////using System.Net.Http;\n////using System.Net.Http.Json;\n////using System.Threading.Tasks;\n\n////namespace Infrastructure.Service\n////{\n//// public class DeepSeekService : IAIService\n//// {\n//// private readonly HttpClient _httpClient;\n//// private readonly IConfiguration _configuration;\n//// private readonly ILogger<DeepSeekService> _logger;\n\n//// public DeepSeekService(\n//// ILogger<DeepSeekService> logger,\n//// IConfiguration configuration,\n//// HttpClient httpClient)\n//// {\n//// _configuration = configuration;\n//// _httpClient = httpClient;\n//// _logger = logger;\n\n//// var apiKey = _configuration[\"DeepSeek:ApiKey\"] ?? \"sk-9b01d4933ded4567ac27412951ee600c\";\n//// _httpClient.DefaultRequestHeaders.Add(\"Authorization\", $\"Bearer {apiKey}\");\n//// }\n\n//// public string ServiceName => \"DeepSeek\";\n\n//// public async Task<string> GenerateAnswerAsync(string context, string question)\n//// {\n//// var apiUrl = \"https://api.deepseek.com/v1/chat/completions\";\n\n//// var messages = new[]\n//// {\n//// new\n//// {\n//// role = \"system\",\n//// content = @\"You are a smart assistant for an English blog. Answer readers' questions based only on the provided content.\n\n////Instructions:\n////- Answer based only on the provided content\n////- If the content is insufficient, say 'I cannot answer based on the available content'\n////- Use clear and proper English\n////- Be helpful and accurate\n////- Do not make up information\"\n//// },\n//// new\n//// {\n//// role = \"user\",\n//// content = $\"Reference Content:\\n{context}\\n\\nQuestion: {question}\"\n//// }\n//// };\n\n//// var request = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = messages,\n//// max_tokens = 1000,\n//// temperature = 0.3\n//// };\n\n//// try\n//// {\n//// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n//// if (response.IsSuccessStatusCode)\n//// {\n//// var result = await response.Content.ReadFromJsonAsync<DeepSeekResponse>();\n//// return CleanResponse(result.choices[0].message.content);\n//// }\n\n//// _logger.LogWarning(\"DeepSeek API returned: {StatusCode}\", response.StatusCode);\n//// return \"Sorry, there was an error processing your question. Please try again later.\";\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error calling DeepSeek API\");\n//// return \"Sorry, the AI service is currently unavailable.\";\n//// }\n//// }\n\n//// public async Task<string> SummarizeTextAsync(string text)\n//// {\n//// var apiUrl = \"https://api.deepseek.com/v1/chat/completions\";\n\n//// var messages = new[]\n//// {\n//// new\n//// {\n//// role = \"system\",\n//// content = @\"Summarize the text in clear main points in English.\n\n//// Requirements:\n//// - Focus on main ideas\n//// - Use clear and easy-to-understand wording\n//// - Maximum 4-5 main points\n//// - Do not add information outside the text\"\n//// },\n//// new\n//// {\n//// role = \"user\",\n//// content = $\"Text:\\n{text}\"\n//// }\n//// };\n\n//// var request = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = messages,\n//// max_tokens = 800,\n//// temperature = 0.3\n//// };\n\n//// try\n//// {\n//// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n//// if (response.IsSuccessStatusCode)\n//// {\n//// var result = await response.Content.ReadFromJsonAsync<DeepSeekResponse>();\n//// return CleanResponse(result.choices[0].message.content);\n//// }\n\n//// return GenerateFallbackSummary(text);\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error generating summary with DeepSeek\");\n//// return GenerateFallbackSummary(text);\n//// }\n//// }\n\n//// public async Task<bool> IsServiceAvailableAsync()\n//// {\n//// try\n//// {\n//// var testRequest = new\n//// {\n//// model = \"deepseek-chat\",\n//// messages = new[]\n//// {\n//// new { role = \"user\", content = \"Say 'hello'\" }\n//// },\n//// max_tokens = 5\n//// };\n\n//// var response = await _httpClient.PostAsJsonAsync(\n//// \"https://api.deepseek.com/v1/chat/completions\",\n//// testRequest\n//// );\n\n//// return response.IsSuccessStatusCode;\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error checking DeepSeek service availability.\");\n//// return false;\n//// }\n//// }\n\n//// private string CleanResponse(string response)\n//// {\n//// if (string.IsNullOrEmpty(response))\n//// return response;\n\n//// var cleanResponse = response.Trim();\n\n//// var prefixes = new[] {\n//// \"Summary:\", \"The summary:\",\n//// \"Answer:\", \"The answer:\",\n//// \"**Summary:**\", \"**Answer:**\"\n//// };\n\n//// foreach (var prefix in prefixes)\n//// {\n//// if (cleanResponse.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))\n//// {\n//// cleanResponse = cleanResponse.Substring(prefix.Length).Trim();\n//// break;\n//// }\n//// }\n\n//// return cleanResponse.TrimStart(':', '-', '*', ' ', '\\n', '\\r');\n//// }\n\n//// private string GenerateFallbackSummary(string text)\n//// {\n//// if (string.IsNullOrWhiteSpace(text))\n//// return \"No content to summarize.\";\n\n//// try\n//// {\n//// var sentences = text.Split(new[] { '.', '!', '?' }, StringSplitOptions.RemoveEmptyEntries)\n//// .Where(s => !string.IsNullOrWhiteSpace(s))\n//// .Take(3)\n//// .Select(s => s.Trim())\n//// .ToArray();\n\n//// return sentences.Any() ?\n//// $\"Main points:\\n• {string.Join(\"\\n• \", sentences)}.\" :\n//// \"Could not generate summary for the provided content.\";\n//// }\n//// catch (Exception ex)\n//// {\n//// _logger.LogError(ex, \"Error in fallback summary generation\");\n//// return \"Sorry, could not generate summary for the content.\";\n//// }\n//// }\n//// }\n\n//// public class DeepSeekResponse\n//// {\n//// public Choice[] choices { get; set; }\n//// }\n\n//// public class Choice\n//// {\n//// public Message message { get; set; }\n//// }\n\n//// public class Message\n//// {\n//// public string role { get; set; }\n//// public string content { get; set; }\n//// }\n////}\n\n\n//using Application.IService;\n//using Microsoft.Extensions.Configuration;\n//using Microsoft.Extensions.Logging;\n//using System.Net.Http.Json;\n\n//public class AIService : IAIService\n//{\n// private readonly HttpClient _httpClient;\n// private readonly IConfiguration _configuration;\n// private readonly ILogger<AIService> _logger;\n\n// public AIService(\n// ILogger<AIService> logger,\n// IConfiguration configuration,\n// HttpClient httpClient)\n// {\n// _configuration = configuration;\n// _httpClient = httpClient;\n// _logger = logger;\n// }\n\n// public string ServiceName => \"HuggingFace\";\n\n// public async Task<string> GenerateAnswerAsync(string context, string question)\n// {\n// var apiUrl = \"https://api-inference.huggingface.co/models/microsoft/DialoGPT-large\";\n\n// var request = new\n// {\n// inputs = $\"{context}\\n\\nQuestion: {question}\",\n// parameters = new { max_length = 500 }\n// };\n\n// try\n// {\n// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n// if (response.IsSuccessStatusCode)\n// {\n// var result = await response.Content.ReadFromJsonAsync<HuggingFaceResponse[]>();\n// return CleanResponse(result[0].generated_text);\n// }\n\n// _logger.LogWarning(\"Hugging Face API returned: {StatusCode}\", response.StatusCode);\n// return \"Sorry, there was an error processing your question. Please try again later.\";\n// }\n// catch (Exception ex)\n// {\n// _logger.LogError(ex, \"Error calling Hugging Face API\");\n// return \"Sorry, the AI service is currently unavailable.\";\n// }\n// }\n\n// public async Task<string> SummarizeTextAsync(string text)\n// {\n// var apiUrl = \"https://api-inference.huggingface.co/models/facebook/bart-large-cnn\";\n\n// var request = new\n// {\n// inputs = text,\n// parameters = new { max_length = 150, min_length = 30, do_sample = false }\n// };\n\n// try\n// {\n// var response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n// if (response.IsSuccessStatusCode)\n// {\n// var result = await response.Content.ReadFromJsonAsync<HuggingFaceSummary[]>();\n// return CleanResponse(result[0].summary_text);\n// }\n\n// // إذا كان النموذج يحمّل، انتظر وحاول مرة أخرى\n// if (response.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable)\n// {\n// await Task.Delay(5000);\n// response = await _httpClient.PostAsJsonAsync(apiUrl, request);\n\n// if (response.IsSuccessStatusCode)\n// {\n// var result = await response.Content.ReadFromJsonAsync<HuggingFaceSummary[]>();\n// return CleanResponse(result[0].summary_text);\n// }\n// }\n\n// return GenerateFallbackSummary(text);\n// }\n// catch (Exception ex)\n// {\n// _logger.LogError(ex, \"Error generating summary with Hugging Face\");\n// return GenerateFallbackSummary(text);\n// }\n// }\n\n// public async Task<bool> IsServiceAvailableAsync()\n// {\n// try\n// {\n// var testRequest = new { inputs = \"Test\" };\n// var response = await _httpClient.PostAsJsonAsync(\n// \"https://api-inference.huggingface.co/models/facebook/bart-large-cnn\",\n// testRequest\n// );\n\n// return response.IsSuccessStatusCode || response.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable;\n// }\n// catch (Exception ex)\n// {\n// _logger.LogError(ex, \"Error checking Hugging Face service availability.\");\n// return false;\n// }\n// }\n\n// private string CleanResponse(string response)\n// {\n// if (string.IsNullOrEmpty(response))\n// return response;\n\n// return response.Trim();\n// }\n\n// private string GenerateFallbackSummary(string text)\n// {\n// if (string.IsNullOrWhiteSpace(text))\n// return \"No content to summarize.\";\n\n// try\n// {\n// var sentences = text.Split(new[] { '.', '!', '?' }, StringSplitOptions.RemoveEmptyEntries)\n// .Where(s => !string.IsNullOrWhiteSpace(s))\n// .Take(3)\n// .Select(s => s.Trim() + \".\")\n// .ToArray();\n\n// return sentences.Any() ?\n// string.Join(\" \", sentences) :\n// text.Length > 150 ? text.Substring(0, 150) + \"...\" : text;\n// }\n// catch (Exception ex)\n// {\n// _logger.LogError(ex, \"Error in fallback summary generation\");\n// return \"Summary: \" + (text.Length > 100 ? text.Substring(0, 100) + \"...\" : text);\n// }\n// }\n//}\n\n//public class HuggingFaceSummary\n//{\n// public string summary_text { get; set; }\n//}\n\n//public class HuggingFaceResponse\n//{\n// public string generated_text { get; set; }\n//}"}}}} |