File size: 1,562 Bytes
54d25d7 890e747 54d25d7 890e747 54d25d7 890e747 64e66df 890e747 9a97606 890e747 9a97606 64e66df 890e747 |
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 37 38 39 40 41 |
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() |