File size: 2,776 Bytes
2028cec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
085fbc3
2028cec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from utils import response_faiss, sub_chunk_query, window_query
from pathlib import Path

# title = "Vietnam's Enterprise Laws chatbot"

description = """
Vietnam's Enterprise Laws Chatbot is an AI-powered tool designed to provide instant, accurate information about corporate laws in Vietnam. 
Users can ask questions related to company formation, legal compliance, business regulations, and other corporate legal matters. 
The chatbot offers tailored guidance based on Vietnamese laws, helping businesses and entrepreneurs navigate legal requirements efficiently.
"""
ROOT_DIR = str(Path(__file__).resolve().parent.parent.resolve())

def load_css():
    with open(ROOT_DIR + '/app/css/styles.css', 'r') as file:
        css_content = file.read()
        print
    return css_content

def load_js():
    with open(ROOT_DIR + '/app/css/js.js', 'r') as file:
        js_content = file.read()
        print
    return js_content

import gradio as gr

print(load_js())

# Load external JavaScript file


with gr.Blocks(title="Chatbot Viet's Corporate Laws", css=load_css(), theme="default", js=load_js()) as demo:
    with gr.Row(elem_classes="header"):
        gr.Image(f"{ROOT_DIR}/app/assets/logo.png", 
                 elem_classes="logo-image", interactive=False, container=False, 
                 show_share_button=False, show_download_button=False, 
                 show_fullscreen_button=False, show_label=False)
        # gr.Markdown(f"{title}", elem_classes="title")
    
    # Add the description with a new class for styling
    gr.Markdown(f"{description}", elem_classes="description")
    gr.ChatInterface(
        # response_faiss,
        window_query,
        # type="messages",#https://www.gradio.app/docs/gradio/chatbot
        title=None,
        description = None,
        chatbot=gr.Chatbot(bubble_full_width = True),
        # multimodal = True, 
        examples=[
            'Chào bán cổ phần cho cổ đông hiện hữu của công ty cổ phần không phải là công ty đại chúng được thực hiện ra sao ?',
            'Quyền của doanh nghiệp là những quyền nào?',
            'Các trường hợp nào được coi là tên gây nhầm lẫn ?',
            'Các quy định về chào bán trái phiếu riêng lẻ', 
            'Doanh nghiệp có quyền và nghĩa vụ như thế nào?', 
            'Xin chào! Tôi muốn hỏi về các quy định khi thành lập doanh nghiệp tư nhân ở Việt Nam.'
        ] 
    )

if __name__ == "__main__":
    # response_faiss("Chào bán cổ phần cho cổ đông hiện hữu của công ty cổ phần không phải là công ty đại chúng được thực hiện ra sao ?", "")
    print('main')
    demo.launch(share = True)