gcc3 / simple-ai-chat

AI chat application.
https://simple-ai.io
Other
1 stars 7 forks source link

Simple AI Chat

Simple AI Chat is a command-based AI chat application, aimed at providing users with an easy and simple AI experience. This application is deployed to simple-ai.io. You can fork this code and deploy it on your machine for non-commercial use. (For details, please refer to the LICENSE file.) For bugs or suggestions, please report to the repository's GitHub Issues.

Dependencies

OpenAI API https://platform.openai.com/docs/api-reference
openai-node https://github.com/openai/openai-node
React https://reactjs.org/
Redux https://redux.js.org/
Next.js https://nextjs.org/
WolframAlpha APIs https://products.wolframalpha.com/api
Vectara https://vectara.com/
tailwind https://tailwindcss.com/docs/
Ollama https://ollama.com/

Features

Refer the Documentation page.
Click the dot in the screen corner.

Node (AI Node)

Simple AI is able to link to another support AI or data source.
The API format will use a OpenAI compitible format.
To use AI links, set USE_NODE_AI to true.

{
  "model": "llama3",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hi."
    },
    {
      "role": "assistant",
      "content": "Hi! It's nice to meet you. Is there something I can help you with or would you like to chat?"
    },
    {
      "role": "user",
      "content": "What can you do?"
    }
  ],
  "stream": false
}
{
  "message": {
      "role": "assistant",
      "content": "Hello"
  }
}

Ollama compatible APIs are supported by Simple AI with Node feature. Both stream or non-stream mode.

Setup

  1. Install the requirements
    $ npm install
    $ npm install next -g

  2. Create necessary files.
    Create .env from .env.example
    Create role.csv from role.csv.example (optional)
    role.csv.example is got from https://github.com/f/awesome-chatgpt-prompts

    • db.sqlite will be created automatically.
  3. Build and run the app.
    $ npm run build
    $ npm run dev or $npm start

Limitation

Limitation below is tested available.

Model: GPT-4o
Tokens: 123,453
Characters: 370358
Used GPT-4 tokenizer as GPT-4o is not available yet.

Coding rules

For API response Return a RESTful API response, with correct response code.
If there is an error, exmple response as below:

return res.status(400).json({
   success: false,
   error: "Error message",
});

Or

return res.status(400).json({
   success: false,
   error: error,  // If there is error handling
});

If success, example response as below:

res.status(200).json({
   success: true,
   message: "Success message.",
   some_additonal_obj,
});

.env

Originally Forked from https://github.com/openai/openai-quickstart-node