Skip to content

Commit

Permalink
fix: chat gpt file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
fbatiga committed May 9, 2023
1 parent 0d4a8bd commit d929405
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"tune:dev": "nodemon src/finetuning.ts",
"clean": "rimraf coverage build tmp",
"prebuild": "npm run lint",
"build": "tsc -p tsconfig.json",
"build": "tsc -p tsconfig.json && chmod +x build/src/*",
"build:watch": "tsc -w -p tsconfig.json",
"build:release": "npm run clean && tsc -p tsconfig.release.json",
"lint": "eslint . --ext .ts --ext .mts",
Expand All @@ -62,9 +62,13 @@
"volta": {
"node": "18.12.1"
},
"bin": {
"chatgpt": "./build/src/chat.js",
"tunegpt": "./build/src/finetune.js"
},
"nodemonConfig": {
"ignore": [
"db/*"
]
}
}
}
3 changes: 2 additions & 1 deletion src/chat.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env node
// eslint-lint-disable no-continue
import 'dotenv/config';
import prompt from 'prompt';
import { chatWithGPT } from './services/openai.ts';
import getDb from './services/db.ts';
import { getUserInput } from './services/utils.ts';

let model = process.argv[2] || 'gpt-3.5-turbo';
const model = process.argv[2] || 'gpt-3.5-turbo';
prompt.start();

const chat = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/finetuning.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/** eslint-lint-disable no-shadow */
import 'dotenv/config';
import prompt from 'prompt';
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
console.log(`Welcome to ChatGPT CLI!
\t To Chat run "yarn chat" then Type your message and press Enter.
\t To Fine Tune your models run "yarn tuning" then select your model and press Enter.
Expand Down
14 changes: 7 additions & 7 deletions src/services/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export const openai = new OpenAIApi(configuration);
export async function chatWithGPT(
message: string,
context = [],
model?:string = 'gpt-3.5-turbo',
model = 'gpt-3.5-turbo',
): Promise<string> {
try {
console.log('Sending message to GPT:', [
...context,
{
role: 'user', content: message
},
]);
// console.log('Sending message to GPT:', [
// ...context,
// {
// role: 'user', content: message
// },
// ]);
const response = await openai.createChatCompletion({
model,
messages: [...context, {
Expand Down

0 comments on commit d929405

Please sign in to comment.