dextersud commited on
Commit
e696b7d
·
verified ·
1 Parent(s): 64a0ef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -1,9 +1,17 @@
1
  import requests
2
  import gradio as gr
3
 
4
- def my_model(prompt):
 
 
 
 
 
5
  public_url = "https://0577-35-193-135-91.ngrok-free.app/generate"
6
 
 
 
 
7
  # Correct JSON format
8
  payload = {
9
  "prompt": prompt
@@ -21,16 +29,28 @@ def my_model(prompt):
21
  # Define the Gradio interface
22
  def create_interface():
23
  with gr.Blocks() as demo:
24
- gr.Markdown("## Text Generation with Your Model")
 
 
25
  with gr.Row():
26
- prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
 
 
 
 
 
27
  submit_button = gr.Button("Generate")
28
- output_text = gr.Textbox(label="Generated Text", lines=10, placeholder="Generated text will appear here...")
 
 
 
 
 
29
 
30
- submit_button.click(fn=my_model, inputs=prompt_input, outputs=output_text)
31
 
32
  return demo
33
 
34
  if __name__ == "__main__":
35
  # Launch the Gradio app
36
- create_interface().launch()
 
1
  import requests
2
  import gradio as gr
3
 
4
+ def generate_prompt(instruction):
5
+ # Define the prompt format with the instruction
6
+ prompt = f"###Instruction:\n{instruction}\n\n###Response\n:"
7
+ return prompt
8
+
9
+ def my_model(instruction):
10
  public_url = "https://0577-35-193-135-91.ngrok-free.app/generate"
11
 
12
+ # Generate the prompt from the instruction
13
+ prompt = generate_prompt(instruction)
14
+
15
  # Correct JSON format
16
  payload = {
17
  "prompt": prompt
 
29
  # Define the Gradio interface
30
  def create_interface():
31
  with gr.Blocks() as demo:
32
+ gr.Markdown("# Text Generation with Your Model")
33
+ gr.Markdown("Enter an instruction below and get the generated text from the model.")
34
+
35
  with gr.Row():
36
+ instruction_input = gr.Textbox(
37
+ label="Instruction",
38
+ placeholder="Enter your instruction here...",
39
+ lines=3,
40
+ max_lines=3
41
+ )
42
  submit_button = gr.Button("Generate")
43
+ output_text = gr.Textbox(
44
+ label="Generated Text",
45
+ lines=10,
46
+ placeholder="Generated text will appear here...",
47
+ max_lines=10
48
+ )
49
 
50
+ submit_button.click(fn=my_model, inputs=instruction_input, outputs=output_text)
51
 
52
  return demo
53
 
54
  if __name__ == "__main__":
55
  # Launch the Gradio app
56
+ create_interface().launch()