1 line
1.1 KiB
JSON
1 line
1.1 KiB
JSON
{"repo": "argszero/tech", "files": {"tools/article.js": {"cca02305060b1cfdc7a1299e1b585933671b5e09": {"t": 1785768948.2768497, "n": 910, "h": "82cc7d9441f55a2e", "c": "\nimport fetch from 'node-fetch';\nimport fs from 'fs';\n\nlet input = fs.readFileSync('article_input.md', 'utf8');\nlet prompt = fs.readFileSync('article_prompt.txt', 'utf8');\nlet url = 'https://api.aiproxy.io/v1/chat/completions';\n\nlet body = JSON.stringify({\n \"model\": \"gpt-4\",\n \"messages\": [\n { \"role\": \"system\", \"content\": prompt },\n { \"role\": \"user\", \"content\": input }], \"stream\": false, \"temperature\": 0.27\n});\n\nlet options = {\n method: 'POST',\n headers: {\n 'x-api2d-no-cache': 1,\n 'Authorization': 'Bearer '+process.env.API2D_TOKEN,\n 'Content-Type': 'application/json'\n },\n body\n};\n\nfetch(url, options)\n .then(res => res.json())\n .then(json => {\n console.log(`json:${JSON.stringify(json)}`);\n const res = json.choices[0].message.content;\n console.log('res:\\n', res);\n\n })\n .catch(err => console.error('error:' + err));\n\n"}}}} |