diff --git a/drizzle.config.ts b/drizzle.config.ts deleted file mode 100644 index fc631d5..0000000 --- a/drizzle.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -//DONT FORGET TO LOAD env variables -import { defineConfig } from "drizzle-kit"; - -//Configured for SQLite with Bun sqlite -export default defineConfig({ - dialect: "sqlite", - schema: "./drizzle/migrations/schema.ts", - out: "./drizzle/migrations", - dbCredentials: { - url: process.env.DATABASE_URL as string, - }, - strict: true, - verbose: true, -}); diff --git a/drizzle/backup/lucy-bck.db b/drizzle/backup/lucy-bck.db deleted file mode 100644 index 8671b5f..0000000 Binary files a/drizzle/backup/lucy-bck.db and /dev/null differ diff --git a/drizzle/crud/ai-query.ts b/drizzle/crud/ai-query.ts deleted file mode 100644 index 84a47fa..0000000 --- a/drizzle/crud/ai-query.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* libs */ -import { eq } from "drizzle-orm"; - -/* orm */ -import { db } from "../db"; -import { tGemini, tGeminiUsage } from "../migrations/schema"; - -/* types */ -import type { - T_tGeminiSchema, - T_tGeminiUsageSchema, - T_AllGeminiTables, - T_AllGeminiSchemas, -} from "../types"; - -// =============================== - -export async function qCreate( - table: T_AllGeminiTables, - values: T_AllGeminiSchemas -): Promise { - return await db.insert(table).values(values); -} - -export async function qRead_tGemini(id: number): Promise { - return (await db.select().from(tGemini).where(eq(tGemini.geminiId, id)))[0]; -} - -export async function qRead_tGeminiUsage( - id: number -): Promise { - return ( - await db - .select() - .from(tGeminiUsage) - .where(eq(tGeminiUsage.geminiUsageId, id)) - )[0]; -} - -export async function qUpdate_tGemini( - id: number, - values: T_tGeminiSchema -): Promise { - await db.update(tGemini).set(values).where(eq(tGemini.geminiId, id)); -} - -export async function qUpdate_tGeminiUsage( - id: number, - values: T_tGeminiUsageSchema -): Promise { - await db - .update(tGeminiUsage) - .set(values) - .where(eq(tGeminiUsage.geminiUsageId, id)); -} - -export async function qDelete_tGemini(id: number): Promise { - await db.delete(tGemini).where(eq(tGemini.geminiId, id)); -} - -export async function qDelete_tGeminiUsage(id: number): Promise { - await db.delete(tGeminiUsage).where(eq(tGeminiUsage.geminiUsageId, id)); -} diff --git a/drizzle/db.ts b/drizzle/db.ts deleted file mode 100644 index 5fb905a..0000000 --- a/drizzle/db.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* libs */ -import { drizzle } from "drizzle-orm/bun-sqlite"; -import { Database } from "bun:sqlite"; - -/* constants */ -import { DATABASE_PATH } from "@/constants"; - -// ============================== - -const sqlite = new Database(DATABASE_PATH); -export const db = drizzle(sqlite); diff --git a/drizzle/lucy.db b/drizzle/lucy.db deleted file mode 100644 index 018cb42..0000000 Binary files a/drizzle/lucy.db and /dev/null differ diff --git a/drizzle/migrations/0000_wet_edwin_jarvis.sql b/drizzle/migrations/0000_wet_edwin_jarvis.sql deleted file mode 100644 index 0098aa7..0000000 --- a/drizzle/migrations/0000_wet_edwin_jarvis.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE `t_gemini` ( - `gemini_id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, - `api_key` text(255), - `model` text(255) NOT NULL, - `prompt` text(255) NOT NULL -); ---> statement-breakpoint -CREATE TABLE `t_gemini_usage` ( - `gemini_usage_id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, - `rpm_limit` integer NOT NULL, - `rpd_limit` integer NOT NULL, - `tpm_limit` integer NOT NULL, - `rpm_start` numeric, - `rpd_start` numeric, - `tpm_start` numeric, - `rpm_end` numeric, - `rpd_end` numeric, - `tpm_end` numeric, - `rpm_counter` integer, - `rpd_counter` integer, - `tpm_counter` integer, - `interval_delay` integer, - `break_delay` integer -); diff --git a/drizzle/migrations/meta/0000_snapshot.json b/drizzle/migrations/meta/0000_snapshot.json deleted file mode 100644 index caad5c4..0000000 --- a/drizzle/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "version": "6", - "dialect": "sqlite", - "id": "25e460a9-5bee-4c64-bec3-fc9055aa82e8", - "prevId": "00000000-0000-0000-0000-000000000000", - "tables": { - "t_gemini": { - "name": "t_gemini", - "columns": { - "gemini_id": { - "name": "gemini_id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "autoincrement": true - }, - "api_key": { - "name": "api_key", - "type": "text(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "model": { - "name": "model", - "type": "text(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "prompt": { - "name": "prompt", - "type": "text(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - }, - "t_gemini_usage": { - "name": "t_gemini_usage", - "columns": { - "gemini_usage_id": { - "name": "gemini_usage_id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "autoincrement": true - }, - "rpm_limit": { - "name": "rpm_limit", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "rpd_limit": { - "name": "rpd_limit", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "tpm_limit": { - "name": "tpm_limit", - "type": "integer", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "rpm_start": { - "name": "rpm_start", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rpd_start": { - "name": "rpd_start", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "tpm_start": { - "name": "tpm_start", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rpm_end": { - "name": "rpm_end", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rpd_end": { - "name": "rpd_end", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "tpm_end": { - "name": "tpm_end", - "type": "numeric", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rpm_counter": { - "name": "rpm_counter", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rpd_counter": { - "name": "rpd_counter", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "tpm_counter": { - "name": "tpm_counter", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "interval_delay": { - "name": "interval_delay", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "break_delay": { - "name": "break_delay", - "type": "integer", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {} - } - }, - "views": {}, - "enums": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "indexes": {} - } -} \ No newline at end of file diff --git a/drizzle/migrations/meta/_journal.json b/drizzle/migrations/meta/_journal.json deleted file mode 100644 index 1bde759..0000000 --- a/drizzle/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "sqlite", - "entries": [ - { - "idx": 0, - "version": "6", - "when": 1732717760452, - "tag": "0000_wet_edwin_jarvis", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/drizzle/migrations/relations.ts b/drizzle/migrations/relations.ts deleted file mode 100644 index 80768e2..0000000 --- a/drizzle/migrations/relations.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { relations } from "drizzle-orm/relations"; -import { } from "./schema"; - diff --git a/drizzle/migrations/schema.ts b/drizzle/migrations/schema.ts deleted file mode 100644 index 461573e..0000000 --- a/drizzle/migrations/schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { sqliteTable, integer, numeric, text } from "drizzle-orm/sqlite-core"; - -export const tGemini = sqliteTable("t_gemini", { - geminiId: integer("gemini_id").primaryKey({ autoIncrement: true }), - apiKey: text("api_key", { length: 255 }), - model: text({ length: 255 }).notNull(), - prompt: text({ length: 255 }).notNull(), -}); - -export const tGeminiUsage = sqliteTable("t_gemini_usage", { - geminiUsageId: integer("gemini_usage_id").primaryKey({ autoIncrement: true }), - rpmLimit: integer("rpm_limit").notNull(), - rpdLimit: integer("rpd_limit").notNull(), - tpmLimit: integer("tpm_limit").notNull(), - rpmStart: numeric("rpm_start"), - rpdStart: numeric("rpd_start"), - tpmStart: numeric("tpm_start"), - rpmEnd: numeric("rpm_end"), - rpdEnd: numeric("rpd_end"), - tpmEnd: numeric("tpm_end"), - rpmCounter: integer("rpm_counter"), - rpdCounter: integer("rpd_counter"), - tpmCounter: integer("tpm_counter"), - intervalDelay: integer("interval_delay"), - breakDelay: integer("break_delay"), -}); diff --git a/drizzle/sql/lucy-dump.sql b/drizzle/sql/lucy-dump.sql deleted file mode 100644 index f2c9217..0000000 --- a/drizzle/sql/lucy-dump.sql +++ /dev/null @@ -1,30 +0,0 @@ -PRAGMA foreign_keys=OFF; -BEGIN TRANSACTION; -CREATE TABLE t_gemini ( - gemini_id INTEGER PRIMARY KEY AUTOINCREMENT, -- Identifiant unique auto-incrémenté - api_key VARCHAR(255), -- Clé API (peut être null) - model VARCHAR(255) NOT NULL, -- Nom du modèle (obligatoire) - prompt VARCHAR(255) NOT NULL -- Prompt utilisé (obligatoire) -); -INSERT INTO t_gemini VALUES(1,'AIzaSyDS6i2kutQoRr1kj403-vcm89DHSeDeNDg','gemini-1.5-flash-8b','Analyser ce CV pour extraire et calculer le total d''années d''expérience de chaque profil mentionné. Pour chaque poste occupé, indiquer le titre du poste ainsi que le nombre d''années d''expérience associées. Si plusieurs postes sont mentionnés, additionner les années d''expérience pour donner un total global. Répondre sous la forme suivante : 1. **Titre du poste** - Nombre d''années d''expérience 2. **Titre du poste** - Nombre d''années d''expérience Total : X années d''expérience.'); -CREATE TABLE t_gemini_usage ( - gemini_usage_id INTEGER PRIMARY KEY AUTOINCREMENT, -- Identifiant unique auto-incrémenté - rpm_limit INTEGER NOT NULL, -- Limite de requêtes par minute (obligatoire) - rpd_limit INTEGER NOT NULL, -- Limite de requêtes par jour (obligatoire) - tpm_limit INTEGER NOT NULL, -- Limite de tokens par minute (obligatoire) - rpm_start DATETIME, -- Début de la période minute - rpd_start DATETIME, -- Début de la période jour - tpm_start DATETIME, -- Début de la période minute pour tokens - rpm_end DATETIME, -- Fin de la période minute - rpd_end DATETIME, -- Fin de la période jour - tpm_end DATETIME, -- Fin de la période minute pour tokens - rpm_counter INTEGER, -- Compteur de requêtes par minute - rpd_counter INTEGER, -- Compteur de requêtes par jour - tpm_counter INTEGER, -- Compteur de tokens par minute - interval_delay INTEGER NULL, -- Temps d'attente entre N+1 requêtes pour eviter les surcharge - break_delay INTEGER NULL); -INSERT INTO t_gemini_usage VALUES(1,60,1500,1000000,NULL,NULL,NULL,NULL,NULL,NULL,0,0,0,1000,5000); -DELETE FROM sqlite_sequence; -INSERT INTO sqlite_sequence VALUES('t_gemini',3); -INSERT INTO sqlite_sequence VALUES('t_gemini_usage',1); -COMMIT; diff --git a/drizzle/template/README.md b/drizzle/template/README.md deleted file mode 100644 index 6f1edd9..0000000 --- a/drizzle/template/README.md +++ /dev/null @@ -1,15 +0,0 @@ -This repository contains sample databases for the -[Build Your Own SQLite](https://codecrafters.io/challenges/sqlite) -challenge. - -1. `sample.db`: - - This is a tiny database used in stages 1-6. - - It contains two tables: `apples` and `oranges`. -2. `superheroes.db`: - - This is a small version of the test database used in stage 6. - - It contains one table: `superheroes`. - - It is ~1MB in size. -3. `companies.db`: - - This is a small version of the test database used in stage 7. - - It contains one table: `companies`, and one index: `idx_companies_country` - - It is ~7MB in size. diff --git a/drizzle/template/companies.db b/drizzle/template/companies.db deleted file mode 100644 index 49d2183..0000000 Binary files a/drizzle/template/companies.db and /dev/null differ diff --git a/drizzle/template/sample.db b/drizzle/template/sample.db deleted file mode 100644 index 687673e..0000000 Binary files a/drizzle/template/sample.db and /dev/null differ diff --git a/drizzle/template/superheroes.db b/drizzle/template/superheroes.db deleted file mode 100644 index b9ae192..0000000 Binary files a/drizzle/template/superheroes.db and /dev/null differ diff --git a/drizzle/types.d.ts b/drizzle/types.d.ts deleted file mode 100644 index 937fe1d..0000000 --- a/drizzle/types.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { tGemini, tGeminiUsage } from "./schema"; - -// =============================== - -export type T_tGemini = typeof tGemini; -export type T_tGeminiUsage = typeof tGeminiUsage; -export type T_tGeminiSchema = typeof tGemini.$inferInsert; -export type T_tGeminiUsageSchema = typeof tGeminiUsage.$inferInsert; -export type T_AllGeminiTables = T_tGemini | T_tGeminiUsage; -export type T_AllGeminiSchemas = T_tGeminiSchema | T_tGeminiUsageSchema; - -export interface I_tGemini { - geminiId: number; - apiKey: string | null; - model: string; - prompt: string; -} - -export interface I_tGeminiUsage { - geminiUsageId: number; - rpmLimit: number; - rpdLimit: number; - tpmLimit: number; - rpmStart: number | null; - rpdStart: number | null; - tpmStart: number | null; - rpmEnd: number | null; - rpdEnd: number | null; - tpmEnd: number | null; - rpmCounter: number | null; - rpdCounter: number | null; - tpmCounter: number | null; - intervalDelay: number | null; - breakDelay: number | null; -} diff --git a/src/core/ai/app.ts b/src/core/ai/app.ts deleted file mode 100644 index 63544e7..0000000 --- a/src/core/ai/app.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* api */ -import { geminiModel, fileManager } from "@/api"; - -/* constants */ -import { INPUT_FILES_PATH, PDF_MIMETYPE, TEST_PDF_FILES } from "@/constants"; - -/* core */ -import { restartAsync } from "@/core/restart"; - -/* data */ -// import { rGemini, rGeminiUsage } from "../../../drizzle/query"; - -/* utils */ -import { successMessage, errorMessage } from "@/utils/extras"; - -// ============================== - -interface I_UploadResult { - displayName: string; - mimeType: string; - uri: string; -} - -async function uploadPDF(files: string[]): Promise { - const uploadResultArray: I_UploadResult[] = []; - - const processFileUpload = async (file: string) => { - try { - const uploadResult = await fileManager.uploadFile( - `${INPUT_FILES_PATH}${file}`, - { - mimeType: PDF_MIMETYPE, - displayName: file, - } - ); - - if (uploadResult?.file) { - uploadResultArray.push({ - displayName: uploadResult.file.displayName || "N/A", - mimeType: uploadResult.file.mimeType || PDF_MIMETYPE, - uri: uploadResult.file.uri || "unknown", - }); - successMessage(file, "white_check_mark", "uploaded"); - } else { - throw new Error("Invalid upload result"); - } - } catch (error) { - errorMessage(error, "upload"); - } - }; - - await Promise.all(files.map(processFileUpload)); - return uploadResultArray; -} - -export async function app(): Promise { - // const result = await geminiModel.generateContent([ - // "Donnez-moi un resumer de ce fichier PDF.", - // { - // fileData: { - // fileUri: uploadResult.file.uri, - // mimeType: uploadResult.file.mimeType, - // }, - // }, - // ]); - - // console.log(result.response.text()); - - const result = await uploadPDF(TEST_PDF_FILES); - console.log(result); - - restartAsync(); -}