File size: 3,597 Bytes
18ddfe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import gradio as gr

from fun_advaitbert import predict_CTH
from fun_advaitbert import llm_model_function
from fun_advaitbert import product_explaination

title="<h1 style='color:green;text-align:center;font-size:2vw;'>AdvaitBERT:HS Code AI Explanability Through Mixtral 46.7B </a></h1>"
description = """
AdvaitBERT is modified version of BERT (Bidirectional Encoder Representation for Transformers), \
finetuned on the Text corpus of Indian Customs Declarations. It is trained for performing  \
downstream tasks  like automating the tariff classification and validation process of Customs \
declarations in realtime. This model may help Customs administration to efficiently use AI assisted \
NLP in realtime Customs process like Assessment, Post Clearance Audit, thereby highlighting classification \
inconsistencies and help in revenue augmentation.
"""

article="<p style='color:black;text-align:right;font-size:1vw;'>Powered by NCTC </a></p>"


css = """
.gradio-container {
    width: 100vw !important;
    min-height: 100vh !important;
    padding:0 !important;
    margin:0 !important;
    max-width: none !important;
}
"""

footnote = """Note: All rights, including licensing and acceptable use policies, related to the AI  models, can be found on their respective model pages on Hugging Face. Powered by NCTC
"""

#Powered by NCTC

# input_txt=gr.Textbox(label='Enter Your Product Descrption',lines=3,)
# textbox = gr.Textbox(container=False,placeholder='Enter text and click the Submit button or press Enter')

textbox = gr.Textbox(label='Enter Your Product Descrption',lines=3,)
textbox_2=textbox

print('textbox',textbox)
print('textbox_2',textbox_2)

chat_prod = gr.Chatbot(label="Product Explanation", layout='panel')    #height=300
#chat_Advait = gr.Chatbot(label="Advaitbert Prediction", layout='panel')
chat_alpha = gr.Chatbot(label="AI Explanability", layout='panel')
chat_Advait=gr.Interface(predict_CTH,inputs=textbox,outputs="label",)


submit = gr.Button('Submit', variant='primary',)
submit_second = gr.Button('Submit', variant='secondary',)
#submit2 = gr.Button('Submit', variant='primary',)
retry = gr.Button('🔄Retry', variant='secondary')
undo = gr.Button('↩️Undo', variant='secondary')

with gr.Blocks(css=css) as demo:
    gr.HTML(f'<h1><center> {title} </center></h1>')
    gr.Markdown(description)

    with gr.Row():
        with gr.Column(scale=0,min_width=600):
            chat_Advait.render()

        with gr.Column(scale=1,min_width=600):
            chat_alpha.render()
            with gr.Row(equal_height=True):
                with gr.Column(scale=1):
                    submit.render()
                with gr.Column(scale=1):
                    undo.render()
                with gr.Column(scale=1):
                    clear = gr.ClearButton(value='🗑️Clear',components=[chat_alpha,chat_prod,textbox])
            chat_prod.render()
            #submit_second.render()

    gr.Markdown(footnote)
    textbox.submit(llm_model_function, [textbox, chat_alpha], [textbox, chat_alpha])
    textbox_2.submit(product_explaination, [textbox_2, chat_prod], [textbox_2, chat_prod])
    
    submit.click(llm_model_function,[textbox, chat_alpha], [textbox, chat_alpha])
    submit.click(product_explaination,[textbox_2, chat_prod], [textbox_2, chat_prod])

    undo.click(lambda x:x[:-1], [chat_alpha], [chat_alpha])
    undo.click(lambda x:x[:-1], [chat_prod], [chat_prod])

    gr.Examples([
              ['200 SI/SI/SI LPO ALUMINIUM LIDS (QTY: 8820000 PCS/PRICE: 21.'],
              ],
              textbox)
           
demo.launch(debug=True)