|
import gradio as gr |
|
from helper_functions import * |
|
|
|
def get_prompt(user_message): |
|
return pre_text + "\n\n" + get_context(user_message) |
|
|
|
def set_pre_text(system_prompt): |
|
global pre_text |
|
pre_text = system_prompt |
|
|
|
with gr.Blocks() as app: |
|
gr.Markdown('# Prompt Generator for FundedNext') |
|
with gr.Tab("Generate Prompt"): |
|
user_message = gr.Textbox(label = "Enter your message") |
|
prompt = gr.Textbox(label="Generated Prompt", interactive=True, lines=20) |
|
with gr.Tab("Edit System Prompt"): |
|
system_prompt = gr.Textbox( |
|
label="System Prompt", interactive=True, lines=15 |
|
) |
|
gr.Markdown("## System Prompt Examples") |
|
gr.Examples( |
|
examples = [[pre_text]], |
|
inputs = [system_prompt] |
|
) |
|
|
|
user_message.submit( |
|
fn = get_prompt, inputs = user_message, outputs = prompt |
|
).then(lambda:"", inputs=None, outputs=user_message) |
|
system_prompt.change( |
|
fn = set_pre_text, inputs = system_prompt, outputs = None |
|
) |
|
|
|
|
|
app.launch(auth=(os.getenv("id"), os.getenv("password")), show_api=False) |