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

Commit 2a65fe6

Browse files
committed
First commit
0 parents  commit 2a65fe6

File tree

351 files changed

+33420
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+33420
-0
lines changed

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Backend server tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: '8.1'
23+
24+
- name: Install dependencies
25+
run: cd backend-server && composer install --prefer-dist --no-progress --no-interaction
26+
27+
- name: Copy .env
28+
run: cd backend-server && cp .env.example .env
29+
30+
- name: Generate key
31+
run: cd backend-server && php artisan key:generate
32+
33+
- name: Run tests
34+
run: cd backend-server && vendor/bin/phpunit

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Variables
2+
DOCKER_COMPOSE = docker-compose
3+
4+
# Colors
5+
COLOR_RESET = \033[0m
6+
COLOR_BOLD = \033[1m
7+
COLOR_GREEN = \033[32m
8+
COLOR_YELLOW = \033[33m
9+
10+
# Targets
11+
install:
12+
@echo "$(COLOR_BOLD)=== Putting the services down (if already running) ===$(COLOR_RESET)"
13+
$(DOCKER_COMPOSE) down --remove-orphans
14+
15+
@echo "$(COLOR_BOLD)=== Setting up Docker environment ===$(COLOR_RESET)"
16+
# Copy .env.example to .env for backend-server
17+
# Show warning before continue, and wait for 10 secounds
18+
@echo "$(COLOR_BOLD)=== This will overwrite your .env files, you still have some time to abort ===$(COLOR_RESET)"
19+
@sleep 5
20+
@echo "$(COLOR_BOLD)=== Copying .env files ===$(COLOR_RESET)"
21+
cp -n backend-server/.env.example backend-server/.env 2>/dev/null || true
22+
cp -n common.env llm-server/.env 2>/dev/null || true
23+
$(DOCKER_COMPOSE) build #--no-cache
24+
$(DOCKER_COMPOSE) up -d #--force-recreate
25+
@echo "$(COLOR_BOLD)=== Waiting for services to start (~20 seconds) ===$(COLOR_RESET)"
26+
@sleep 20
27+
28+
@echo "$(COLOR_BOLD)=== Clearing backend server config cache ===$(COLOR_RESET)"
29+
$(DOCKER_COMPOSE) exec backend-server php artisan config:cache
30+
31+
@echo "$(COLOR_BOLD)=== Run backend server server migrations ===$(COLOR_RESET)"
32+
$(DOCKER_COMPOSE) exec backend-server php artisan migrate --seed
33+
$(DOCKER_COMPOSE) exec backend-server php artisan storage:link
34+
$(DOCKER_COMPOSE) run -d backend-server php artisan queue:work --timeout=200
35+
36+
@echo "$(COLOR_BOLD)=== Installation completed ===$(COLOR_RESET)"
37+
@echo "$(COLOR_BOLD)=== 🔥🔥 You can now access the dashboard at -> http://localhost:8000 ===$(COLOR_RESET)"
38+
@echo "$(COLOR_BOLD)=== Enjoy! ===$(COLOR_RESET)"
39+
40+
run-worker:
41+
$(DOCKER_COMPOSE) exec backend-server php artisan queue:work --timeout=200
42+
43+
db-setup:
44+
$(DOCKER_COMPOSE) exec backend-server php artisan migrate:fresh --seed
45+
46+
down:
47+
$(DOCKER_COMPOSE) down --remove-orphans
48+
49+
exec-backend-server:
50+
$(DOCKER_COMPOSE) exec backend-server bash
51+
.PHONY: install down

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
[![](https://dcbadge.vercel.app/api/server/Q4DxvXGw?style=flat&compact=True)](https://discord.gg/Q4DxvXGw)
3+
<a href="http://www.repostatus.org/#active"><img src="http://www.repostatus.org/badges/latest/active.svg" /></a>
4+
![Tests](https://github.com/openchatai/OpenChat/actions/workflows/tests.yml/badge.svg)
5+
6+
7+
8+
![](https://gcdnb.pbrd.co/images/gjX4atjx9uKT.png?o=1)
9+
10+
------
11+
# 🔥 OpenChat
12+
13+
**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!
14+
15+
----
16+
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.
17+
18+
> Currently, OpenChat supports GPT models, and we are actively working on incorporating various open-source drivers that can be activated with a single click.
19+
20+
21+
22+
https://github.com/gharbat/OpenChat/assets/32633162/2f0c4587-cd93-496c-8b1b-1ed8d8c162b4
23+
24+
## Try it out:
25+
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)
26+
27+
## 🏁 Current Features
28+
29+
- Create unlimited local chatbots based on GPT-3 (and GPT-4 if available).
30+
- Customize your chatbots by providing PDF files, websites, and soon, integrations with platforms like Notion, Confluence, and Office 365.
31+
- Each chatbot has unlimited memory capacity, enabling seamless interaction with large files such as a 400-page PDF.
32+
- Embed chatbots as widgets on your website or internal company tools.
33+
- And much more!
34+
35+
## 🛣️ Roadmap:
36+
- [x] Create unlimited chatbots
37+
- [x] Share chatbots via URL
38+
- [x] Integrate chatbots on any website using JS (as a widget on the bottom right corner)
39+
- [x] Support GPT-3 models
40+
- [x] Support vector database to provide chatbots with larger memory
41+
- [x] Accept websites as a data source
42+
- [x] Accept PDF files as a data source
43+
- [x] Support multiple data sources per chatbot
44+
- [ ] Support Slack integration (allow users to connect chatbots with their Slack workspaces)
45+
- [ ] Support Intercom integration (enable users to sync chat conversations with Intercom)
46+
- [ ] Support offline open-source models (e.g., Alpaca, LLM drivers)
47+
- [ ] Support Confluence, Notion, Office 365, and Google Workspace
48+
- [ ] Refactor the codebase to be API ready
49+
- [ ] Create a new UI designer for website-embedded chatbots
50+
- [ ] Support custom input fields for chatbots
51+
- [ ] Support pre-defined messages with a single click
52+
53+
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!
54+
55+
56+
## 🚀 Getting Started
57+
58+
- To begin, clone this Git repository:
59+
60+
```bash
61+
git clone git@github.com:openchatai/OpenChat.git
62+
```
63+
64+
- Update common.env with your keys:
65+
```
66+
OPENAI_API_KEY=# you can get it from your account in openai.com
67+
PINECONE_API_KEY=# you can get from "API Keys" tab in pinecone
68+
PINECONE_ENVIRONMENT=# you can get it after creating your index in pinecone
69+
PINECONE_INDEX_NAME=# you can get it after creating your index in pinecone
70+
```
71+
72+
- Navigate to the repository folder and run the following command:
73+
```
74+
make install
75+
```
76+
77+
Once the installation is complete, you can access the OpenChat console at: http://localhost:8000
78+
79+
80+
81+
## ❤️ Thanks:
82+
- 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.
83+
84+
85+
86+
## Disclaimer:
87+
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.
88+
89+
90+
## License
91+
This project is licensed under the MIT License.

backend-server/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

backend-server/.env.example

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
6+
APP_URL=http://localhost
7+
8+
LOG_CHANNEL=stack
9+
LOG_DEPRECATIONS_CHANNEL=null
10+
LOG_LEVEL=debug
11+
12+
BROADCAST_DRIVER=log
13+
CACHE_DRIVER=file
14+
FILESYSTEM_DISK=local
15+
SESSION_DRIVER=file
16+
SESSION_LIFETIME=120
17+
18+
QUEUE_CONNECTION=database
19+
DB_CONNECTION=mysql
20+
21+
REDIS_HOST=redis
22+
REDIS_PASSWORD=null
23+
REDIS_PORT=6379
24+
25+
AWS_ACCESS_KEY_ID=
26+
AWS_SECRET_ACCESS_KEY=
27+
AWS_DEFAULT_REGION=us-east-1
28+
AWS_BUCKET=
29+
AWS_USE_PATH_STYLE_ENDPOINT=false

backend-server/.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

backend-server/.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/vendor
8+
.env
9+
.env.backup
10+
.env.production
11+
.phpunit.result.cache
12+
Homestead.json
13+
Homestead.yaml
14+
auth.json
15+
npm-debug.log
16+
yarn-error.log
17+
/.fleet
18+
/.idea
19+
/.vscode

backend-server/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Use an official PHP runtime as the base image
2+
FROM php:8.1-cli
3+
4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
libpq-dev \
7+
libzip-dev \
8+
zip \
9+
unzip \
10+
git
11+
12+
RUN docker-php-ext-install pdo pdo_mysql
13+
14+
# Set the working directory
15+
WORKDIR /var/www/html
16+
17+
# Copy the project files to the container
18+
COPY . .
19+
20+
# Copy the .env file (assuming it's in the same directory as the Dockerfile)
21+
COPY .env .env
22+
23+
# Install Composer
24+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
25+
26+
# Install Composer dependencies
27+
RUN composer install --no-plugins --no-scripts
28+
29+
# Generate the Laravel application key
30+
RUN php artisan key:generate
31+
32+
# Expose the container's port 8000 (default for `php artisan serve`)
33+
EXPOSE 8000
34+
35+
# Start the Laravel development server
36+
CMD php artisan serve --host=0.0.0.0 --port=8000
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*/
13+
protected function schedule(Schedule $schedule): void
14+
{
15+
// $schedule->command('inspire')->hourly();
16+
}
17+
18+
/**
19+
* Register the commands for the application.
20+
*/
21+
protected function commands(): void
22+
{
23+
$this->load(__DIR__.'/Commands');
24+
25+
require base_path('routes/console.php');
26+
}
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* The list of the inputs that are never flashed to the session on validation exceptions.
12+
*
13+
* @var array<int, string>
14+
*/
15+
protected $dontFlash = [
16+
'current_password',
17+
'password',
18+
'password_confirmation',
19+
];
20+
21+
/**
22+
* Register the exception handling callbacks for the application.
23+
*/
24+
public function register(): void
25+
{
26+
$this->reportable(function (Throwable $e) {
27+
//
28+
});
29+
}
30+
}

0 commit comments

Comments
 (0)