Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -51,6 +54,7 @@ HUMOUR_STYLE = "friendly"
# HUMOUR_STYLE = "mean sarcastic"

TERMINAL_EMULATOR = "very simple"
# TERMINAL_EMULATOR = "Kitty"
# TERMINAL_EMULATOR = "Alacritty"
# TERMINAL_EMULATOR = "iTerm2"

Expand Down Expand Up @@ -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.

Expand Down
10 changes: 7 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -62,6 +66,7 @@ export const checkEnv = (): IPreferences => {
targetOS,
humourStyle,
terminalEmulator,
gptModel,
openAIKey
};
} catch (error) {
Expand Down Expand Up @@ -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<BridgeResponse> => {
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;
Expand Down
1 change: 1 addition & 0 deletions src/openai/IPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export interface IPreferences {
readonly targetOS: string;
readonly humourStyle: string;
readonly terminalEmulator: string;
readonly gptModel: string;
readonly openAIKey: string;
}
5 changes: 3 additions & 2 deletions src/openai/OpenAIBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down