|
import gradio as gr |
|
|
|
|
|
def fn(txt): |
|
print(txt) |
|
parts = txt.split('\n\n') |
|
print(parts[1]) |
|
txt2 = parts[0].replace('🫡 ', '') |
|
chats = "{\"messages\": [{\"role\": \"user\", \"content\": " + "\"" + txt2 + "\"" + "}, {\"role\": \"assistant\", \"content\": " + "\"" + parts[1] + "\"" + "}]}" |
|
print(chats) |
|
with open("fine.txt", "r", encoding='utf-8') as fine: |
|
finetune = fine.read() |
|
with open('fine.txt', 'w', encoding='utf-8') as fine: |
|
fine.write(finetune+ "\n"+ chats) |
|
return chats |
|
|
|
def out(): |
|
with open("fine.txt", "r", encoding='utf-8') as fine: |
|
finetune = fine.read() |
|
return finetune |
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
with gr.Tab("add"): |
|
with gr.Row(): |
|
txt = gr.Textbox() |
|
submit = gr.Button("Submit") |
|
txt2 = gr.Textbox(interactive=False) |
|
submit.click(fn=fn, inputs=txt, outputs=txt2) |
|
with gr.Tab("confirm") as tapsss: |
|
txtss = gr.TextArea(interactive=False) |
|
tapsss.select(fn=out, outputs=txtss) |
|
|
|
|
|
demo.launch() |