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

Commit 4c1e578

Browse files
authored
Merge pull request #126 from codebanesr/feature/django
App rewrite in django
2 parents 397e053 + a4d4876 commit 4c1e578

File tree

349 files changed

+18303
-9
lines changed

Some content is hidden

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

349 files changed

+18303
-9
lines changed

.env.docker

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# For azure, can take either of azure or openai, for openai we will only need the key
2+
OPENAI_API_TYPE=openai
3+
AZURE_OPENAI_API_BASE=
4+
AZURE_OPENAI_API_KEY=
5+
AZURE_OPENAI_API_VERSION=2023-03-15-preview
6+
AZURE_OPENAI_EMBEDDING_MODEL_NAME=
7+
AZURE_OPENAI_DEPLOYMENT_NAME=
8+
AZURE_OPENAI_COMPLETION_MODEL=gpt-35-turbo
9+
10+
11+
# For openai
12+
OPENAI_API_KEY=
13+
14+
15+
16+
# azure | openai
17+
EMBEDDING_PROVIDER=azure
18+
19+
# Vector Store, PINECONE|QDRANT
20+
STORE=QDRANT
21+
22+
23+
# if using pinecone
24+
PINECONE_API_KEY=
25+
PINECONE_ENV=
26+
VECTOR_STORE_INDEX_NAME=
27+
28+
29+
# if using qdrant
30+
QDRANT_URL=http://qdrant:6333
31+
32+
33+
# optional, defaults to 15
34+
MAX_PAGES_CRAWL=1
35+
36+
# --- these will change if you decide to start testing the software
37+
CELERY_BROKER_URL=redis://redis:6379/0
38+
CELERY_RESULT_BACKEND=redis://redis:6379/0
39+
DATABASE_NAME=openchat
40+
DATABASE_USER=dbuser
41+
DATABASE_PASSWORD=dbpass
42+
DATABASE_HOST=mysql
43+
DATABASE_PORT=3306

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,16 @@ down:
6161
exec-backend-server:
6262
$(DOCKER_COMPOSE) exec backend-server bash
6363
.PHONY: install down
64+
65+
66+
# Makefile to Run docker-compose for Django App
67+
68+
.env.docker:
69+
@echo "Error: The .env.docker file is missing. Please create it before proceeding. Refer readme"
70+
@exit 1
71+
72+
install_django: .env.docker
73+
@docker-compose -f docker-compose.django.yaml up -d
74+
75+
uninstall_django:
76+
@docker-compose -f docker-compose.django.yaml down

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ make install
121121
make.bat
122122
```
123123

124+
Sure, here's the modified text with the additional line you requested:
124125

125-
Once the installation is complete, you can access the OpenChat console at: http://localhost:8000
126+
## Getting Started with the Openchat Django App
127+
128+
Start your adventure of contributing to and using OpenChat, now remade using the Python programming language. You can begin by following the instructions in the guide available here: [OpenChat Python Guide](docs/django_release.md).
126129

130+
**Kindly be aware that the transition to the Python backend includes a significant alteration related to the Qdrant vector store, constituting a breaking change.**
131+
132+
Once the installation is complete, you can access the OpenChat console at: http://localhost:8000
127133

128134
Documentation [available here](https://docs.openchat.so/introduction)
129135

common.env

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Required for openai azure ------------------------------------------------------------------
2-
# USE_AZURE_OPENAI=true
3-
# AZURE_OPENAI_API_KEY=1ddb532d770a414581c0ed9987c9ac2d
4-
# AZURE_OPENAI_API_INSTANCE_NAME=shanurrahman
5-
# AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME=emailclassifier
6-
# AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=emailclassifierembedding
7-
# AZURE_OPENAI_API_VERSION=2023-03-15-preview
2+
USE_AZURE_OPENAI=true
3+
AZURE_OPENAI_API_KEY=
4+
AZURE_OPENAI_API_INSTANCE_NAME=
5+
AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME=
6+
AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=
7+
AZURE_OPENAI_API_VERSION=2023-03-15-preview
88
# --------------------------------------------------------------------------------------------
99

1010
OPENAI_API_KEY=
1111

12-
STORE=qdrant
12+
STORE=pinecone
1313

1414
PINECONE_API_KEY=
1515
PINECONE_ENVIRONMENT=
16-
PINECONE_INDEX_NAME=
16+
VECTOR_STORE_INDEX_NAME=
1717

1818
# QDRANT_URL
1919
QDRANT_URL=http://qdrant:6333

dj_backend_server/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Ignore general OS and text editor files
2+
*.pyc
3+
__pycache__/
4+
*.pyo
5+
*.pyd
6+
*.swp
7+
.DS_Store
8+
Thumbs.db
9+
desktop.ini
10+
11+
# Ignore Django-specific files
12+
*.log
13+
*.pot
14+
*.pyc
15+
local_settings.py
16+
db.sqlite3
17+
media
18+
staticfiles
19+
20+
# Ignore development and environment files
21+
.env
22+
.env.*
23+
*.envrc
24+
.env.local
25+
.env.*.local
26+
*.sqlite3
27+
*.db
28+
*.sqlite
29+
*.pdb
30+
*.env
31+
*.pyc
32+
*.orig
33+
*.egg-info/
34+
*.egg-info
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
website_data_sources/*
38+
venv
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Django",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/manage.py",
12+
"args": [
13+
"runserver"
14+
],
15+
"django": true,
16+
"justMyCode": true
17+
},
18+
{
19+
"name": "Python: Celery Workers",
20+
"type": "python",
21+
"request": "launch",
22+
// "program": "${workspaceFolder}/path_to_celery_executable",
23+
"module": "celery",
24+
"args": [
25+
"-A",
26+
"dj_backend_server",
27+
"worker",
28+
"-l",
29+
"debug"
30+
],
31+
"env": {
32+
"OBJC_DISABLE_INITIALIZE_FORK_SAFETY": "YES",
33+
"DISABLE_SPRING": "true"
34+
},
35+
"console": "integratedTerminal",
36+
"envFile": "${workspaceFolder}/.env"
37+
}
38+
]
39+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[python]": {
3+
"editor.defaultFormatter": "ms-python.python"
4+
},
5+
"python.formatting.provider": "none"
6+
}

dj_backend_server/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.9
3+
4+
# Set environment variables for the project
5+
ENV PYTHONUNBUFFERED 1
6+
ENV DJANGO_SETTINGS_MODULE=dj_backend_server.settings
7+
8+
# Set the working directory to /app
9+
WORKDIR /app
10+
11+
# Copy the current directory contents into the container at /app
12+
COPY . /app/
13+
14+
# Install any needed packages specified in requirements.txt
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
17+
# Run migrations on startup
18+
CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]

dj_backend_server/api/__init__.py

Whitespace-only changes.

dj_backend_server/api/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

0 commit comments

Comments
 (0)