{"id":15857407,"url":"https://github.com/timmikeladze/ai-complete","last_synced_at":"2026-01-19T09:01:48.807Z","repository":{"id":64749453,"uuid":"577966138","full_name":"TimMikeladze/ai-complete","owner":"TimMikeladze","description":"A toolkit that super-charges your workflow when working with openai.","archived":false,"fork":false,"pushed_at":"2023-04-07T20:48:11.000Z","size":460,"stargazers_count":1,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T00:04:53.096Z","etag":null,"topics":["ai","ai-complete","aitranslate","javascript","nlp","openai","translation","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimMikeladze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"linesofcodedev","custom":["https://www.paypal.me/TimMikeladze"]}},"created_at":"2022-12-13T23:55:46.000Z","updated_at":"2024-10-26T18:42:10.000Z","dependencies_parsed_at":"2025-02-13T14:50:54.289Z","dependency_job_id":"0911b1ff-7b19-49a6-bae5-4d120a1637a6","html_url":"https://github.com/TimMikeladze/ai-complete","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/TimMikeladze/ai-complete","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimMikeladze%2Fai-complete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimMikeladze%2Fai-complete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimMikeladze%2Fai-complete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimMikeladze%2Fai-complete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimMikeladze","download_url":"https://codeload.github.com/TimMikeladze/ai-complete/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimMikeladze%2Fai-complete/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28565001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-complete","aitranslate","javascript","nlp","openai","translation","typescript"],"created_at":"2024-10-05T20:22:50.761Z","updated_at":"2026-01-19T09:01:48.792Z","avatar_url":"https://github.com/TimMikeladze.png","language":"TypeScript","funding_links":["https://ko-fi.com/linesofcodedev","https://www.paypal.me/TimMikeladze"],"categories":[],"sub_categories":[],"readme":"# ai-complete\n\nA toolkit that super-charges your workflow when working with `openai`.\n\n## Install\n\n```bash\nnpm install ai-complete\n# or\nyarn add ai-complete\n# or\npnpm add ai-complete\n```\n\n**Note:** You will need to get an API key from [OpenAI](https://beta.openai.com/login/).\n\n## Usage\n\nIn the following example we use `ai-complete` to translate a directory containing a bunch JSON language files. Our goal is to translate the files into another language and write the translated files to a new directory.\n\n\u003e Note: You can run this example by cloning this repo and running `yarn example`.\n\n```js\nimport 'dotenv/config'\n\nimport AIComplete from 'ai-complete'\nimport { existsSync, mkdirSync, writeFileSync } from 'fs'\n\nconst inputDir = 'locales/en'\nconst outputDir = 'locales/ru'\n\nconst aic = new AIComplete({\n  // Configure the OpenAI API. API key is required.\n  openAI: {\n    config: {\n      apiKey: process.env.OPENAI_API_KEY\n    }\n  }\n})\n\nawait aic.createCompletion({\n  // Where to read files from. All globby pattern and options are supported.\n  globby: {\n    patterns: ['example/locales/en/**/*.json']\n  },\n  // This function is called for each file and the results are used as arguments for the OpenAI API.\n  input: async () =\u003e {\n    return {\n      // Describe what you want to do with the file.\n      prompt:\n        'Translate the JSON below into Russian but keep names of all keys and metadata in English.',\n      request: {\n        // controls randomness, as value approaches 0 the output will be more deterministic\n        temperature: 0\n      }\n    }\n  },\n  // This function is called with the results from each OpenAI API call.\n  output: async ({ data, filePath }) =\u003e {\n    // Parse the results from JSON to JS.\n    const choice = JSON.parse(data.choices[0].text)\n\n    // Calculate the new file path of the translated file.\n\n    const outputFilePath = filePath.replace(inputDir, outputDir)\n\n    const dir = outputFilePath.substring(0, outputFilePath.lastIndexOf('/'))\n\n    if (!existsSync(dir)) {\n      mkdirSync(dir, { recursive: true })\n    }\n\n    // Write the results to the file.\n\n    const fileContents = JSON.stringify(choice, null, 2)\n\n    try {\n      writeFileSync(outputFilePath, fileContents, { flag: 'wx' })\n      console.log('Wrote file: ' + outputFilePath)\n    } catch (error) {\n      console.error('Error writing file: ' + outputFilePath)\n      console.error(error.message)\n    }\n\n    return {\n      choice\n    }\n  }\n})\n```\n\nIn this example we will use `ai-complete` to load some text and ask OpenAI to create an edit.\n\n```js\nimport 'dotenv/config'\n\nimport AIComplete from 'ai-complete'\n\nconst aic = new AIComplete({\n  openAI: {\n    config: {\n      apiKey: process.env.OPENAI_API_KEY\n    }\n  }\n})\n\nconst result = await aic.createEdit({\n  data: [\n    {\n      type: 'text',\n      value: 'One, two, ___, four.'\n    }\n  ],\n  input: async () =\u003e ({\n    instruction: 'Fill in the blank with the correct word.'\n  }),\n  output: async ({ data }) =\u003e {\n    return {\n      choice: data.choices[0].text\n    }\n  }\n})\n\n// Result:\n//   [\n//      {\n//          \"choice\": \"One, two, three, four.\",\n//      }\n//   ]\n```\n\n## Running examples and tests\n\n1. Create a `.env` file in the root of the project and add your `OPENAI_API_KEY` to it.\n2. Run `yarn example` to run the `translate.js` example.\n3. Run `yarn test` to run all the tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmikeladze%2Fai-complete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimmikeladze%2Fai-complete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmikeladze%2Fai-complete/lists"}