Spaces:
Sleeping
Sleeping
pierrelissope
commited on
Commit
·
fef8a16
1
Parent(s):
68f213b
deploy: added project base
Browse files- Dockerfile +18 -0
- front/.gitignore +24 -0
- front/README.md +50 -0
- front/eslint.config.js +28 -0
- front/index.html +13 -0
- front/package-lock.json +0 -0
- front/package.json +30 -0
- front/public/vite.svg +1 -0
- front/src/App.css +42 -0
- front/src/App.tsx +35 -0
- front/src/assets/react.svg +1 -0
- front/src/index.css +3 -0
- front/src/main.tsx +10 -0
- front/src/vite-env.d.ts +1 -0
- front/tailwind.config.js +8 -0
- front/tsconfig.app.json +24 -0
- front/tsconfig.app.tsbuildinfo +1 -0
- front/tsconfig.json +7 -0
- front/tsconfig.node.json +22 -0
- front/tsconfig.node.tsbuildinfo +1 -0
- front/vite.config.ts +7 -0
- main.py +24 -0
- requirements.txt +7 -0
Dockerfile
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM python:3.9
|
3 |
+
|
4 |
+
# Créer un utilisateur
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
WORKDIR /app
|
7 |
+
|
8 |
+
# Copier et installer les dépendances
|
9 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
11 |
+
|
12 |
+
# Copier l'application (y compris le dossier front)
|
13 |
+
COPY --chown=user . /app
|
14 |
+
|
15 |
+
# Changer d'utilisateur
|
16 |
+
USER user
|
17 |
+
|
18 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
front/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Logs
|
2 |
+
logs
|
3 |
+
*.log
|
4 |
+
npm-debug.log*
|
5 |
+
yarn-debug.log*
|
6 |
+
yarn-error.log*
|
7 |
+
pnpm-debug.log*
|
8 |
+
lerna-debug.log*
|
9 |
+
|
10 |
+
node_modules
|
11 |
+
dist
|
12 |
+
dist-ssr
|
13 |
+
*.local
|
14 |
+
|
15 |
+
# Editor directories and files
|
16 |
+
.vscode/*
|
17 |
+
!.vscode/extensions.json
|
18 |
+
.idea
|
19 |
+
.DS_Store
|
20 |
+
*.suo
|
21 |
+
*.ntvs*
|
22 |
+
*.njsproj
|
23 |
+
*.sln
|
24 |
+
*.sw?
|
front/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# React + TypeScript + Vite
|
2 |
+
|
3 |
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
4 |
+
|
5 |
+
Currently, two official plugins are available:
|
6 |
+
|
7 |
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
8 |
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
9 |
+
|
10 |
+
## Expanding the ESLint configuration
|
11 |
+
|
12 |
+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
13 |
+
|
14 |
+
- Configure the top-level `parserOptions` property like this:
|
15 |
+
|
16 |
+
```js
|
17 |
+
export default tseslint.config({
|
18 |
+
languageOptions: {
|
19 |
+
// other options...
|
20 |
+
parserOptions: {
|
21 |
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
22 |
+
tsconfigRootDir: import.meta.dirname,
|
23 |
+
},
|
24 |
+
},
|
25 |
+
})
|
26 |
+
```
|
27 |
+
|
28 |
+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
|
29 |
+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
|
30 |
+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
|
31 |
+
|
32 |
+
```js
|
33 |
+
// eslint.config.js
|
34 |
+
import react from 'eslint-plugin-react'
|
35 |
+
|
36 |
+
export default tseslint.config({
|
37 |
+
// Set the react version
|
38 |
+
settings: { react: { version: '18.3' } },
|
39 |
+
plugins: {
|
40 |
+
// Add the react plugin
|
41 |
+
react,
|
42 |
+
},
|
43 |
+
rules: {
|
44 |
+
// other rules...
|
45 |
+
// Enable its recommended rules
|
46 |
+
...react.configs.recommended.rules,
|
47 |
+
...react.configs['jsx-runtime'].rules,
|
48 |
+
},
|
49 |
+
})
|
50 |
+
```
|
front/eslint.config.js
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import js from '@eslint/js'
|
2 |
+
import globals from 'globals'
|
3 |
+
import reactHooks from 'eslint-plugin-react-hooks'
|
4 |
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
5 |
+
import tseslint from 'typescript-eslint'
|
6 |
+
|
7 |
+
export default tseslint.config(
|
8 |
+
{ ignores: ['dist'] },
|
9 |
+
{
|
10 |
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
11 |
+
files: ['**/*.{ts,tsx}'],
|
12 |
+
languageOptions: {
|
13 |
+
ecmaVersion: 2020,
|
14 |
+
globals: globals.browser,
|
15 |
+
},
|
16 |
+
plugins: {
|
17 |
+
'react-hooks': reactHooks,
|
18 |
+
'react-refresh': reactRefresh,
|
19 |
+
},
|
20 |
+
rules: {
|
21 |
+
...reactHooks.configs.recommended.rules,
|
22 |
+
'react-refresh/only-export-components': [
|
23 |
+
'warn',
|
24 |
+
{ allowConstantExport: true },
|
25 |
+
],
|
26 |
+
},
|
27 |
+
},
|
28 |
+
)
|
front/index.html
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
+
<title>Vite + React + TS</title>
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<div id="root"></div>
|
11 |
+
<script type="module" src="/src/main.tsx"></script>
|
12 |
+
</body>
|
13 |
+
</html>
|
front/package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
front/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "front",
|
3 |
+
"private": true,
|
4 |
+
"version": "0.0.0",
|
5 |
+
"type": "module",
|
6 |
+
"scripts": {
|
7 |
+
"dev": "vite",
|
8 |
+
"build": "tsc -b && vite build",
|
9 |
+
"lint": "eslint .",
|
10 |
+
"preview": "vite preview"
|
11 |
+
},
|
12 |
+
"dependencies": {
|
13 |
+
"react": "^18.3.1",
|
14 |
+
"react-dom": "^18.3.1"
|
15 |
+
},
|
16 |
+
"devDependencies": {
|
17 |
+
"@eslint/js": "^9.9.0",
|
18 |
+
"@types/react": "^18.3.3",
|
19 |
+
"@types/react-dom": "^18.3.0",
|
20 |
+
"@vitejs/plugin-react": "^4.3.1",
|
21 |
+
"eslint": "^9.9.0",
|
22 |
+
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
23 |
+
"eslint-plugin-react-refresh": "^0.4.9",
|
24 |
+
"globals": "^15.9.0",
|
25 |
+
"tailwindcss": "^3.4.13",
|
26 |
+
"typescript": "^5.5.3",
|
27 |
+
"typescript-eslint": "^8.0.1",
|
28 |
+
"vite": "^5.4.1"
|
29 |
+
}
|
30 |
+
}
|
front/public/vite.svg
ADDED
|
front/src/App.css
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#root {
|
2 |
+
max-width: 1280px;
|
3 |
+
margin: 0 auto;
|
4 |
+
padding: 2rem;
|
5 |
+
text-align: center;
|
6 |
+
}
|
7 |
+
|
8 |
+
.logo {
|
9 |
+
height: 6em;
|
10 |
+
padding: 1.5em;
|
11 |
+
will-change: filter;
|
12 |
+
transition: filter 300ms;
|
13 |
+
}
|
14 |
+
.logo:hover {
|
15 |
+
filter: drop-shadow(0 0 2em #646cffaa);
|
16 |
+
}
|
17 |
+
.logo.react:hover {
|
18 |
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
19 |
+
}
|
20 |
+
|
21 |
+
@keyframes logo-spin {
|
22 |
+
from {
|
23 |
+
transform: rotate(0deg);
|
24 |
+
}
|
25 |
+
to {
|
26 |
+
transform: rotate(360deg);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
@media (prefers-reduced-motion: no-preference) {
|
31 |
+
a:nth-of-type(2) .logo {
|
32 |
+
animation: logo-spin infinite 20s linear;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
.card {
|
37 |
+
padding: 2em;
|
38 |
+
}
|
39 |
+
|
40 |
+
.read-the-docs {
|
41 |
+
color: #888;
|
42 |
+
}
|
front/src/App.tsx
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useState } from 'react'
|
2 |
+
import reactLogo from './assets/react.svg'
|
3 |
+
import viteLogo from '/vite.svg'
|
4 |
+
import './App.css'
|
5 |
+
|
6 |
+
function App() {
|
7 |
+
const [count, setCount] = useState(0)
|
8 |
+
|
9 |
+
return (
|
10 |
+
<>
|
11 |
+
<div>
|
12 |
+
<a href="https://vitejs.dev" target="_blank">
|
13 |
+
<img src={viteLogo} className="logo" alt="Vite logo" />
|
14 |
+
</a>
|
15 |
+
<a href="https://react.dev" target="_blank">
|
16 |
+
<img src={reactLogo} className="logo react" alt="React logo" />
|
17 |
+
</a>
|
18 |
+
</div>
|
19 |
+
<h1>Vite + React</h1>
|
20 |
+
<div className="card">
|
21 |
+
<button onClick={() => setCount((count) => count + 1)}>
|
22 |
+
count is {count}
|
23 |
+
</button>
|
24 |
+
<p>
|
25 |
+
Edit <code>src/App.tsx</code> and save to test HMR
|
26 |
+
</p>
|
27 |
+
</div>
|
28 |
+
<p className="read-the-docs">
|
29 |
+
Click on the Vite and React logos to learn more
|
30 |
+
</p>
|
31 |
+
</>
|
32 |
+
)
|
33 |
+
}
|
34 |
+
|
35 |
+
export default App
|
front/src/assets/react.svg
ADDED
|
front/src/index.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
@tailwind base;
|
2 |
+
@tailwind components;
|
3 |
+
@tailwind utilities;
|
front/src/main.tsx
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { StrictMode } from 'react'
|
2 |
+
import { createRoot } from 'react-dom/client'
|
3 |
+
import App from './App.tsx'
|
4 |
+
import './index.css'
|
5 |
+
|
6 |
+
createRoot(document.getElementById('root')!).render(
|
7 |
+
<StrictMode>
|
8 |
+
<App />
|
9 |
+
</StrictMode>,
|
10 |
+
)
|
front/src/vite-env.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/// <reference types="vite/client" />
|
front/tailwind.config.js
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @type {import('tailwindcss').Config} */
|
2 |
+
module.exports = {
|
3 |
+
content: ["./src/**/*.{html,js}"],
|
4 |
+
theme: {
|
5 |
+
extend: {},
|
6 |
+
},
|
7 |
+
plugins: [],
|
8 |
+
};
|
front/tsconfig.app.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "ES2020",
|
4 |
+
"useDefineForClassFields": true,
|
5 |
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6 |
+
"module": "ESNext",
|
7 |
+
"skipLibCheck": true,
|
8 |
+
|
9 |
+
/* Bundler mode */
|
10 |
+
"moduleResolution": "bundler",
|
11 |
+
"allowImportingTsExtensions": true,
|
12 |
+
"isolatedModules": true,
|
13 |
+
"moduleDetection": "force",
|
14 |
+
"noEmit": true,
|
15 |
+
"jsx": "react-jsx",
|
16 |
+
|
17 |
+
/* Linting */
|
18 |
+
"strict": true,
|
19 |
+
"noUnusedLocals": true,
|
20 |
+
"noUnusedParameters": true,
|
21 |
+
"noFallthroughCasesInSwitch": true
|
22 |
+
},
|
23 |
+
"include": ["src"]
|
24 |
+
}
|
front/tsconfig.app.tsbuildinfo
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts"],"version":"5.6.2"}
|
front/tsconfig.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"files": [],
|
3 |
+
"references": [
|
4 |
+
{ "path": "./tsconfig.app.json" },
|
5 |
+
{ "path": "./tsconfig.node.json" }
|
6 |
+
]
|
7 |
+
}
|
front/tsconfig.node.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "ES2022",
|
4 |
+
"lib": ["ES2023"],
|
5 |
+
"module": "ESNext",
|
6 |
+
"skipLibCheck": true,
|
7 |
+
|
8 |
+
/* Bundler mode */
|
9 |
+
"moduleResolution": "bundler",
|
10 |
+
"allowImportingTsExtensions": true,
|
11 |
+
"isolatedModules": true,
|
12 |
+
"moduleDetection": "force",
|
13 |
+
"noEmit": true,
|
14 |
+
|
15 |
+
/* Linting */
|
16 |
+
"strict": true,
|
17 |
+
"noUnusedLocals": true,
|
18 |
+
"noUnusedParameters": true,
|
19 |
+
"noFallthroughCasesInSwitch": true
|
20 |
+
},
|
21 |
+
"include": ["vite.config.ts"]
|
22 |
+
}
|
front/tsconfig.node.tsbuildinfo
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"root":["./vite.config.ts"],"version":"5.6.2"}
|
front/vite.config.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defineConfig } from 'vite'
|
2 |
+
import react from '@vitejs/plugin-react'
|
3 |
+
|
4 |
+
// https://vitejs.dev/config/
|
5 |
+
export default defineConfig({
|
6 |
+
plugins: [react()],
|
7 |
+
})
|
main.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from fastapi import FastAPI
|
3 |
+
from fastapi.staticfiles import StaticFiles
|
4 |
+
from starlette.responses import FileResponse
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
# Initialiser le pipeline pour Flan T5
|
10 |
+
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
11 |
+
|
12 |
+
# Route d'inférence
|
13 |
+
@app.get("/infer_t5")
|
14 |
+
async def infer_t5(input: str):
|
15 |
+
output = pipe_flan(input)
|
16 |
+
return {"output": output[0]["generated_text"]}
|
17 |
+
|
18 |
+
# Monter les fichiers statiques
|
19 |
+
app.mount("/", StaticFiles(directory="front/dist", html=True), name="static")
|
20 |
+
|
21 |
+
@app.get("/")
|
22 |
+
async def index() -> FileResponse:
|
23 |
+
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
24 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.74.*
|
2 |
+
requests==2.27.*
|
3 |
+
sentencepiece==0.1.*
|
4 |
+
torch==1.11.*
|
5 |
+
transformers==4.*
|
6 |
+
uvicorn[standard]==0.17.*
|
7 |
+
numpy<2.0
|