|
import gradio as gr |
|
from helper_functions import * |
|
|
|
with gr.Blocks() as app: |
|
gr.Markdown('# Prompt Generator for FundedNext') |
|
session_data = gr.State([{"current_system_prompt": ""}]) |
|
|
|
with gr.Tab("Generate Prompt"): |
|
user_message = gr.Textbox(label = "Enter your message") |
|
prompt = gr.Textbox(label="Generated Prompt", interactive=True, lines=20).style(show_copy_button=True) |
|
with gr.Tab("Edit System Prompt"): |
|
system_prompt = gr.Textbox( |
|
label="System Prompt", interactive=True, lines=15 |
|
).style(show_copy_button=True) |
|
save_s_p = gr.Button("Save System Prompt") |
|
gr.Markdown("## System Prompt Examples") |
|
gr.Examples( |
|
examples = [[pre_text]], |
|
inputs = [system_prompt] |
|
) |
|
|
|
user_message.submit( |
|
fn = get_prompt, inputs = [user_message, session_data], outputs = prompt |
|
).then(lambda:"", inputs=None, outputs=user_message, queue=False) |
|
save_s_p.click( |
|
fn = set_pre_text, inputs = [system_prompt, session_data], outputs = session_data, queue=False |
|
) |
|
system_prompt.submit( |
|
fn = set_pre_text, inputs = [system_prompt, session_data], outputs = session_data, queue=False |
|
) |
|
|
|
|
|
app.launch(auth=(os.getenv("id"), os.getenv("password")), show_api=False) |
|
|