keremberke's picture
Upload 2 files
16d8d96 verified
raw
history blame
1.28 kB
import gradio as gr
import dotenv
import os
from gpt_utils import update_text_with_ai
from db_utils import supabase, get_next_row_id, get_text_by_row_id ,add_updated_text_to_db
dotenv.load_dotenv()
PW=os.getenv("PW")
def apply_ai_func(text, request: gr.Request):
updated_text2 = update_text_with_ai(text)
return updated_text2
def get_next_func(request: gr.Request):
next_id = get_next_row_id(user_name=request.username)
text=get_text_by_row_id(next_id)
return next_id, text
with gr.Blocks(analytics_enabled=False) as demo:
get_from_db = gr.Button("🗂️Sıradaki Veriyi Çek🗂️")
with gr.Row():
text_id = gr.Number(label="Satır NO:", interactive=False,scale= 1)
original_text = gr.Textbox(label="Orjinial Yazı:", interactive=False,scale= 5)
apply_ai = gr.Button("✨BÜYÜ YAP✨")
updated_text = gr.Textbox(label="Düzeltilmiş Yazı:")
add_to_db = gr.Button("📥Veri Tabanına Yükle📥")
get_from_db.click(fn=get_next_func, outputs=[text_id, original_text])
apply_ai.click(fn=apply_ai_func, inputs=original_text, outputs=updated_text)
add_to_db.click(fn=add_updated_text_to_db, inputs=[text_id, updated_text])
demo.launch(auth=[("kerem", PW), ("mehmet", PW)],favicon_path="./tugra_logo.png")