Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gharbat committed May 30, 2023
0 parents commit 2a65fe6
Show file tree
Hide file tree
Showing 351 changed files with 33,420 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Backend server tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Install dependencies
run: cd backend-server && composer install --prefer-dist --no-progress --no-interaction

- name: Copy .env
run: cd backend-server && cp .env.example .env

- name: Generate key
run: cd backend-server && php artisan key:generate

- name: Run tests
run: cd backend-server && vendor/bin/phpunit
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Variables
DOCKER_COMPOSE = docker-compose

# Colors
COLOR_RESET = \033[0m
COLOR_BOLD = \033[1m
COLOR_GREEN = \033[32m
COLOR_YELLOW = \033[33m

# Targets
install:
@echo "$(COLOR_BOLD)=== Putting the services down (if already running) ===$(COLOR_RESET)"
$(DOCKER_COMPOSE) down --remove-orphans

@echo "$(COLOR_BOLD)=== Setting up Docker environment ===$(COLOR_RESET)"
# Copy .env.example to .env for backend-server
# Show warning before continue, and wait for 10 secounds
@echo "$(COLOR_BOLD)=== This will overwrite your .env files, you still have some time to abort ===$(COLOR_RESET)"
@sleep 5
@echo "$(COLOR_BOLD)=== Copying .env files ===$(COLOR_RESET)"
cp -n backend-server/.env.example backend-server/.env 2>/dev/null || true
cp -n common.env llm-server/.env 2>/dev/null || true
$(DOCKER_COMPOSE) build #--no-cache
$(DOCKER_COMPOSE) up -d #--force-recreate
@echo "$(COLOR_BOLD)=== Waiting for services to start (~20 seconds) ===$(COLOR_RESET)"
@sleep 20

@echo "$(COLOR_BOLD)=== Clearing backend server config cache ===$(COLOR_RESET)"
$(DOCKER_COMPOSE) exec backend-server php artisan config:cache

@echo "$(COLOR_BOLD)=== Run backend server server migrations ===$(COLOR_RESET)"
$(DOCKER_COMPOSE) exec backend-server php artisan migrate --seed
$(DOCKER_COMPOSE) exec backend-server php artisan storage:link
$(DOCKER_COMPOSE) run -d backend-server php artisan queue:work --timeout=200

@echo "$(COLOR_BOLD)=== Installation completed ===$(COLOR_RESET)"
@echo "$(COLOR_BOLD)=== 🔥🔥 You can now access the dashboard at -> http://localhost:8000 ===$(COLOR_RESET)"
@echo "$(COLOR_BOLD)=== Enjoy! ===$(COLOR_RESET)"

run-worker:
$(DOCKER_COMPOSE) exec backend-server php artisan queue:work --timeout=200

db-setup:
$(DOCKER_COMPOSE) exec backend-server php artisan migrate:fresh --seed

down:
$(DOCKER_COMPOSE) down --remove-orphans

exec-backend-server:
$(DOCKER_COMPOSE) exec backend-server bash
.PHONY: install down
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

[![](https://dcbadge.vercel.app/api/server/Q4DxvXGw?style=flat&compact=True)](https://discord.gg/Q4DxvXGw)
<a href="http://www.repostatus.org/#active"><img src="http://www.repostatus.org/badges/latest/active.svg" /></a>
![Tests](https://github.com/openchatai/OpenChat/actions/workflows/tests.yml/badge.svg)



![](https://gcdnb.pbrd.co/images/gjX4atjx9uKT.png?o=1)

------
# 🔥 OpenChat

**Important disclaimer:** This is an undergoing efforts to create a free & open source chatbot console that allows you to easily create unlimited chatbots using different models for your daily use. Our main goal is to make the interface simple and user-friendly for everyone. If you find this interesting, we would greatly appreciate your support in contributing to this project. We have a highly ambitious plan that we are determined to implement!

----
OpenChat is an everyday user chatbot console that simplifies the utilization of large language models. With the advancements in AI, the installation and usage of these models have become overwhelming. OpenChat aims to address this challenge by providing a two-step setup process to create a comprehensive chatbot console. It serves as a central hub for managing multiple customized chatbots.

> Currently, OpenChat supports GPT models, and we are actively working on incorporating various open-source drivers that can be activated with a single click.


https://github.com/gharbat/OpenChat/assets/32633162/2f0c4587-cd93-496c-8b1b-1ed8d8c162b4

## Try it out:
You can try it out on OpenChat.so (we use our own OpenAI/pinecone token for the demo, please be mindful on the usage, we will clear out bots every 3 hours)

## 🏁 Current Features

- Create unlimited local chatbots based on GPT-3 (and GPT-4 if available).
- Customize your chatbots by providing PDF files, websites, and soon, integrations with platforms like Notion, Confluence, and Office 365.
- Each chatbot has unlimited memory capacity, enabling seamless interaction with large files such as a 400-page PDF.
- Embed chatbots as widgets on your website or internal company tools.
- And much more!

## 🛣️ Roadmap:
- [x] Create unlimited chatbots
- [x] Share chatbots via URL
- [x] Integrate chatbots on any website using JS (as a widget on the bottom right corner)
- [x] Support GPT-3 models
- [x] Support vector database to provide chatbots with larger memory
- [x] Accept websites as a data source
- [x] Accept PDF files as a data source
- [x] Support multiple data sources per chatbot
- [ ] Support Slack integration (allow users to connect chatbots with their Slack workspaces)
- [ ] Support Intercom integration (enable users to sync chat conversations with Intercom)
- [ ] Support offline open-source models (e.g., Alpaca, LLM drivers)
- [ ] Support Confluence, Notion, Office 365, and Google Workspace
- [ ] Refactor the codebase to be API ready
- [ ] Create a new UI designer for website-embedded chatbots
- [ ] Support custom input fields for chatbots
- [ ] Support pre-defined messages with a single click

We love hearing from you! Got any cool ideas or requests? We're all ears! So, if you have something in mind, give us a shout!


## 🚀 Getting Started

- To begin, clone this Git repository:

```bash
git clone [email protected]:openchatai/OpenChat.git
```

- Update common.env with your keys:
```
OPENAI_API_KEY=# you can get it from your account in openai.com
PINECONE_API_KEY=# you can get from "API Keys" tab in pinecone
PINECONE_ENVIRONMENT=# you can get it after creating your index in pinecone
PINECONE_INDEX_NAME=# you can get it after creating your index in pinecone
```

- Navigate to the repository folder and run the following command:
```
make install
```

Once the installation is complete, you can access the OpenChat console at: http://localhost:8000



## ❤️ Thanks:
- To ![@mayooear](https://github.com/mayooear) for his work and tutorial on chatting with PDF files, we utilized a lot of his code in the LLM server.



## Disclaimer:
We quickly built this project to validate the idea, so please excuse any shortcomings in the code. You may come across several areas that require enhancements, and we truly appreciate your support by opening issues, submitting pull requests, and providing suggestions.


## License
This project is licensed under the MIT License.
18 changes: 18 additions & 0 deletions backend-server/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
29 changes: 29 additions & 0 deletions backend-server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true

APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
SESSION_DRIVER=file
SESSION_LIFETIME=120

QUEUE_CONNECTION=database
DB_CONNECTION=mysql

REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
11 changes: 11 additions & 0 deletions backend-server/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
19 changes: 19 additions & 0 deletions backend-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
36 changes: 36 additions & 0 deletions backend-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Use an official PHP runtime as the base image
FROM php:8.1-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
libpq-dev \
libzip-dev \
zip \
unzip \
git

RUN docker-php-ext-install pdo pdo_mysql

# Set the working directory
WORKDIR /var/www/html

# Copy the project files to the container
COPY . .

# Copy the .env file (assuming it's in the same directory as the Dockerfile)
COPY .env .env

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install Composer dependencies
RUN composer install --no-plugins --no-scripts

# Generate the Laravel application key
RUN php artisan key:generate

# Expose the container's port 8000 (default for `php artisan serve`)
EXPOSE 8000

# Start the Laravel development server
CMD php artisan serve --host=0.0.0.0 --port=8000
27 changes: 27 additions & 0 deletions backend-server/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
30 changes: 30 additions & 0 deletions backend-server/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
});
}
}
Loading

0 comments on commit 2a65fe6

Please sign in to comment.