File size: 1,425 Bytes
5120311 |
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 |
import gradio as gr
import json
import ast
def push_queue(CONFIG):
return
def wirte_config(CONFIG):
CONFIG = ast.literal_eval(CONFIG)
str = f"""
******CONFIG UPDATE******
start_time: {CONFIG['start_time']}
end_time: {CONFIG['end_time']}
query: {CONFIG['query']}
keywords: {CONFIG['keywords']}
top_cluster: {CONFIG['top_cluster']}
prompt: {CONFIG['prompt']}
check_relevent: {CONFIG['check_relevent']}
max_posts: {CONFIG['max_posts']}
"""
with open('/home2/cuongnguyen2/topic-clustering-global-dashboard/config_periodic.json', 'w') as f:
json.dump(CONFIG, f, ensure_ascii= False)
return str
demo = gr.Blocks()
def gradio_function():
with demo:
gr.Markdown(
"""
# Flip Text!
Start typing below to see the output.
"""
)
with open('/home2/cuongnguyen2/topic-clustering-global-dashboard/config_periodic.json') as f:
CONFIG = json.load(f)
input1 = gr.Textbox(placeholder="Enter input", value=str(CONFIG))
# input2 = gr.Textbox(placeholder="Enter second text")
# Tạo ô output
output = gr.Textbox()
# Kết nối các input với hàm process_text
gr.Button("Submit").click(fn=wirte_config, inputs=[input1], outputs=output)
demo.launch(share=True)
if __name__ == '__main__':
gradio_function() |