Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/321208008_itusi-ai-translation-tool.json

1 line
4.5 KiB
JSON

{"repo": "321208008/itusi-ai-translation-tool", "files": {"lib/deepseek.ts": {"2a0f664ab791f9af7659888bf9ab353810936dd5": {"t": 1785746393.6020265, "n": 1318, "h": "54dcd918225f7f53", "c": "import { TranslationRequest } from './types';\n\nconst DEEPSEEK_API_URL = 'https://api.deepseek.com/v1/chat/completions';\n\ninterface Message {\n role: 'system' | 'user';\n content: string;\n}\n\nexport async function translateWithDeepSeek(\n text: string,\n sourceLanguage: string,\n targetLanguage: string,\n apiKey: string\n): Promise<string> {\n const response = await fetch('https://api.deepseek.com/v1/chat/completions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n model: 'deepseek-chat',\n messages: [\n {\n role: 'system',\n content: 'You are a professional translator. Translate the text exactly as provided, maintaining the original meaning and style. Only return the translation, no explanations.',\n },\n {\n role: 'user',\n content: `Translate the following text ${sourceLanguage !== 'auto' ? `from ${sourceLanguage}` : ''} to ${targetLanguage}:\\n${text}`,\n },\n ],\n temperature: 0.3,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error.error?.message || 'Translation failed');\n }\n\n const data = await response.json();\n return data.choices[0].message.content.trim();\n}\n"}, "05167238263f0ea71784182ab65239aa069412ae": {"t": 1785763234.2140565, "n": 1318, "h": "54dcd918225f7f53", "c": "import { TranslationRequest } from './types';\n\nconst DEEPSEEK_API_URL = 'https://api.deepseek.com/v1/chat/completions';\n\ninterface Message {\n role: 'system' | 'user';\n content: string;\n}\n\nexport async function translateWithDeepSeek(\n text: string,\n sourceLanguage: string,\n targetLanguage: string,\n apiKey: string\n): Promise<string> {\n const response = await fetch('https://api.deepseek.com/v1/chat/completions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n model: 'deepseek-chat',\n messages: [\n {\n role: 'system',\n content: 'You are a professional translator. Translate the text exactly as provided, maintaining the original meaning and style. Only return the translation, no explanations.',\n },\n {\n role: 'user',\n content: `Translate the following text ${sourceLanguage !== 'auto' ? `from ${sourceLanguage}` : ''} to ${targetLanguage}:\\n${text}`,\n },\n ],\n temperature: 0.3,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error.error?.message || 'Translation failed');\n }\n\n const data = await response.json();\n return data.choices[0].message.content.trim();\n}\n"}, "afc1868437751664af65e850258586ef749815ba": {"t": 1785763235.8659422, "n": 1428, "h": "70b262db9575ce01", "c": "import { TranslationRequest } from './types';\n\nconst DEEPSEEK_API_URL = 'https://api.deepseek.com/v1/chat/completions';\n\ninterface Message {\n role: 'system' | 'user';\n content: string;\n}\n\nexport async function translateWithDeepSeek(\n request: TranslationRequest,\n apiKey: string\n): Promise<string> {\n const { text, sourceLanguage, targetLanguage } = request;\n \n const messages: Message[] = [\n {\n role: 'system',\n content: `You are a professional translator. Translate the following text ${\n sourceLanguage !== 'auto' ? `from ${sourceLanguage}` : ''\n } to ${targetLanguage}. Only return the translated text without any explanations or additional information.`\n },\n {\n role: 'user',\n content: text\n }\n ];\n\n try {\n const response = await fetch(DEEPSEEK_API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`\n },\n body: JSON.stringify({\n model: 'deepseek-chat',\n messages,\n temperature: 0.3,\n max_tokens: 2000\n })\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error.error?.message || 'Translation failed');\n }\n\n const data = await response.json();\n return data.choices[0].message.content.trim();\n } catch (error) {\n console.error('[DeepSeek API Error]', error);\n throw error;\n }\n}\n"}}}}