kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
add a CLI
rodzic
f2f209657d
commit
30f3abd471
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { ChatGPTAPI } from './build/index.js'
|
||||||
|
|
||||||
|
const input = process.argv[2]
|
||||||
|
|
||||||
|
if (!input) {
|
||||||
|
console.log('Usage: chatgpt "input prompt"')
|
||||||
|
process.exit()
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })
|
||||||
|
const res = await api.sendMessage(input)
|
||||||
|
process.stdout.write(res.text)
|
Plik diff jest za duży
Load Diff
|
@ -21,6 +21,7 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
|
"bin": "cli.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"dev": "tsup --watch",
|
"dev": "tsup --watch",
|
||||||
|
|
Ładowanie…
Reference in New Issue