├── .DS_Store
├── README.md
└── chatgpt_project
└── chatgpt_project
├── chatgpt_app
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-310.pyc
│ ├── admin.cpython-310.pyc
│ ├── apps.cpython-310.pyc
│ ├── models.cpython-310.pyc
│ ├── urls.cpython-310.pyc
│ └── views.cpython-310.pyc
├── admin.py
├── apps.py
├── migrations
│ ├── __init__.py
│ └── __pycache__
│ │ └── __init__.cpython-310.pyc
├── models.py
├── static
│ └── css
│ │ └── styles.css
├── templates
│ └── chatgpt_app
│ │ └── chat.html
├── tests.py
├── urls.py
└── views.py
├── chatgpt_project
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-310.pyc
│ ├── settings.cpython-310.pyc
│ ├── urls.cpython-310.pyc
│ └── wsgi.cpython-310.pyc
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
├── db.sqlite3
└── manage.py
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/.DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Django-ChatGPT-Interface
2 | A simple, clean django site for interacting with GPT-3.5-Turbo.
3 |
4 | 1. Install Python, Django and the 'openai' python module.
5 | 2. Paste your API key in the views.py file.
6 | 3. Run Django commands to migrate and runserver.
7 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__init__.py
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/admin.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/admin.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/apps.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/apps.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/models.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/models.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/urls.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/urls.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/views.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/__pycache__/views.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class ChatgptAppConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'chatgpt_app'
7 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/migrations/__init__.py
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/migrations/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_app/migrations/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/static/css/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: 'Roboto', sans-serif;
3 | background-color: #1f1f1f;
4 | margin: 0;
5 | padding: 0;
6 | color: #ffffff;
7 | }
8 |
9 | .container {
10 | display: flex;
11 | flex-direction: column;
12 | min-height: 100vh;
13 | padding-bottom: 20px;
14 | }
15 |
16 | .main {
17 | flex: 1;
18 | display: flex;
19 | justify-content: center;
20 | align-items: center;
21 | padding: 20px;
22 | padding-bottom: 80px; /* Add enough padding to prevent chat window content from being covered by the input area */
23 | }
24 |
25 | .main {
26 | flex: 1;
27 | display: flex;
28 | justify-content: center;
29 | align-items: flex-start; /* Change this to flex-start */
30 | padding: 20px;
31 | padding-bottom: 80px;
32 | }
33 |
34 | #chat-window {
35 | height: calc(100vh - 120px); /* Change this to take up most of the browser window */
36 | width: 100%;
37 | max-width: 800px;
38 | overflow-y: scroll;
39 | background-color: #333333; /* Change this to a slightly lighter gray than the main background */
40 | border: 1px solid #444;
41 | border-radius: 5px;
42 | padding: 10px;
43 | }
44 |
45 | #chat-window::-webkit-scrollbar {
46 | width: 10px;
47 | }
48 |
49 | #chat-window::-webkit-scrollbar-track {
50 | background-color: #2c2c2c;
51 | border-radius: 5px;
52 | }
53 |
54 | #chat-window::-webkit-scrollbar-thumb {
55 | background-color: #444;
56 | border-radius: 5px;
57 | }
58 |
59 | #chat-window::-webkit-scrollbar-thumb:hover {
60 | background-color: #555;
61 | }
62 |
63 | #chat-form {
64 | position: fixed; /* Make the input area fixed at the bottom */
65 | bottom: 0; /* Position the input area at the bottom */
66 | left: 0; /* Align the input area to the left edge */
67 | right: 0; /* Align the input area to the right edge */
68 | max-width: 800px;
69 | margin: 0 auto;
70 | display: flex;
71 | justify-content: space-between;
72 | align-items: center;
73 | padding: 0 20px;
74 | background-color: #1f1f1f; /* Match the background color with the body */
75 | }
76 |
77 | #user_input {
78 | flex-grow: 1;
79 | padding: 5px;
80 | border-radius: 5px;
81 | border: 1px solid #444;
82 | margin-right: 10px;
83 | margin-bottom: 20px;
84 | background-color: #3a3a3a;
85 | color: #ffffff;
86 | }
87 |
88 | button[type="submit"] {
89 | background-color: #007bff;
90 | color: white;
91 | font-weight: bold;
92 | border: none;
93 | margin-bottom: 20px;
94 | border-radius: 5px;
95 | padding: 7px 15px;
96 | cursor: pointer;
97 | }
98 |
99 | button[type="submit"]:hover {
100 | background-color: #0056b3;
101 | }
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/templates/chatgpt_app/chat.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ChatGPT
7 |
8 | {% load static %}
9 |
10 |
11 |
12 |
13 |
22 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('', views.chat_view, name='chat_view'),
6 | ]
7 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_app/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 | from django.http import JsonResponse
3 | import openai
4 |
5 | openai.api_key = ""
6 |
7 | def chat_view(request):
8 | if request.method == 'POST':
9 | user_input = request.POST['user_input']
10 |
11 | response = openai.ChatCompletion.create(
12 | model="gpt-3.5-turbo",
13 | messages=[
14 | {"role": "system", "content": "You are a helpful assistant."},
15 | {"role": "user", "content": user_input},
16 | ],
17 | temperature=0.5,
18 | max_tokens=150,
19 | top_p=1,
20 | frequency_penalty=0,
21 | presence_penalty=0,
22 | n=1,
23 | stop=["\nUser:"],
24 | )
25 |
26 | bot_response = response["choices"][0]["message"]["content"]
27 | return JsonResponse({'response': bot_response})
28 |
29 | return render(request, 'chatgpt_app/chat.html')
30 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_project/__init__.py
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/__init__.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/__init__.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/settings.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/settings.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/urls.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/urls.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/wsgi.cpython-310.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/chatgpt_project/__pycache__/wsgi.cpython-310.pyc
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for chatgpt_project project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chatgpt_project.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/settings.py:
--------------------------------------------------------------------------------
1 | import os
2 | from pathlib import Path
3 |
4 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
5 | BASE_DIR = Path(__file__).resolve().parent.parent
6 |
7 |
8 | # Quick-start development settings - unsuitable for production
9 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
10 |
11 | # SECURITY WARNING: keep the secret key used in production secret!
12 | SECRET_KEY = 'django-insecure-cdp@#1dd&0n8id848#%7kfnmt&y7n9nw_l&efe%l%7o_x0)#_g'
13 |
14 | # SECURITY WARNING: don't run with debug turned on in production!
15 | DEBUG = True
16 |
17 | ALLOWED_HOSTS = []
18 |
19 |
20 | # Application definition
21 |
22 | INSTALLED_APPS = [
23 | 'chatgpt_app',
24 | 'django.contrib.admin',
25 | 'django.contrib.auth',
26 | 'django.contrib.contenttypes',
27 | 'django.contrib.sessions',
28 | 'django.contrib.messages',
29 | 'django.contrib.staticfiles',
30 | ]
31 |
32 | MIDDLEWARE = [
33 | 'django.middleware.security.SecurityMiddleware',
34 | 'django.contrib.sessions.middleware.SessionMiddleware',
35 | 'django.middleware.common.CommonMiddleware',
36 | 'django.middleware.csrf.CsrfViewMiddleware',
37 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
38 | 'django.contrib.messages.middleware.MessageMiddleware',
39 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
40 | ]
41 |
42 | ROOT_URLCONF = 'chatgpt_project.urls'
43 |
44 | TEMPLATES = [
45 | {
46 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
47 | 'DIRS': [],
48 | 'APP_DIRS': True,
49 | 'OPTIONS': {
50 | 'context_processors': [
51 | 'django.template.context_processors.debug',
52 | 'django.template.context_processors.request',
53 | 'django.contrib.auth.context_processors.auth',
54 | 'django.contrib.messages.context_processors.messages',
55 | ],
56 | },
57 | },
58 | ]
59 |
60 | WSGI_APPLICATION = 'chatgpt_project.wsgi.application'
61 |
62 |
63 | # Database
64 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
65 |
66 | DATABASES = {
67 | 'default': {
68 | 'ENGINE': 'django.db.backends.sqlite3',
69 | 'NAME': BASE_DIR / 'db.sqlite3',
70 | }
71 | }
72 |
73 |
74 | # Password validation
75 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
76 |
77 | AUTH_PASSWORD_VALIDATORS = [
78 | {
79 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
80 | },
81 | {
82 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
83 | },
84 | {
85 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
86 | },
87 | {
88 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
89 | },
90 | ]
91 |
92 |
93 | # Internationalization
94 | # https://docs.djangoproject.com/en/4.1/topics/i18n/
95 |
96 | LANGUAGE_CODE = 'en-us'
97 |
98 | TIME_ZONE = 'UTC'
99 |
100 | USE_I18N = True
101 |
102 | USE_TZ = True
103 |
104 |
105 | # Static files (CSS, JavaScript, Images)
106 | # https://docs.djangoproject.com/en/4.1/howto/static-files/
107 |
108 | STATIC_URL = '/static/'
109 | STATICFILES_DIRS = [
110 | os.path.join(BASE_DIR, "chatgpt_app/static"),
111 | ]
112 |
113 |
114 | # Default primary key field type
115 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
116 |
117 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
118 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path, include
3 |
4 | urlpatterns = [
5 | path('admin/', admin.site.urls),
6 | path('', include('chatgpt_app.urls')),
7 | ]
8 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/chatgpt_project/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for chatgpt_project project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chatgpt_project.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ai-Austin/Django-ChatGPT-Interface/1be7d2cbc754af478745949b981dfe07df3838bb/chatgpt_project/chatgpt_project/db.sqlite3
--------------------------------------------------------------------------------
/chatgpt_project/chatgpt_project/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chatgpt_project.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------