Tbruand
commited on
Commit
·
3ece550
1
Parent(s):
c4dd07c
chore(): nitial commit - project structure
Browse files- .cz.toml +29 -0
- app/handler.py +13 -0
- app/interface.py +12 -0
- main.py +4 -0
- models/base.py +6 -0
- requirements.txt +6 -0
- tests/test_handler.py +5 -0
.cz.toml
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.commitizen]
|
| 2 |
+
name = "cz_customize"
|
| 3 |
+
tag_format = "v$version"
|
| 4 |
+
version = "0.1.0"
|
| 5 |
+
version_scheme = "semver"
|
| 6 |
+
update_changelog_on_bump = true
|
| 7 |
+
major_version_zero = true
|
| 8 |
+
|
| 9 |
+
[tool.commitizen.customize]
|
| 10 |
+
message_template = "{{type}}({{scope}}): {{message}}"
|
| 11 |
+
questions = [
|
| 12 |
+
{ name = "type", type = "list", message = "Select the type of change you are committing", choices = [
|
| 13 |
+
{ value = "feat", name = "feat: A new feature. Correlates with MINOR in SemVer" },
|
| 14 |
+
{ value = "fix", name = "fix: A bug fix. Correlates with PATCH in SemVer" },
|
| 15 |
+
{ value = "docs", name = "docs: Documentation only changes" },
|
| 16 |
+
{ value = "style", name = "style: Changes that do not affect the meaning of the code" },
|
| 17 |
+
{ value = "refactor", name = "refactor: A code change that neither fixes a bug nor adds a feature" },
|
| 18 |
+
{ value = "perf", name = "perf: A code change that improves performance" },
|
| 19 |
+
{ value = "test", name = "test: Adding or correcting tests" },
|
| 20 |
+
{ value = "build", name = "build: Changes that affect the build system or dependencies" },
|
| 21 |
+
{ value = "ci", name = "ci: Changes to CI/CD configuration" },
|
| 22 |
+
{ value = "chore", name = "chore: Routine tasks like config or meta updates" }
|
| 23 |
+
] },
|
| 24 |
+
{ name = "scope", type = "input", message = "What is the scope of this change (e.g. component or file name):" },
|
| 25 |
+
{ name = "message", type = "input", message = "Write a short, imperative tense description of the change:" },
|
| 26 |
+
{ name = "body", type = "input", message = "Provide a longer description of the change (optional):" },
|
| 27 |
+
{ name = "is_breaking_change", type = "confirm", message = "Are there any breaking changes?" },
|
| 28 |
+
{ name = "breaking_change", type = "input", message = "Describe the breaking changes:" }
|
| 29 |
+
]
|
app/handler.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from models.base import BaseModel
|
| 2 |
+
|
| 3 |
+
# Exemple de modèle minimal
|
| 4 |
+
class DummyModel(BaseModel):
|
| 5 |
+
def predict(self, text):
|
| 6 |
+
if "stupide" in text.lower():
|
| 7 |
+
return "toxique"
|
| 8 |
+
return "non-toxique"
|
| 9 |
+
|
| 10 |
+
dummy = DummyModel()
|
| 11 |
+
|
| 12 |
+
def predict(text: str) -> str:
|
| 13 |
+
return dummy.predict(text)
|
app/interface.py
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from app.handler import predict
|
| 3 |
+
|
| 4 |
+
def launch_app():
|
| 5 |
+
iface = gr.Interface(
|
| 6 |
+
fn=predict,
|
| 7 |
+
inputs="text",
|
| 8 |
+
outputs="label",
|
| 9 |
+
title="🧪 ToxiCheck",
|
| 10 |
+
description="Entrez un texte pour détecter s'il est toxique."
|
| 11 |
+
)
|
| 12 |
+
iface.launch()
|
main.py
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.interface import launch_app
|
| 2 |
+
|
| 3 |
+
if __name__ == '__main__':
|
| 4 |
+
launch_app()
|
models/base.py
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
|
| 3 |
+
class BaseModel(ABC):
|
| 4 |
+
@abstractmethod
|
| 5 |
+
def predict(self, text: str) -> str:
|
| 6 |
+
pass
|
requirements.txt
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
scikit-learn
|
| 4 |
+
pandas
|
| 5 |
+
pytest
|
| 6 |
+
commitizen
|
tests/test_handler.py
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.handler import predict
|
| 2 |
+
|
| 3 |
+
def test_prediction_output():
|
| 4 |
+
result = predict("Tu es stupide")
|
| 5 |
+
assert result in ["toxique", "non-toxique"]
|