first implementation
This commit is contained in:
52
backend/target/classes/application.yaml
Normal file
52
backend/target/classes/application.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: ${DB_URL:jdbc:postgresql://master:30432/aiteacher}
|
||||
username: ${DB_USERNAME:user}
|
||||
password: ${DB_PASSWORD:password}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
show-sql: false
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: false
|
||||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
open-in-view: false
|
||||
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: classpath:db/migration
|
||||
|
||||
ai:
|
||||
vectorstore:
|
||||
pgvector:
|
||||
dimensions: 1536
|
||||
distance-type: COSINE_DISTANCE
|
||||
index-type: HNSW
|
||||
initialize-schema: false
|
||||
openai:
|
||||
api-key: ${OPENAI_API_KEY}
|
||||
chat:
|
||||
options:
|
||||
model: gpt-4o
|
||||
embedding:
|
||||
options:
|
||||
model: "text-embedding-3-small"
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 100MB
|
||||
|
||||
task:
|
||||
execution:
|
||||
pool:
|
||||
core-size: 4
|
||||
max-size: 8
|
||||
queue-capacity: 50
|
||||
|
||||
app:
|
||||
auth:
|
||||
password: ${APP_PASSWORD:changeme}
|
||||
BIN
backend/target/classes/com/aiteacher/AiTeacherApplication.class
Normal file
BIN
backend/target/classes/com/aiteacher/AiTeacherApplication.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/book/Book.class
Normal file
BIN
backend/target/classes/com/aiteacher/book/Book.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/book/BookController.class
Normal file
BIN
backend/target/classes/com/aiteacher/book/BookController.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/book/BookRepository.class
Normal file
BIN
backend/target/classes/com/aiteacher/book/BookRepository.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/book/BookService.class
Normal file
BIN
backend/target/classes/com/aiteacher/book/BookService.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/book/BookStatus.class
Normal file
BIN
backend/target/classes/com/aiteacher/book/BookStatus.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/chat/ChatController.class
Normal file
BIN
backend/target/classes/com/aiteacher/chat/ChatController.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/chat/ChatService.class
Normal file
BIN
backend/target/classes/com/aiteacher/chat/ChatService.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/chat/ChatSession.class
Normal file
BIN
backend/target/classes/com/aiteacher/chat/ChatSession.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/chat/Message.class
Normal file
BIN
backend/target/classes/com/aiteacher/chat/Message.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/chat/MessageRole.class
Normal file
BIN
backend/target/classes/com/aiteacher/chat/MessageRole.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/config/AiConfig.class
Normal file
BIN
backend/target/classes/com/aiteacher/config/AiConfig.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/config/SecurityConfig.class
Normal file
BIN
backend/target/classes/com/aiteacher/config/SecurityConfig.class
Normal file
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/topic/Topic.class
Normal file
BIN
backend/target/classes/com/aiteacher/topic/Topic.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/target/classes/com/aiteacher/topic/TopicController.class
Normal file
BIN
backend/target/classes/com/aiteacher/topic/TopicController.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33
backend/target/classes/db/migration/V1__initial_schema.sql
Normal file
33
backend/target/classes/db/migration/V1__initial_schema.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- ============================================================
|
||||
-- V1: Initial schema
|
||||
-- Spring AI manages the vector_store table separately.
|
||||
-- ============================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS book (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
title VARCHAR(500) NOT NULL,
|
||||
file_name VARCHAR(500) NOT NULL,
|
||||
file_size_bytes BIGINT NOT NULL,
|
||||
page_count INT,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'PENDING',
|
||||
error_message TEXT,
|
||||
uploaded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
processed_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS chat_session (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
topic_id VARCHAR(100),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS message (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
session_id UUID NOT NULL REFERENCES chat_session(id) ON DELETE CASCADE,
|
||||
role VARCHAR(10) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
sources JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_session ON message(session_id, created_at);
|
||||
17
backend/target/classes/db/migration/V2__pgvector_store.sql
Normal file
17
backend/target/classes/db/migration/V2__pgvector_store.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- ============================================================
|
||||
-- V2: pgvector extension + Spring AI vector_store table
|
||||
-- Replaces Spring AI's initialize-schema=true (which requires
|
||||
-- CREATE SCHEMA privilege and fails on restricted users).
|
||||
-- ============================================================
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS vector_store (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
content text,
|
||||
metadata json,
|
||||
embedding vector(1536)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS spring_ai_vector_index
|
||||
ON vector_store USING hnsw (embedding vector_cosine_ops);
|
||||
74
backend/target/classes/topics.json
Normal file
74
backend/target/classes/topics.json
Normal file
@@ -0,0 +1,74 @@
|
||||
[
|
||||
{
|
||||
"id": "cerebral-aneurysm",
|
||||
"name": "Cerebral Aneurysm Management",
|
||||
"description": "Diagnosis, grading, and surgical/endovascular treatment of cerebral aneurysms.",
|
||||
"category": "Vascular"
|
||||
},
|
||||
{
|
||||
"id": "subarachnoid-hemorrhage",
|
||||
"name": "Subarachnoid Hemorrhage",
|
||||
"description": "Pathophysiology, clinical presentation, and management of subarachnoid hemorrhage.",
|
||||
"category": "Vascular"
|
||||
},
|
||||
{
|
||||
"id": "arteriovenous-malformation",
|
||||
"name": "Arteriovenous Malformation (AVM)",
|
||||
"description": "Classification, natural history, and treatment options for cerebral AVMs.",
|
||||
"category": "Vascular"
|
||||
},
|
||||
{
|
||||
"id": "carotid-stenosis",
|
||||
"name": "Carotid Artery Stenosis",
|
||||
"description": "Evaluation and surgical or endovascular management of carotid artery stenosis.",
|
||||
"category": "Vascular"
|
||||
},
|
||||
{
|
||||
"id": "glioblastoma",
|
||||
"name": "Glioblastoma (GBM)",
|
||||
"description": "Pathophysiology, surgical resection strategies, and adjuvant therapy for GBM.",
|
||||
"category": "Oncology"
|
||||
},
|
||||
{
|
||||
"id": "meningioma",
|
||||
"name": "Meningioma",
|
||||
"description": "Classification, surgical approaches, and recurrence management for meningiomas.",
|
||||
"category": "Oncology"
|
||||
},
|
||||
{
|
||||
"id": "pituitary-adenoma",
|
||||
"name": "Pituitary Adenoma",
|
||||
"description": "Hormonal assessment, transsphenoidal surgery, and medical management of pituitary adenomas.",
|
||||
"category": "Oncology"
|
||||
},
|
||||
{
|
||||
"id": "lumbar-disc-herniation",
|
||||
"name": "Lumbar Disc Herniation",
|
||||
"description": "Anatomy, clinical presentation, conservative and surgical treatment of lumbar disc herniation.",
|
||||
"category": "Spine"
|
||||
},
|
||||
{
|
||||
"id": "cervical-myelopathy",
|
||||
"name": "Cervical Spondylotic Myelopathy",
|
||||
"description": "Pathomechanics, clinical grading, and decompressive surgery for cervical myelopathy.",
|
||||
"category": "Spine"
|
||||
},
|
||||
{
|
||||
"id": "spinal-cord-injury",
|
||||
"name": "Spinal Cord Injury",
|
||||
"description": "ASIA classification, acute management protocols, and rehabilitation strategies for SCI.",
|
||||
"category": "Spine"
|
||||
},
|
||||
{
|
||||
"id": "traumatic-brain-injury",
|
||||
"name": "Traumatic Brain Injury (TBI)",
|
||||
"description": "GCS scoring, intracranial pressure monitoring, and surgical management of TBI.",
|
||||
"category": "Trauma"
|
||||
},
|
||||
{
|
||||
"id": "epidural-hematoma",
|
||||
"name": "Epidural Hematoma",
|
||||
"description": "Mechanism, radiological features, and emergency surgical evacuation of epidural hematomas.",
|
||||
"category": "Trauma"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user