Hug0endob commited on
Commit
8361fdd
·
verified ·
1 Parent(s): 1e6243d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -117,13 +117,16 @@ with gr.Blocks() as demo:
117
 
118
  with gr.Row():
119
  with gr.Column(scale=1):
120
- alt_key = gr.Textbox(label="Alternate Mistral API Key (optional)", type="password")
 
 
 
121
  url_input = gr.Textbox(label="Image/Video URL", placeholder="https://...")
122
  custom = gr.Textbox(label="Custom prompt (optional)", lines=4, placeholder="Enter custom prompt to override default")
123
  submit = gr.Button("Submit")
124
- preview = gr.Image(label="Preview", type="pil")
125
  with gr.Column(scale=1):
126
- out = gr.Textbox(label="Generated Detailed Description", lines=25)
 
127
 
128
  def load_preview(url):
129
  if not url:
@@ -139,10 +142,14 @@ with gr.Blocks() as demo:
139
  def start_gen(url, custom_p, alt_k):
140
  if not url:
141
  return "No URL provided."
 
 
142
  for chunk in generate_stream(url, custom_p, alt_k):
143
- yield chunk
 
 
144
 
145
  url_input.change(fn=load_preview, inputs=[url_input], outputs=[preview])
146
- submit.click(fn=start_gen, inputs=[url_input, custom, alt_key], outputs=[out])
147
 
148
  demo.launch()
 
117
 
118
  with gr.Row():
119
  with gr.Column(scale=1):
120
+ # Minimal API key field
121
+ alt_key = gr.Textbox(label="API Key (optional)", type="password", max_lines=1)
122
+ # Preview on top
123
+ preview = gr.Image(label="Preview", type="pil")
124
  url_input = gr.Textbox(label="Image/Video URL", placeholder="https://...")
125
  custom = gr.Textbox(label="Custom prompt (optional)", lines=4, placeholder="Enter custom prompt to override default")
126
  submit = gr.Button("Submit")
 
127
  with gr.Column(scale=1):
128
+ # Streamed text area rendered as HTML/text block filling right column
129
+ output_display = gr.Markdown("", elem_id="generated_output")
130
 
131
  def load_preview(url):
132
  if not url:
 
142
  def start_gen(url, custom_p, alt_k):
143
  if not url:
144
  return "No URL provided."
145
+ # produce full combined text for Markdown via streaming
146
+ text = ""
147
  for chunk in generate_stream(url, custom_p, alt_k):
148
+ text += chunk
149
+ yield text
150
+ # final yield already returned in loop
151
 
152
  url_input.change(fn=load_preview, inputs=[url_input], outputs=[preview])
153
+ submit.click(fn=start_gen, inputs=[url_input, custom, alt_key], outputs=[output_display])
154
 
155
  demo.launch()