File size: 1,055 Bytes
10266aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()