File size: 1,279 Bytes
1a17245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb0cecf
 
 
 
1a17245
 
 
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
import streamlit as st
import codecs
import streamlit.components.v1 as stc
import pathlib


def stc_chatbot(root_dir, width=700, height=600):
    html_file = root_dir/"app/chatbot.html"
    css_file = root_dir/"app/css/chatbot.css"
    js_file = root_dir/"app/js/chatbot.js"
    if css_file.exists() and js_file.exists():
        html = codecs.open(html_file, "r").read()
        css = codecs.open(css_file, "r").read()
        js = codecs.open(js_file, "r").read()
        html = html.replace('<link rel="stylesheet" href="css/chatbot.css">', "<style>\n" + css + "\n</style>")
        html = html.replace('<script src="js/chatbot.js"></script>', "<script>\n" + js + "\n</script>")
        stc.html(html, width=width, height=height, scrolling=False)


st.header("English and Indonesian Persona Chatbot")

description = f"This application uses the Indonesian GPT2 model; we finetuned it with the original English persona " \
              f"dataset and its Indonesian translation. It gives the chatbot the capability to understand and talk " \
              f"in both languages (code-switching). The finetuning is based on the Huggingface's Conversational AI " \
              f"with Transfer Learning."
st.markdown(description)
root_dir = pathlib.Path(".")
stc_chatbot(root_dir)