Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit 515e385

Browse files
committed
Initial framework build out checkpoint.
0 parents  commit 515e385

File tree

121 files changed

+3229
-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.

121 files changed

+3229
-0
lines changed

CONTRIBUTORS.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
John Scrudato

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
The MIT License (MIT)
3+
Copyright (c) 2023, John Scrudato
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Chat All The Docs
2+
3+
An orchestration framework for LlamaIndex to build and host multiple *separate* document collections and indices so you can get honed, insightful search results for target document collections.
4+
5+
[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter)](https://github.com/cookiecutter/cookiecutter-django/)
6+
[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
7+
8+
License: MIT
9+
10+
## Settings
11+
12+
Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings.html).
13+
14+
## Basic Commands
15+
16+
### Setting Up Your Users
17+
18+
- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
19+
20+
- To create a **superuser account**, use this command:
21+
22+
$ python manage.py createsuperuser
23+
24+
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
25+
26+
### Type checks
27+
28+
Running type checks with mypy:
29+
30+
$ mypy chat_all_the_docs
31+
32+
### Test coverage
33+
34+
To run the tests, check your test coverage, and generate an HTML coverage report:
35+
36+
$ coverage run -m pytest
37+
$ coverage html
38+
$ open htmlcov/index.html
39+
40+
#### Running tests with pytest
41+
42+
$ pytest
43+
44+
### Live reloading and Sass CSS compilation
45+
46+
Moved to [Live reloading and SASS compilation](https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html#sass-compilation-live-reloading).
47+
48+
### Celery
49+
50+
This app comes with Celery.
51+
52+
To run a celery worker:
53+
54+
``` bash
55+
cd chat_all_the_docs
56+
celery -A config.celery_app worker -l info
57+
```
58+
59+
Please note: For Celery's import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right.
60+
61+
To run [periodic tasks](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html), you'll need to start the celery beat scheduler service. You can start it as a standalone process:
62+
63+
``` bash
64+
cd chat_all_the_docs
65+
celery -A config.celery_app beat
66+
```
67+
68+
or you can embed the beat service inside a worker with the `-B` option (not recommended for production use):
69+
70+
``` bash
71+
cd chat_all_the_docs
72+
celery -A config.celery_app worker -B -l info
73+
```
74+
75+
## Deployment
76+
77+
The following details how to deploy this application.
78+
79+
### Docker
80+
81+
See detailed [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html).

chat_all_the_docs/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__version__ = "0.1.0"
2+
__version_info__ = tuple(
3+
int(num) if num.isdigit() else num
4+
for num in __version__.replace("-", ".", 1).split(".")
5+
)

chat_all_the_docs/conftest.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pytest
2+
3+
from chat_all_the_docs.users.models import User
4+
from chat_all_the_docs.users.tests.factories import UserFactory
5+
6+
7+
@pytest.fixture(autouse=True)
8+
def media_storage(settings, tmpdir):
9+
settings.MEDIA_ROOT = tmpdir.strpath
10+
11+
12+
@pytest.fixture
13+
def user(db) -> User:
14+
return UserFactory()

chat_all_the_docs/contrib/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
To understand why this file is here, please read:
3+
4+
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
5+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
To understand why this file is here, please read:
3+
4+
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
5+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import django.contrib.sites.models
2+
from django.contrib.sites.models import _simple_domain_name_validator
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = []
9+
10+
operations = [
11+
migrations.CreateModel(
12+
name="Site",
13+
fields=[
14+
(
15+
"id",
16+
models.AutoField(
17+
verbose_name="ID",
18+
serialize=False,
19+
auto_created=True,
20+
primary_key=True,
21+
),
22+
),
23+
(
24+
"domain",
25+
models.CharField(
26+
max_length=100,
27+
verbose_name="domain name",
28+
validators=[_simple_domain_name_validator],
29+
),
30+
),
31+
("name", models.CharField(max_length=50, verbose_name="display name")),
32+
],
33+
options={
34+
"ordering": ("domain",),
35+
"db_table": "django_site",
36+
"verbose_name": "site",
37+
"verbose_name_plural": "sites",
38+
},
39+
bases=(models.Model,),
40+
managers=[("objects", django.contrib.sites.models.SiteManager())],
41+
)
42+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import django.contrib.sites.models
2+
from django.db import migrations, models
3+
4+
5+
class Migration(migrations.Migration):
6+
7+
dependencies = [("sites", "0001_initial")]
8+
9+
operations = [
10+
migrations.AlterField(
11+
model_name="site",
12+
name="domain",
13+
field=models.CharField(
14+
max_length=100,
15+
unique=True,
16+
validators=[django.contrib.sites.models._simple_domain_name_validator],
17+
verbose_name="domain name",
18+
),
19+
)
20+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""
2+
To understand why this file is here, please read:
3+
4+
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
5+
"""
6+
from django.conf import settings
7+
from django.db import migrations
8+
9+
10+
def _update_or_create_site_with_sequence(site_model, connection, domain, name):
11+
"""Update or create the site with default ID and keep the DB sequence in sync."""
12+
site, created = site_model.objects.update_or_create(
13+
id=settings.SITE_ID,
14+
defaults={
15+
"domain": domain,
16+
"name": name,
17+
},
18+
)
19+
if created:
20+
# We provided the ID explicitly when creating the Site entry, therefore the DB
21+
# sequence to auto-generate them wasn't used and is now out of sync. If we
22+
# don't do anything, we'll get a unique constraint violation the next time a
23+
# site is created.
24+
# To avoid this, we need to manually update DB sequence and make sure it's
25+
# greater than the maximum value.
26+
max_id = site_model.objects.order_by('-id').first().id
27+
with connection.cursor() as cursor:
28+
cursor.execute("SELECT last_value from django_site_id_seq")
29+
(current_id,) = cursor.fetchone()
30+
if current_id <= max_id:
31+
cursor.execute(
32+
"alter sequence django_site_id_seq restart with %s",
33+
[max_id + 1],
34+
)
35+
36+
37+
def update_site_forward(apps, schema_editor):
38+
"""Set site domain and name."""
39+
Site = apps.get_model("sites", "Site")
40+
_update_or_create_site_with_sequence(
41+
Site,
42+
schema_editor.connection,
43+
"chat.opensource.legal",
44+
"Chat All The Docs",
45+
)
46+
47+
48+
def update_site_backward(apps, schema_editor):
49+
"""Revert site domain and name to default."""
50+
Site = apps.get_model("sites", "Site")
51+
_update_or_create_site_with_sequence(
52+
Site,
53+
schema_editor.connection,
54+
"example.com",
55+
"example.com",
56+
)
57+
58+
59+
class Migration(migrations.Migration):
60+
61+
dependencies = [("sites", "0002_alter_domain_unique")]
62+
63+
operations = [migrations.RunPython(update_site_forward, update_site_backward)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 3.1.7 on 2021-02-04 14:49
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("sites", "0003_set_site_domain_and_name"),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name="site",
15+
options={
16+
"ordering": ["domain"],
17+
"verbose_name": "site",
18+
"verbose_name_plural": "sites",
19+
},
20+
),
21+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
To understand why this file is here, please read:
3+
4+
http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
5+
"""
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* These styles are generated from project.scss. */
2+
3+
.alert-debug {
4+
color: black;
5+
background-color: white;
6+
border-color: #d6e9c6;
7+
}
8+
9+
.alert-error {
10+
color: #b94a48;
11+
background-color: #f2dede;
12+
border-color: #eed3d7;
13+
}

chat_all_the_docs/static/fonts/.gitkeep

Whitespace-only changes.
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
/* Project specific Javascript goes here. */

chat_all_the_docs/templates/403.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Forbidden (403){% endblock %}
4+
5+
{% block content %}
6+
<h1>Forbidden (403)</h1>
7+
8+
<p>{% if exception %}{{ exception }}{% else %}You're not allowed to access this page.{% endif %}</p>
9+
{% endblock content %}

chat_all_the_docs/templates/404.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Page not found{% endblock %}
4+
5+
{% block content %}
6+
<h1>Page not found</h1>
7+
8+
<p>{% if exception %}{{ exception }}{% else %}This is not the page you were looking for.{% endif %}</p>
9+
{% endblock content %}

chat_all_the_docs/templates/500.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Server Error{% endblock %}
4+
5+
{% block content %}
6+
<h1>Ooops!!! 500</h1>
7+
8+
<h3>Looks like something went wrong!</h3>
9+
10+
<p>We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing.</p>
11+
{% endblock content %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% extends "account/base.html" %}
2+
3+
{% load i18n %}
4+
5+
{% block head_title %}{% translate "Account Inactive" %}{% endblock %}
6+
7+
{% block inner %}
8+
<h1>{% translate "Account Inactive" %}</h1>
9+
10+
<p>{% translate "This account is inactive." %}</p>
11+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends "base.html" %}
2+
{% block title %}{% block head_title %}{% endblock head_title %}{% endblock title %}
3+
4+
{% block content %}
5+
<div class="row">
6+
<div class="col-md-6 offset-md-3">
7+
{% block inner %}{% endblock %}
8+
</div>
9+
</div>
10+
{% endblock %}

0 commit comments

Comments
 (0)