forked from Chanzhaoyu/chatgpt-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31ea7c5
commit 35da3f1
Showing
2 changed files
with
21 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import dotenv from 'dotenv' | ||
import { ChatGPTAPI } from 'chatgpt' | ||
|
||
dotenv.config() | ||
|
||
const apiKey = '' | ||
|
||
/** | ||
* More Info: https://github.com/transitive-bullshit/chatgpt-api | ||
*/ | ||
const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY || apiKey }) | ||
|
||
async function chatReply(message: string) { | ||
if (!message) | ||
return | ||
return await api.sendMessage(message) | ||
} | ||
|
||
export { chatReply } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters