File size: 1,262 Bytes
f34a6fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from global_vars import t, translations
from app import Plugin
import streamlit as st
import torch

# Ajout des traductions spécifiques à ce plugin
translations["en"].update({
    "work_directory": "Work Directory",
    "page_title": "News watcher",
})
translations["fr"].update({
    "work_directory": "Répertoire de travail",
    "page_title": "Outil de veille",
})

class CommonPlugin(Plugin):
    def get_config_fields(self):
        return {
            "work_directory": {
                "type": "text",
                "label": t("work_directory"),
                "default": "/home/joriel/Vidéos"
            },
            "language": {
                "type": "select",
                "label": t("preferred_language"),
                "options": [("fr", "Français"), ("en", "Anglais")],
                "default": "fr"
            },
        }

    def get_tabs(self):
        return [{"name": "Commun", "plugin": "common"}]

    def run(self, config):
        st.header("Common Plugin")
        st.write(f"{t('work_directory')}: {config['common']['work_directory']}")
        torch.cuda.empty_cache()
        st.write("CUDA memory reset")

def remove_quotes(s):
    if s.startswith('"') and s.endswith('"'):
        return s[1:-1]
    return s