Skip to content

Commit 65a8ab7

Browse files
committed
add initial project files
0 parents  commit 65a8ab7

60 files changed

Lines changed: 3202 additions & 0 deletions

Some content is hidden

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

‎.env.example‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Defaults. Change these as needed
2+
3+
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5445/cs_assistant
4+
REDIS_URL=redis://localhost:6370/0
5+
OLLAMA_URL=http://localhost:11434
6+
OLLAMA_CHAT_MODEL=llama3.2:3b
7+
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
8+
EMBEDDING_DIM=768
9+
TOP_K=3
10+
TEST_DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5445/cs_assistant_test

‎.github/workflows/ci.yml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: astral-sh/setup-uv@v5
14+
with:
15+
enable-cache: true
16+
python-version: "3.12"
17+
- run: uvx pre-commit run --all-files
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
services:
22+
postgres:
23+
image: pgvector/pgvector:pg17
24+
env:
25+
POSTGRES_USER: postgres
26+
POSTGRES_PASSWORD: postgres
27+
POSTGRES_DB: cs_assistant_test
28+
ports:
29+
- 5432:5432
30+
options: >-
31+
--health-cmd "pg_isready -U postgres"
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
env:
36+
# TEST_DATABASE_URL must contain "test" and differ from DATABASE_URL (conftest safety guard).
37+
# DATABASE_URL is required by Settings but never connected to during tests.
38+
TEST_DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/cs_assistant_test
39+
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/cs_assistant
40+
# Remaining vars are required by Settings; tests don't connect to these services.
41+
REDIS_URL: redis://localhost:6379/0
42+
OLLAMA_URL: http://localhost:11434
43+
OLLAMA_CHAT_MODEL: llama3.2:3b
44+
OLLAMA_EMBEDDING_MODEL: nomic-embed-text
45+
EMBEDDING_DIM: "768"
46+
TOP_K: "3"
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: astral-sh/setup-uv@v5
50+
with:
51+
enable-cache: true
52+
python-version: "3.12"
53+
- run: uv sync
54+
- run: uv run pytest

‎.gitignore‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
*.egg-info/
7+
*.egg
8+
dist/
9+
build/
10+
.eggs/
11+
12+
# Virtual environments
13+
.venv/
14+
venv/
15+
env/
16+
17+
# Environment
18+
.env
19+
20+
# Testing
21+
.pytest_cache/
22+
.coverage
23+
htmlcov/
24+
25+
# Tooling
26+
.ruff_cache/
27+
.mypy_cache/
28+
29+
# IDEs
30+
.vscode/
31+
.idea/
32+
*.swp
33+
*.swo
34+
35+
# OS
36+
.DS_Store
37+
Thumbs.db

‎.pre-commit-config.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.15.15
13+
hooks:
14+
- id: ruff
15+
args: [--fix]
16+
17+
- repo: https://github.com/psf/black
18+
rev: 26.5.1
19+
hooks:
20+
- id: black

‎Makefile‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.PHONY: setup cli migrate ingest test lint format
2+
3+
setup:
4+
uv sync
5+
6+
cli:
7+
uv run python -m src.apps.dev_cli
8+
9+
migrate:
10+
uv run alembic -c src/infrastructure/db/alembic.ini upgrade head
11+
12+
ingest:
13+
uv run python -m scripts.ingest
14+
15+
test:
16+
uv run pytest
17+
18+
lint:
19+
uv run ruff check .
20+
21+
format:
22+
uv run black .

‎data/webpages/list.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
"https://ccss.carleton.ca/resources/articles/which-electives-should-i-take/",
3+
"https://ccss.carleton.ca/resources/faqs/comp1405-z-section/",
4+
"https://carleton.ca/scs/current-students/undergraduate-students/"
5+
]

‎docker-compose.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
postgres:
3+
image: pgvector/pgvector:pg17
4+
ports:
5+
- "5445:5432"
6+
environment:
7+
POSTGRES_USER: postgres
8+
POSTGRES_PASSWORD: postgres
9+
POSTGRES_DB: cs_assistant
10+
volumes:
11+
- postgres_data:/var/lib/postgresql/data
12+
- ./docker/postgres-init:/docker-entrypoint-initdb.d:ro
13+
14+
redis:
15+
image: redis/redis-stack-server:latest
16+
ports:
17+
- "6370:6379"
18+
19+
# worker:
20+
# build: .
21+
# command: celery -A src.config.celery worker --loglevel=info
22+
# environment:
23+
# DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/cs_assistant
24+
# REDIS_URL: redis://redis:6379/0
25+
# depends_on:
26+
# - postgres
27+
# - redis
28+
#
29+
# Enabled once ingestion is wired up. The worker runs Celery tasks for
30+
# scraping and embedding documents into the vector store.
31+
32+
volumes:
33+
postgres_data:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE DATABASE cs_assistant_test;

‎pyproject.toml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[project]
2+
name = "cs-assistant"
3+
version = "0.1.0"
4+
description = "RAG-based assistant for Carleton CS students"
5+
requires-python = ">=3.12"
6+
dependencies = [
7+
"fastapi",
8+
"pydantic>=2",
9+
"pydantic-settings",
10+
"sqlalchemy[asyncio]",
11+
"asyncpg",
12+
"pgvector",
13+
"alembic",
14+
"httpx",
15+
"trafilatura",
16+
"langchain-text-splitters",
17+
"celery",
18+
"redis",
19+
"structlog",
20+
]
21+
22+
[dependency-groups]
23+
dev = [
24+
"pytest",
25+
"pytest-asyncio",
26+
"ruff",
27+
"black",
28+
"psycopg2-binary",
29+
]
30+
31+
[tool.ruff]
32+
line-length = 100
33+
target-version = "py312"
34+
35+
[tool.ruff.lint]
36+
select = ["E", "F", "I", "UP"]
37+
38+
[tool.ruff.lint.per-file-ignores]
39+
"src/completions/prompts.py" = ["E501"]
40+
41+
[tool.black]
42+
line-length = 100
43+
target-version = ["py312"]
44+
45+
[tool.pytest.ini_options]
46+
asyncio_mode = "auto"
47+
asyncio_default_fixture_loop_scope = "session"
48+
asyncio_default_test_loop_scope = "session"
49+
testpaths = ["tests"]

‎scripts/__init__.py‎

Whitespace-only changes.

0 commit comments

Comments
 (0)