File size: 2,846 Bytes
4ad5efa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import gradio as gr
import logging
from pathlib import Path

# Імпортуємо вкладки з підмодулів
from modules.interface.csv_analysis_ui import create_csv_analysis_tab
from modules.interface.visualizations_ui import create_visualizations_tab
from modules.interface.jira_api_ui import create_jira_api_tab
from modules.interface.ai_assistant_ui import create_ai_assistant_tab
from modules.interface.integrations_ui import create_integrations_tab

logger = logging.getLogger("jira_assistant_interface")

def create_help_tab(app):
    """
    Створює вкладку 'Довідка' з інформацією з HELP.md.
    """
    with gr.Tab("Довідка"):
        try:
            # Шлях до файлу HELP.md
            help_file_path = Path("HELP.md")
            
            # Перевіряємо, чи існує файл
            if help_file_path.exists():
                # Читаємо вміст файлу
                with open(help_file_path, "r", encoding="utf-8") as f:
                    help_content = f.read()
                
                # Відображаємо вміст як Markdown
                with gr.Blocks():
                    gr.Markdown(help_content)
            else:
                gr.Markdown("# Довідка недоступна")
                gr.Markdown("Файл HELP.md не знайдено. Перевірте, чи існує файл у кореневій директорії проєкту.")
        except Exception as e:
            logger.error(f"Помилка при завантаженні файлу довідки: {e}")
            gr.Markdown("# Помилка при завантаженні довідки")
            gr.Markdown(f"Виникла помилка: {str(e)}")

def launch_interface(app):
    """
    Запуск інтерфейсу користувача Gradio

    Args:
        app: Екземпляр JiraAssistantApp
    """
    interface = gr.Blocks(title="Jira AI Assistant")

    with interface:
        gr.Markdown("# 🔍 Jira AI Assistant")

        # Перевіряємо, чи додаток має необхідні атрибути
        if not hasattr(app, 'last_loaded_csv'):
            app.last_loaded_csv = None
        if not hasattr(app, 'current_data'):
            app.current_data = None
        if not hasattr(app, 'indices_path'):
            app.indices_path = None

        with gr.Tabs() as tabs:
            # Створюємо вкладки
            create_csv_analysis_tab(app)
            create_visualizations_tab(app)
            create_ai_assistant_tab(app)
            create_jira_api_tab(app)
            create_integrations_tab(app)
            create_help_tab(app)  # Додана нова вкладка з довідкою

    return interface