Coder Social home page Coder Social logo

namor / chatgpt-ui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dvcrn/chatgpt-ui

0.0 0.0 0.0 2.99 MB

ChatGPT UI with auth, targeted towards business-ey usecases, written in Elixir + LiveView

License: MIT License

JavaScript 4.30% Elixir 89.46% CSS 0.21% HTML 5.00% Dockerfile 1.03%

chatgpt-ui's Introduction

ChatGPT UI

ChatGPT to host yourself, targeted at business-ey usecases that may be useful within a company, written in Elixir + LiveView

screenshot

What is this?

The goal is to create a simple ChatGPT UI that uses the OpenAI APIs directly, for you and your company to self-host.

Why?

According to the OpenAI API Usage Policy, data from ChatGPT usage will be used to train their models. Usage of the API however, will not.

Some companies want to offer ChatGPT internally to their employees, but without having company data end up in the training set.

Features

  • "Scenarios" for repetitive tasks you find yourself doing a lot
  • Use your own OpenAI API key
  • Google OAuth authentication
  • Restrict access to certain email domains
  • Set which model to use
  • Code highlighting with highlightjs
  • Streaming messages support
  • Dark Mode
  • Ability to use "text-davinci-003" (GPT3), despite it not being a model for chatting
  • Automatic content truncating based on token count with bert-base-multilingual-uncased

Configuration

In config.exs, you can set the following keys:

config :chatgpt,
  title: "Elixir ChatGPT",
  enable_google_oauth: true,
  restrict_email_domains: false,
  allowed_email_domains: ["google.com"]

  default_model: :"gpt-3.5-turbo",
  models: [
    %{
      id: :gpt4,
      truncate_tokens: 8000 # this key is not being used yet, but will be in a future version
    },
    %{
      id: :"gpt-3.5-turbo",
      truncate_tokens: 4000
    },
    %{
      id: :davinci,
      truncate_tokens: 2200
    }
  ],

Then in runtime.exs:

# generate them at https://platform.openai.com/account/api-keys
config :ex_openai,
  api_key: System.get_env("OPENAI_API_KEY"),
  organization_key: System.get_env("OPENAI_ORGANIZATION_KEY"),
  http_options: [recv_timeout: 50_000]

# If you set `enable_google_oauth`, also set the following keys: (by default, uses the environment variables)
# check https://github.com/dwyl/elixir-auth-google/blob/main/create-google-app-guide.md on how to get these keys

config :elixir_auth_google,
  client_id: System.get_env("GOOGLE_AUTH_CLIENT_ID"),
  client_secret: System.get_env("GOOGLE_AUTH_CLIENT_SECRET")

Scenarios

scenario

This UI decided to go with "scenarios" instead of the usual "recent conversations" approach of the official ChatGPT.

"Scenarios" are preconfigured tasks that the AI should do, ready to be bookmarked and used whenever the task needs to be done. These can be things like:

  • Rewriting JIRA tickets
  • Grading user stories
  • Explaining code
  • Rephrasing based on corporate language

Currently, scenarios are set in scenario.ex and follow the %ChatgptWeb.Scenario struct:

      %{
        id: "generate-userstory",
        name: "๐Ÿ“— Generate Userstory",
        description:
          "Give me the content of a ticket, and I will try to write a user story for you!",
        messages: [
          %ChatgptWeb.Message{
            content:
              "You are an assistant that generates user stories for tickets. First, take the inputted text and give a summary if the entered text is a good userstory or not, with explanation why.\nThen, generate a proper user-story with the inputted text in the format of 'As a X, I want to Y, so that I can Z'.",
            sender: :system
          }
        ],
        keep_context: false
      }
  • messages are instructions to send to ChatGPT when the scenario is loaded, typically instructing the AI what it should do. Use :system messages to provide admin commands. The 3.5-turbo model is not paying so much attention to system messages, so experiment with using :user instead.
  • keep_context specifies whether the conversation context should be kept. If this is set to false (recommended), each message that is sent to the AI will be treated as a new conversation, the AI will have no context on previously sent messages.

Usage

Quick development setup:

First, install Elixir 1.14 or higher (1.13 or lower will not work). Then:

# Clone the project
git clone https://github.com/dvcrn/chatgpt-ui
cd chatgpt-ui

# Install Elixir
mix deps.get

# Install node dependencies
yarn install      # or npm install
mix assets.setup
mix assets.build

# Start the dev server
export OPENAI_API_KEY=<api-key>
export OPENAI_ORGANIZATION_KEY=<org-key>
mix phx.server

Usage / Deploying with Docker

First of all, generate a new random keybase: mix phx.gen.secret. A default is set, but you should really change this before deploying.

docker build . -t chatgpt
docker run -e SECRET_KEY_BASE=<keybase here> -e HOST="localhost" -p 4000:4000 chatgpt

The container (by default) expects the following env vars (unless you changed it in runtime.exs):

  • HOST
  • PORT (default 4000)
  • SECRET_KEY_BASE
  • OPENAI_API_KEY
  • OPENAI_ORGANIZATION_KEY

And if you use google:

  • GOOGLE_AUTH_CLIENT_ID
  • GOOGLE_AUTH_CLIENT_SECRET

Status

Super work-in-progress

chatgpt-ui's People

Contributors

dvcrn avatar freedomben avatar theodowling avatar zingbretsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.