OlympIA / plugins /common.py
johannoriel's picture
Initial relase. Tested. Working
f34a6fd
raw
history blame
1.26 kB
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