rkoushikroy2's picture
Upload 2 files
9a97606
raw
history blame
1.56 kB
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": ""}])
def get_prompt(user_message, session_data):
if(user_message == ""):
return_message = "Please enter your message"
return return_message
pre_text = session_data[0]["current_system_prompt"]
return_message = pre_text + "\n\n" + get_context(user_message)
return return_message
def set_pre_text(system_prompt, session_data):
session_data[0]["current_system_prompt"] = system_prompt
return session_data
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, session_data], outputs = prompt
).then(lambda:"", inputs=None, outputs=user_message, queue=False)
system_prompt.change(
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)
# app.launch()