Skip to content

Commit 3004e41

Browse files
authored
Merge pull request #80 from rootcodelabs/rag-20-llm-connections-view-be
LLM connection CRUD api & integration
2 parents 8d2285f + f6c418b commit 3004e41

Some content is hidden

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

68 files changed

+3344
-294
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ __pycache__/
33
*$py.class
44
.venv/
55
.pytest_cache/
6-
.env
6+
.env
7+
tim-db
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- Schema for LLM Connections
2+
CREATE TABLE llm_connections (
3+
id SERIAL PRIMARY KEY,
4+
5+
-- LLM Model Configuration
6+
llm_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
7+
llm_model VARCHAR(100) NOT NULL, -- e.g. GPT-4o
8+
9+
-- Embedding Model Configuration
10+
embedding_platform VARCHAR(100) NOT NULL, -- e.g. Azure AI, OpenAI
11+
embedding_model VARCHAR(100) NOT NULL, -- e.g. Ada-200-1
12+
13+
-- Budget and Environment
14+
monthly_budget NUMERIC(12,2) NOT NULL, -- e.g. 1000.00
15+
environment VARCHAR(50) NOT NULL,
16+
17+
-- Metadata
18+
connection_status VARCHAR(50) DEFAULT 'active', -- active / inactive
19+
created_at TIMESTAMP DEFAULT NOW());
20+
21+
CREATE TABLE inference_results (
22+
id SERIAL PRIMARY KEY,
23+
llm_connection_id INT NOT NULL REFERENCES llm_connections(id) ON DELETE CASCADE,
24+
user_question TEXT NOT NULL, -- raw user input
25+
refined_questions JSONB, -- list of refined questions (LLM-generated)
26+
conversation_history JSONB, -- prior messages (array of {role, content})
27+
ranked_chunks JSONB, -- retrieved chunks (ranked, with metadata)
28+
embedding_scores JSONB, -- distance scores for each chunk
29+
final_answer TEXT, -- LLM’s final generated answer
30+
created_at TIMESTAMP DEFAULT NOW()
31+
);
32+
33+
CREATE TABLE inference_results_references (
34+
id SERIAL PRIMARY KEY,
35+
conversation_id INT NOT NULL REFERENCES inference_results(id) ON DELETE CASCADE,
36+
reference_url TEXT NOT NULL
37+
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- liquibase formatted sql
2+
3+
-- changeset Erangi Ariyasena:classifier-script-v3-changeset1
4+
CREATE TYPE user_status AS ENUM ('active','deleted');
5+
6+
-- changeset Erangi Ariyasena:classifier-script-v3-changeset2
7+
CREATE TABLE public."user" (
8+
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
9+
login VARCHAR(50) NOT NULL,
10+
password_hash VARCHAR(60),
11+
first_name VARCHAR(50),
12+
last_name VARCHAR(50),
13+
id_code VARCHAR(50) NOT NULL,
14+
display_name VARCHAR(50),
15+
status user_status,
16+
csa_title VARCHAR,
17+
csa_email VARCHAR,
18+
created TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
19+
CONSTRAINT user_pkey PRIMARY KEY (id)
20+
);
21+
22+
CREATE TABLE public."authority" (
23+
name VARCHAR(50) PRIMARY KEY
24+
);
25+
26+
CREATE TABLE public."user_authority" (
27+
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
28+
user_id VARCHAR(50) NOT NULL,
29+
authority_name VARCHAR[] NOT NULL,
30+
created TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
31+
CONSTRAINT user_authority_pkey PRIMARY KEY (id)
32+
);
33+
34+
-- changeset Erangi Ariyasena:classifier-script-v1-changeset3
35+
36+
INSERT INTO public."user" (login,password_hash,first_name,last_name,id_code,display_name,status,csa_title,csa_email)
37+
VALUES ('EE30303039914','ok','classifier','test','EE30303039914','classifier','active','Title','classifier.doe@example.com');
38+
39+
INSERT INTO public."user_authority" ( user_id, authority_name)
40+
VALUES ('EE30303039914', ARRAY['ROLE_ADMINISTRATOR', 'ROLE_MODEL_TRAINER'] );
41+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- liquibase formatted sql
2+
3+
-- changeset Erangi Ariyasena:classifier-script-v5-changeset1
4+
CREATE TABLE public.configuration (
5+
id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
6+
key VARCHAR(128),
7+
value VARCHAR(128),
8+
created TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
9+
deleted BOOLEAN NOT NULL DEFAULT FALSE,
10+
CONSTRAINT configuration_pkey PRIMARY KEY (id)
11+
);
12+
13+
-- changeset Erangi Ariyasena:classifier-script-v5-changeset2
14+
INSERT INTO public.configuration (key, value)
15+
VALUES ('session_length', '120');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd
7+
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd">
8+
9+
<changeSet id="rag-search-script-v4-changeset" author="Erangi Ariyasena">
10+
<loadData
11+
file="data/authority.csv"
12+
separator=";"
13+
tableName="authority">
14+
<column name="name" type="string"/>
15+
</loadData>
16+
</changeSet>
17+
</databaseChangeLog>

DSL/Liquibase/data/authority.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name
2+
ROLE_ADMINISTRATOR
3+
ROLE_MODEL_TRAINER

DSL/Liquibase/liquibase.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
changelogFile: /changelog/master.yml
2+
url: jdbc:postgresql://localhost:5436/rag-search
3+
username: postgres
4+
password: dbadmin
5+
secureParsing: false
6+
liquibase.hub.mode=off

DSL/Liquibase/master.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
databaseChangeLog:
2+
- include:
3+
file: changelog/rag-search-script-v1-llm-connections.sql
4+
- include:
5+
file: changelog/rag-search-script-v2-user-management.sql
6+
- include:
7+
file: changelog/rag-search-script-v3-configuration.sql
8+
- include:
9+
file: changelog/rag-search-script-v4-authority-data.xml

DSL/Resql/rag-search/GET/empty.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- This is a empty sql for Buerokratt DSL delivery method
2+
SELECT current_date;

DSL/Resql/rag-search/GET/get-llm-connections-paginated.sql

Whitespace-only changes.

0 commit comments

Comments
 (0)