1.0.5 • Published 11 months ago

@jerrywn/chatgpt-server v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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
}
1.0.2

12 months ago

1.0.1

12 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.0

1 year ago