Add OpenAI and PostgreSQL credential management

- Implemented OpenAICredencial class for managing OpenAI API keys.
- Created OpenAICredencialModel and OpenAICredencialMapper for SQLAlchemy integration.
- Developed OpenAICredencialRepo for CRUD operations on OpenAI credentials.
- Established OpenAICliente class for interacting with OpenAI API.
- Introduced PostgresCredencial class for managing PostgreSQL connection details.
- Created PostgresCredencialModel and PostgresCredencialMapper for SQLAlchemy integration.
- Developed PostgresCredencialRepo for CRUD operations on PostgreSQL credentials.
- Added base connection class and PostgreSQL connection implementation.
- Included environment variable loading for sensitive data management.
This commit is contained in:
2025-05-05 23:54:17 +02:00
parent 7b6f525809
commit 613cd90662
56 changed files with 16237 additions and 131 deletions
+4 -4
View File
@@ -15,9 +15,9 @@
} }
], ],
"source": [ "source": [
"from backend.ApiKeys.openai_apikey import OpenAICredencial\n", "from src.ApiKeys.openai_apikey import OpenAICredencial\n",
"from backend.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo # Ajusta si está en otro módulo\n", "from src.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo # Ajusta si está en otro módulo\n",
"from backend.ConexionSql.Postgres_conexion import PostgresConexion\n", "from src.ConexionSql.Postgres_conexion import PostgresConexion\n",
"\n", "\n",
"# 1. Crear instancia de conexión (asegúrate de configurar bien tu conexión en Base_conexion)\n", "# 1. Crear instancia de conexión (asegúrate de configurar bien tu conexión en Base_conexion)\n",
"from entrypoint.init_db import db_credencial\n", "from entrypoint.init_db import db_credencial\n",
@@ -36,7 +36,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from backend.ConexionApis.OpenAi_conexion import OpenAICliente\n", "from src.ConexionApis.OpenAi_conexion import OpenAICliente\n",
"\n", "\n",
"cliente = OpenAICliente(credencial_openai)\n", "cliente = OpenAICliente(credencial_openai)\n",
"\n", "\n",
+3 -3
View File
@@ -2,13 +2,13 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "5206b9c6", "id": "5206b9c6",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from backend.ConexionSql.Postgres_conexion import PostgresConexion\n", "from src.ConexionSql.Postgres_conexion import PostgresConexion\n",
"from backend.Credenciales.postgres_credencial_mmr import PostgresCredencialRepo\n", "from src.Credenciales.postgres_credencial_mmr import PostgresCredencialRepo\n",
"\n" "\n"
] ]
}, },
-97
View File
@@ -1,97 +0,0 @@
E:\Fitz_Studio
├── .git
│ ├── FETCH_HEAD
│ ├── HEAD
│ ├── config
│ ├── description
│ ├── hooks
│ │ ├── applypatch-msg.sample
│ │ ├── commit-msg.sample
│ │ ├── fsmonitor-watchman.sample
│ │ ├── post-update.sample
│ │ ├── pre-applypatch.sample
│ │ ├── pre-commit.sample
│ │ ├── pre-merge-commit.sample
│ │ ├── pre-push.sample
│ │ ├── pre-rebase.sample
│ │ ├── pre-receive.sample
│ │ ├── prepare-commit-msg.sample
│ │ ├── push-to-checkout.sample
│ │ ├── sendemail-validate.sample
│ │ └── update.sample
│ ├── info
│ │ └── exclude
│ ├── objects
│ │ ├── info
│ │ └── pack
│ └── refs
│ ├── heads
│ └── tags
├── .gitignore
├── .python-version
├── .venv
│ ├── .gitignore
│ ├── .lock
│ ├── CACHEDIR.TAG
│ ├── Lib
│ │ └── site-packages
│ ├── Scripts
│ │ ├── activate
│ │ ├── activate.bat
│ │ ├── activate.csh
│ │ ├── activate.fish
│ │ ├── activate.nu
│ │ ├── activate.ps1
│ │ ├── activate_this.py
│ │ ├── deactivate.bat
│ │ ├── dotenv.exe
│ │ ├── pip.exe
│ │ ├── pip3.11.exe
│ │ ├── pip3.exe
│ │ ├── pydoc.bat
│ │ ├── python.exe
│ │ └── pythonw.exe
│ ├── include
│ │ └── site
│ └── pyvenv.cfg
├── README.md
├── backend
│ ├── ConexionSql
│ │ ├── Base_conexion.py
│ │ ├── Postgres_conexion.py
│ │ ├── __init__.py
│ │ └── __pycache__
│ ├── Credenciales
│ │ ├── __init__.py
│ │ ├── postgres_credencial.py
│ │ └── postgres_credencial_mmr.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-311.pyc
│ │ └── base.cpython-311.pyc
│ └── base.py
├── config
│ └── .env
├── data
│ ├── files
│ │ └── tree.txt
│ ├── postgresql
│ │ ├── docker-compose.yml
│ │ └── pgdata
│ └── sqlite
├── entrypoint
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-311.pyc
│ │ └── init_db.cpython-311.pyc
│ ├── add_to_pythonpath.ps1
│ └── init_db.py
├── main.py
├── pyproject.toml
└── scripts
├── __init_.py
├── __pycache__
│ └── prueba_carga_postrgesql.cpython-311.pyc
├── datos_para_llms
│ └── generar_tree.py
└── prueba_carga_postrgesql.py
+5 -5
View File
@@ -1,11 +1,11 @@
# entrypoint/init_db.py # entrypoint/init_db.py
from backend.base import Base from src.base import Base
from backend.ConexionSql.Postgres_conexion import PostgresConexion # Asegúrate de tener esta clase implementada correctamente from src.ConexionSql.Postgres_conexion import PostgresConexion # Asegúrate de tener esta clase implementada correctamente
from backend.Credenciales.postgres_credencial import PostgresCredencial # Asegúrate de tener esta clase implementada correctamente from src.Credenciales.postgres_credencial import PostgresCredencial # Asegúrate de tener esta clase implementada correctamente
from backend.Credenciales.postgres_credencial_mmr import PostgresCredencialModel from src.Credenciales.postgres_credencial_mmr import PostgresCredencialModel
from backend.ApiKeys.openai_apikey_mmr import OpenAICredencialModel from src.ApiKeys.openai_apikey_mmr import OpenAICredencialModel
from llms.Modelos.Openai_model_mmr import ModeloOpenAIConfigModel from llms.Modelos.Openai_model_mmr import ModeloOpenAIConfigModel
from dotenv import load_dotenv from dotenv import load_dotenv
+27
View File
@@ -0,0 +1,27 @@
name: npm test
on:
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
test_pull_request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- name: Install dependencies
run: yarn
- name: Run build
run: npm run build
- name: Run tests
run: npm test
+132
View File
@@ -0,0 +1,132 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.DS_Store
+1
View File
@@ -0,0 +1 @@
v22.11.0
+35
View File
@@ -0,0 +1,35 @@
/** @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig} */
const config = {
printWidth: 100,
singleQuote: true,
trailingComma: 'es5',
plugins: ['@ianvs/prettier-plugin-sort-imports'],
importOrder: [
'.*styles.css$',
'',
'dayjs',
'^react$',
'^next$',
'^next/.*$',
'<BUILTIN_MODULES>',
'<THIRD_PARTY_MODULES>',
'^@mantine/(.*)$',
'^@mantinex/(.*)$',
'^@mantine-tests/(.*)$',
'^@docs/(.*)$',
'^@/.*$',
'^../(?!.*.css$).*$',
'^./(?!.*.css$).*$',
'\\.css$',
],
overrides: [
{
files: '*.mdx',
options: {
printWidth: 70,
},
},
],
};
export default config;
+17
View File
@@ -0,0 +1,17 @@
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
core: {
disableWhatsNewNotifications: true,
disableTelemetry: true,
enableCrashReports: false,
},
stories: ['../src/**/*.mdx', '../src/**/*.story.@(js|jsx|ts|tsx)'],
addons: ['storybook-dark-mode'],
framework: {
name: '@storybook/react-vite',
options: {},
},
};
export default config;
+33
View File
@@ -0,0 +1,33 @@
import '@mantine/core/styles.css';
import React, { useEffect } from 'react';
import { addons } from '@storybook/preview-api';
import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';
import { MantineProvider, useMantineColorScheme } from '@mantine/core';
import { theme } from '../src/theme';
const channel = addons.getChannel();
export const parameters = {
layout: 'fullscreen',
options: {
showPanel: false,
},
};
function ColorSchemeWrapper({ children }: { children: React.ReactNode }) {
const { setColorScheme } = useMantineColorScheme();
const handleColorScheme = (value: boolean) => setColorScheme(value ? 'dark' : 'light');
useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, handleColorScheme);
return () => channel.off(DARK_MODE_EVENT_NAME, handleColorScheme);
}, [channel]);
return children;
}
export const decorators = [
(renderStory: any) => <ColorSchemeWrapper>{renderStory()}</ColorSchemeWrapper>,
(renderStory: any) => <MantineProvider theme={theme}>{renderStory()}</MantineProvider>,
];
+1
View File
@@ -0,0 +1 @@
dist
+28
View File
@@ -0,0 +1,28 @@
{
"extends": ["stylelint-config-standard-scss"],
"rules": {
"custom-property-pattern": null,
"selector-class-pattern": null,
"scss/no-duplicate-mixins": null,
"declaration-empty-line-before": null,
"declaration-block-no-redundant-longhand-properties": null,
"alpha-value-notation": null,
"custom-property-empty-line-before": null,
"property-no-vendor-prefix": null,
"color-function-notation": null,
"length-zero-no-unit": null,
"selector-not-notation": null,
"no-descending-specificity": null,
"comment-empty-line-before": null,
"scss/at-mixin-pattern": null,
"scss/at-rule-no-unknown": null,
"value-keyword-case": null,
"media-feature-range-notation": null,
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": ["global"]
}
]
}
}
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.9.1.cjs
+34
View File
@@ -0,0 +1,34 @@
# Mantine Vite template
## Features
This template comes with the following features:
- [PostCSS](https://postcss.org/) with [mantine-postcss-preset](https://mantine.dev/styles/postcss-preset)
- [TypeScript](https://www.typescriptlang.org/)
- [Storybook](https://storybook.js.org/)
- [Vitest](https://vitest.dev/) setup with [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
- ESLint setup with [eslint-config-mantine](https://github.com/mantinedev/eslint-config-mantine)
## npm scripts
## Build and dev scripts
- `dev` start development server
- `build` build production version of the app
- `preview` locally preview production build
### Testing scripts
- `typecheck` checks TypeScript types
- `lint` runs ESLint
- `prettier:check` checks files with Prettier
- `vitest` runs vitest tests
- `vitest:watch` starts vitest watch
- `test` runs `vitest`, `prettier:check`, `lint` and `typecheck` scripts
### Other scripts
- `storybook` starts storybook dev server
- `storybook:build` build production storybook bundle to `storybook-static`
- `prettier:write` formats all files with Prettier
+11
View File
@@ -0,0 +1,11 @@
import mantine from 'eslint-config-mantine';
import tseslint from 'typescript-eslint';
export default tseslint.config(
...mantine,
{ ignores: ['**/*.{mjs,cjs,js,d.ts,d.mts}', './.storybook/main.ts'] },
{
files: ['**/*.story.tsx'],
rules: { 'no-console': 'off' },
}
);
+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width, user-scalable=no"
/>
<title>Vite + Mantine App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+9940
View File
File diff suppressed because it is too large Load Diff
+64
View File
@@ -0,0 +1,64 @@
{
"name": "mantine-vite-template",
"private": true,
"type": "module",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit",
"lint": "npm run eslint && npm run stylelint",
"eslint": "eslint . --cache",
"stylelint": "stylelint '**/*.css' --cache",
"prettier": "prettier --check \"**/*.{ts,tsx}\"",
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
"vitest": "vitest run",
"vitest:watch": "vitest",
"test": "npm run typecheck && npm run prettier && npm run lint && npm run vitest && npm run build",
"storybook": "storybook dev -p 6006",
"storybook:build": "storybook build"
},
"dependencies": {
"@mantine/core": "8.0.0",
"@mantine/hooks": "8.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router-dom": "^7.4.0"
},
"devDependencies": {
"@eslint/js": "^9.23.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@storybook/react": "^8.6.8",
"@storybook/react-vite": "^8.6.8",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^22.13.11",
"@types/react": "^19.0.12",
"@types/react-dom": "^19.0.4",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.23.0",
"eslint-config-mantine": "^4.0.3",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.4",
"identity-obj-proxy": "^3.0.0",
"jsdom": "^26.0.0",
"postcss": "^8.5.3",
"postcss-preset-mantine": "1.17.0",
"postcss-simple-vars": "^7.0.1",
"prettier": "^3.5.3",
"prop-types": "^15.8.1",
"storybook": "^8.6.8",
"storybook-dark-mode": "^4.0.2",
"stylelint": "^16.16.0",
"stylelint-config-standard-scss": "^14.0.0",
"typescript": "^5.8.2",
"typescript-eslint": "^8.27.0",
"vite": "^6.2.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.9"
},
"packageManager": "yarn@4.9.1"
}
+14
View File
@@ -0,0 +1,14 @@
module.exports = {
plugins: {
'postcss-preset-mantine': {},
'postcss-simple-vars': {
variables: {
'mantine-breakpoint-xs': '36em',
'mantine-breakpoint-sm': '48em',
'mantine-breakpoint-md': '62em',
'mantine-breakpoint-lg': '75em',
'mantine-breakpoint-xl': '88em',
},
},
},
};
+13
View File
@@ -0,0 +1,13 @@
import '@mantine/core/styles.css';
import { MantineProvider } from '@mantine/core';
import { Router } from './Router';
import { theme } from './theme';
export default function App() {
return (
<MantineProvider theme={theme}>
<Router />
</MantineProvider>
);
}
+13
View File
@@ -0,0 +1,13 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { HomePage } from './pages/Home.page';
const router = createBrowserRouter([
{
path: '/',
element: <HomePage />,
},
]);
export function Router() {
return <RouterProvider router={router} />;
}
@@ -0,0 +1,13 @@
import { Button, Group, useMantineColorScheme } from '@mantine/core';
export function ColorSchemeToggle() {
const { setColorScheme } = useMantineColorScheme();
return (
<Group justify="center" mt="xl">
<Button onClick={() => setColorScheme('light')}>Light</Button>
<Button onClick={() => setColorScheme('dark')}>Dark</Button>
<Button onClick={() => setColorScheme('auto')}>Auto</Button>
</Group>
);
}
@@ -0,0 +1,10 @@
.title {
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
font-size: rem(100px);
font-weight: 900;
letter-spacing: rem(-2px);
@media (max-width: $mantine-breakpoint-md) {
font-size: rem(50px);
}
}
@@ -0,0 +1,7 @@
import { Welcome } from './Welcome';
export default {
title: 'Welcome',
};
export const Usage = () => <Welcome />;
@@ -0,0 +1,12 @@
import { render, screen } from '@test-utils';
import { Welcome } from './Welcome';
describe('Welcome component', () => {
it('has correct Vite guide link', () => {
render(<Welcome />);
expect(screen.getByText('this guide')).toHaveAttribute(
'href',
'https://mantine.dev/guides/vite/'
);
});
});
@@ -0,0 +1,23 @@
import { Anchor, Text, Title } from '@mantine/core';
import classes from './Welcome.module.css';
export function Welcome() {
return (
<>
<Title className={classes.title} ta="center" mt={100}>
Welcome to{' '}
<Text inherit variant="gradient" component="span" gradient={{ from: 'pink', to: 'yellow' }}>
Mantine
</Text>
</Title>
<Text c="dimmed" ta="center" size="lg" maw={580} mx="auto" mt="xl">
This starter Vite project includes a minimal setup, if you want to learn more on Mantine +
Vite integration follow{' '}
<Anchor href="https://mantine.dev/guides/vite/" size="lg">
this guide
</Anchor>
. To get started edit pages/Home.page.tsx file.
</Text>
</>
);
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 163 163"><path fill="#339AF0" d="M162.162 81.5c0-45.011-36.301-81.5-81.08-81.5C36.301 0 0 36.489 0 81.5 0 126.51 36.301 163 81.081 163s81.081-36.49 81.081-81.5z"/><path fill="#fff" d="M65.983 43.049a6.234 6.234 0 00-.336 6.884 6.14 6.14 0 001.618 1.786c9.444 7.036 14.866 17.794 14.866 29.52 0 11.726-5.422 22.484-14.866 29.52a6.145 6.145 0 00-1.616 1.786 6.21 6.21 0 00-.694 4.693 6.21 6.21 0 001.028 2.186 6.151 6.151 0 006.457 2.319 6.154 6.154 0 002.177-1.035 50.083 50.083 0 007.947-7.39h17.493c3.406 0 6.174-2.772 6.174-6.194s-2.762-6.194-6.174-6.194h-9.655a49.165 49.165 0 004.071-19.69 49.167 49.167 0 00-4.07-19.692h9.66c3.406 0 6.173-2.771 6.173-6.194 0-3.422-2.762-6.193-6.173-6.193H82.574a50.112 50.112 0 00-7.952-7.397 6.15 6.15 0 00-4.578-1.153 6.189 6.189 0 00-4.055 2.438h-.006z"/><path fill="#fff" fill-rule="evenodd" d="M56.236 79.391a9.342 9.342 0 01.632-3.608 9.262 9.262 0 011.967-3.077 9.143 9.143 0 012.994-2.063 9.06 9.06 0 017.103 0 9.145 9.145 0 012.995 2.063 9.262 9.262 0 011.967 3.077 9.339 9.339 0 01-2.125 10.003 9.094 9.094 0 01-6.388 2.63 9.094 9.094 0 01-6.39-2.63 9.3 9.3 0 01-2.755-6.395z" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+4
View File
@@ -0,0 +1,4 @@
import ReactDOM from 'react-dom/client';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
+11
View File
@@ -0,0 +1,11 @@
import { ColorSchemeToggle } from '../components/ColorSchemeToggle/ColorSchemeToggle';
import { Welcome } from '../components/Welcome/Welcome';
export function HomePage() {
return (
<>
<Welcome />
<ColorSchemeToggle />
</>
);
}
+5
View File
@@ -0,0 +1,5 @@
import { createTheme } from '@mantine/core';
export const theme = createTheme({
/** Put your mantine theme override here */
});
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+5
View File
@@ -0,0 +1,5 @@
import userEvent from '@testing-library/user-event';
export * from '@testing-library/react';
export { render } from './render';
export { userEvent };
+11
View File
@@ -0,0 +1,11 @@
import { render as testingLibraryRender } from '@testing-library/react';
import { MantineProvider } from '@mantine/core';
import { theme } from '../src/theme';
export function render(ui: React.ReactNode) {
return testingLibraryRender(ui, {
wrapper: ({ children }: { children: React.ReactNode }) => (
<MantineProvider theme={theme}>{children}</MantineProvider>
),
});
}
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"types": ["node", "@testing-library/jest-dom", "vitest/globals"],
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@/*": ["./src/*"],
"@test-utils": ["./test-utils"]
}
},
"include": ["src", "test-utils"]
}
+12
View File
@@ -0,0 +1,12 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest.setup.mjs',
},
});
+28
View File
@@ -0,0 +1,28 @@
import '@testing-library/jest-dom/vitest';
import { vi } from 'vitest';
const { getComputedStyle } = window;
window.getComputedStyle = (elt) => getComputedStyle(elt);
window.HTMLElement.prototype.scrollIntoView = () => {};
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
class ResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
}
window.ResizeObserver = ResizeObserver;
+4705
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,8 +1,8 @@
from sqlalchemy import Table, Column, Integer, String, MetaData, insert, select, delete from sqlalchemy import Table, Column, Integer, String, MetaData, insert, select, delete
from typing import Literal from typing import Literal
from backend.Credenciales.postgres_credencial import PostgresCredencial from src.Credenciales.postgres_credencial import PostgresCredencial
from backend.ConexionSql.Postgres_conexion import PostgresConexion # Usamos la clase específica from src.ConexionSql.Postgres_conexion import PostgresConexion # Usamos la clase específica
from llms.Memory.Base_MemoryConv import MemoryConvABC from llms.Memory.Base_MemoryConv import MemoryConvABC
+1 -1
View File
@@ -1,5 +1,5 @@
from llms.Modelos.Base_model import ModeloABC from llms.Modelos.Base_model import ModeloABC
from backend.ConexionApis.OpenAi_conexion import OpenAICliente from src.ConexionApis.OpenAi_conexion import OpenAICliente
class ModeloOpenAI(ModeloABC): class ModeloOpenAI(ModeloABC):
def __init__( def __init__(
+2 -2
View File
@@ -2,8 +2,8 @@ import os
from dotenv import load_dotenv from dotenv import load_dotenv
from sqlalchemy import Column, Integer, String, Float, Boolean from sqlalchemy import Column, Integer, String, Float, Boolean
from backend.ConexionSql.Base_conexion import ConexionBase from src.ConexionSql.Base_conexion import ConexionBase
from backend.base import Base from src.base import Base
from llms.Modelos.Openai_model import ModeloOpenAI # Clase real de lógica from llms.Modelos.Openai_model import ModeloOpenAI # Clase real de lógica
# ---------------------- # ----------------------
+4 -4
View File
@@ -1,9 +1,9 @@
import asyncio import asyncio
from backend.ApiKeys.openai_apikey import OpenAICredencial from src.ApiKeys.openai_apikey import OpenAICredencial
from backend.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo from src.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo
from backend.ConexionSql.Postgres_conexion import PostgresConexion from src.ConexionSql.Postgres_conexion import PostgresConexion
from entrypoint.init_db import db_credencial from entrypoint.init_db import db_credencial
from backend.ConexionApis.OpenAi_conexion import OpenAICliente from src.ConexionApis.OpenAi_conexion import OpenAICliente
from llms.Modelos.Openai_model import ModeloOpenAI from llms.Modelos.Openai_model import ModeloOpenAI
from llms.Agente import AgenteAI from llms.Agente import AgenteAI
+4 -4
View File
@@ -27,9 +27,9 @@ if __name__ == "__main__":
from backend.ApiKeys.openai_apikey import OpenAICredencial from src.ApiKeys.openai_apikey import OpenAICredencial
from backend.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo # Ajusta si está en otro módulo from src.ApiKeys.openai_apikey_mmr import OpenAICredencialRepo # Ajusta si está en otro módulo
from backend.ConexionSql.Postgres_conexion import PostgresConexion from src.ConexionSql.Postgres_conexion import PostgresConexion
# 1. Crear instancia de conexión (asegúrate de configurar bien tu conexión en Base_conexion) # 1. Crear instancia de conexión (asegúrate de configurar bien tu conexión en Base_conexion)
from entrypoint.init_db import db_credencial from entrypoint.init_db import db_credencial
@@ -40,7 +40,7 @@ repo = OpenAICredencialRepo(conexion_admin)
credencial_openai = repo.get_by_id(1) credencial_openai = repo.get_by_id(1)
print(f"✅ Credencial: {credencial_openai.titulo}") print(f"✅ Credencial: {credencial_openai.titulo}")
from backend.ConexionApis.OpenAi_conexion import OpenAICliente from src.ConexionApis.OpenAi_conexion import OpenAICliente
cliente = OpenAICliente(credencial_openai) cliente = OpenAICliente(credencial_openai)
@@ -3,9 +3,9 @@ import base64
from dotenv import load_dotenv from dotenv import load_dotenv
from sqlalchemy import Column, Integer, String from sqlalchemy import Column, Integer, String
from backend.ConexionSql.Base_conexion import ConexionBase from src.ConexionSql.Base_conexion import ConexionBase
from backend.base import Base from src.base import Base
from backend.ApiKeys.openai_apikey import OpenAICredencial from src.ApiKeys.openai_apikey import OpenAICredencial
from security.Encriptar import Encriptar_fernet from security.Encriptar import Encriptar_fernet
from entrypoint import ENV_PATH from entrypoint import ENV_PATH
@@ -1,5 +1,5 @@
from openai import OpenAI from openai import OpenAI
from backend.ApiKeys.openai_apikey import OpenAICredencial from src.ApiKeys.openai_apikey import OpenAICredencial
class OpenAICliente: class OpenAICliente:
def __init__(self, credencial: OpenAICredencial): def __init__(self, credencial: OpenAICredencial):
@@ -3,8 +3,8 @@ from sqlalchemy import create_engine, text
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from backend.ConexionSql.Base_conexion import ConexionBase from src.ConexionSql.Base_conexion import ConexionBase
from backend.Credenciales.postgres_credencial import PostgresCredencial from src.Credenciales.postgres_credencial import PostgresCredencial
class PostgresConexion(ConexionBase): class PostgresConexion(ConexionBase):
@@ -3,9 +3,9 @@ from dotenv import load_dotenv
from sqlalchemy import Column, Integer, String from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from backend.ConexionSql.Base_conexion import ConexionBase from src.ConexionSql.Base_conexion import ConexionBase
from backend.base import Base from src.base import Base
from backend.Credenciales.postgres_credencial import PostgresCredencial from src.Credenciales.postgres_credencial import PostgresCredencial
from security.Encriptar import Encriptar_fernet from security.Encriptar import Encriptar_fernet
# ---------------------- # ----------------------
View File