1.0.5 • Published 11 months ago
@jerrywn/chatgpt-server v1.0.5
chatgpt-server
Example
const response01 = await fetch("http://localhost:3000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
message: "How are you?",
}),
})
const data = await response01.json()
const id = data.id
console.log(data)
const response02 = await fetch("http://localhost:3000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
message: "where are you from?",
}),
})
console.log(await response02.json())
const response03 = await fetch("http://localhost:3000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id,
message: "whats my previous question",
}),
})
console.log(await response03.json())
output
{
id: '4effed08-5cbf-403a-ac2f-ac10968205b9',
message: "As an AI language model, I don't have feelings, but I'm operational and ready to help you! How can I assist you today?"
}
{
id: '8930eeaa-4570-46ed-a919-1e8535c4f229',
message: "I don't have a physical origin as I am a virtual assistant powered by AI technology. I was created by OpenAI and am available to assist and interact with users online."
}
{
id: '4effed08-5cbf-403a-ac2f-ac10968205b9',
message: 'Your previous question was "How are you?"'
}
Usage
npm install @jerrywn/chatgpt-server -g
chatgpt-server --api-key=<OPENAI_API_KEY>
Request
{
"id": "" // Optional, the converastion id to use
"message": "" // message send to chatgpt
}
Response
{
"id": "" // the convesation id in this message
"message": "" // the chatgpt's reply message
}