Skip to content

Commit

Permalink
feat(main.js): add logic to choose between local and OpenAI APIs base…
Browse files Browse the repository at this point in the history
…d on environment variable
  • Loading branch information
alexsoyes committed Jul 16, 2024
1 parent 7aab31a commit f85ef16
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions scripts/aiddc/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,19 @@ for (const file of aiddFiles) {

const promptFilePath = path.join(__dirname, '/.prompt');

let callableAPI = null;

if (process.env.LOCAL_MODEL) {
console.log('\n🤖 Loading local model: ' + process.env.LOCAL_MODEL);
callableAPI = callOllamaApi;
} else {
console.log('\n🤖 Using OpenAI API!');
callableAPI = callOpenAiApi;
}

if (fs.existsSync(promptFilePath)) {
const promptContent = fs.readFileSync(promptFilePath, 'utf-8');
// Proceed with the rest of the logic
if (argv['no-validate'] === 'true') {
callOpenAiApi(GEN_AI_SYSTEM_MESSAGE, promptContent)
.then(response => console.log(response))
.catch(error => {
console.error(error.message);
process.exit(1);
});
} else {
askAi(promptContent);
}
askAi(promptContent, callableAPI);
} else {
console.error('.prompt file not found. Exiting.');
process.exit(1);
Expand Down

0 comments on commit f85ef16

Please sign in to comment.