diff --git a/README.md b/README.md index b68f8f6..f6fba91 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ Feel free to experiment with your own values the perference properties. Here is an example: ```bash +GPT_MODEL = "gpt-4" +# GPT_MODEL = "gpt-3.5-turbo" + TARGET_OS = "Manjaro Linux" # TARGET_OS = "Arch Linx" # TARGET_OS = "MacOS" @@ -51,6 +54,7 @@ HUMOUR_STYLE = "friendly" # HUMOUR_STYLE = "mean sarcastic" TERMINAL_EMULATOR = "very simple" +# TERMINAL_EMULATOR = "Kitty" # TERMINAL_EMULATOR = "Alacritty" # TERMINAL_EMULATOR = "iTerm2" @@ -123,6 +127,9 @@ To add a new package to the project # Release History +## v0.3.0 +- Add support for different GPT models. + ## v0.2.2 - Tweak colors. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6471a0c..3df5099 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: colors: specifier: ^1.4.0 @@ -358,7 +362,7 @@ packages: /axios@0.26.1: resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} dependencies: - follow-redirects: 1.15.2 + follow-redirects: 1.15.6 transitivePeerDependencies: - debug dev: false @@ -752,8 +756,8 @@ packages: resolution: {integrity: sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==} dev: true - /follow-redirects@1.15.2: - resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + /follow-redirects@1.15.6: + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} peerDependencies: debug: '*' diff --git a/src/App.ts b/src/App.ts index 685b812..eb7ff29 100644 --- a/src/App.ts +++ b/src/App.ts @@ -8,7 +8,8 @@ async function main() { try{ const aiResponse = await h.performAICall( userString, - pref.openAIKey, + pref.openAIKey, + pref.gptModel, pref.terminalEmulator, pref.targetOS, pref.humourStyle diff --git a/src/helpers.ts b/src/helpers.ts index 6bfd8aa..ac07358 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -54,6 +54,10 @@ export const checkEnv = (): IPreferences => { if (!openAIKey) { throw new Error("Define 'OPENAI_KEY' in .env file in project's root"); } + const gptModel = process.env["GPT_MODEL"]; + if (!gptModel) { + throw new Error("Define 'GPT_MODEL' in .env file in project's root"); + } const terminalEmulator = process.env["TERMINAL_EMULATOR"]; if (!terminalEmulator) { throw new Error("Define 'TERMINAL_EMULATOR' in .env file in project's root"); @@ -62,6 +66,7 @@ export const checkEnv = (): IPreferences => { targetOS, humourStyle, terminalEmulator, + gptModel, openAIKey }; } catch (error) { @@ -97,11 +102,18 @@ export const processArgs = (): string => { export const performAICall = async ( userString: string, apiKey: string, + gptModel: string, terminalEmulator: string, targetOS: string, humourStyle: string, ): Promise => { - const aiBridge = new OpenAIBridge( terminalEmulator, targetOS, humourStyle, apiKey); + const aiBridge = new OpenAIBridge( + apiKey, + gptModel, + terminalEmulator, + targetOS, + humourStyle, + ); const aiResponse1 = await aiBridge.requestResponse(userString); if (aiResponse1) { return aiResponse1; diff --git a/src/openai/IPreferences.ts b/src/openai/IPreferences.ts index 6c07db0..99039a4 100644 --- a/src/openai/IPreferences.ts +++ b/src/openai/IPreferences.ts @@ -2,5 +2,6 @@ export interface IPreferences { readonly targetOS: string; readonly humourStyle: string; readonly terminalEmulator: string; + readonly gptModel: string; readonly openAIKey: string; } \ No newline at end of file diff --git a/src/openai/OpenAIBridge.ts b/src/openai/OpenAIBridge.ts index bdc6fb2..fdc8f61 100644 --- a/src/openai/OpenAIBridge.ts +++ b/src/openai/OpenAIBridge.ts @@ -82,10 +82,11 @@ export class OpenAIBridge { private _openAIApi: OpenAIApi; constructor( + apiKey: string, + private _gptModel: string, private _terminalEmulator: string, private _targetOS: string, private _humourStyle: string, - apiKey: string, ) { const config = new Configuration({ apiKey: apiKey @@ -97,7 +98,7 @@ export class OpenAIBridge { try { const response = await this._openAIApi.createChatCompletion({ // model: "gpt-4", // Not yet available - model: "gpt-3.5-turbo", + model: this._gptModel, messages: [ { "role": "user",