suprimedev commited on
Commit
5d24286
·
verified ·
1 Parent(s): bbb0217

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -806,13 +806,25 @@ def process_request(instruction, files, urls_input):
806
  future = executor.submit(process_request_sync, instruction, files, urls_input)
807
  result_text, file_path, talkgpt_url = future.result()
808
 
809
- # Return results, including TalkGPT URL if available
 
810
  if talkgpt_url:
811
- # Append TalkGPT URL to result text if not already included
812
- if talkgpt_url not in result_text:
813
- result_text += f"\n\n📁 Direct Link: {talkgpt_url}"
814
-
815
- return result_text, file_path
 
 
 
 
 
 
 
 
 
 
 
816
 
817
  # Cleanup on exit
818
  def cleanup_on_exit():
@@ -876,7 +888,7 @@ with gr.Blocks(title="AI File Processor - Self Correcting with TalkGPT Upload")
876
 
877
  with gr.Row():
878
  output = gr.Textbox(label="نتیجه", lines=15)
879
- file_out = gr.File(label="فایل خروجی (اگر تولید شود، به TalkGPT آپلود می‌شود)")
880
 
881
  # Examples
882
  gr.Examples(
@@ -889,7 +901,7 @@ with gr.Blocks(title="AI File Processor - Self Correcting with TalkGPT Upload")
889
  inputs=[instruction, files, urls],
890
  )
891
 
892
- btn.click(fn=process_request, inputs=[instruction, files, urls], outputs=[output, file_out])
893
 
894
  if __name__ == "__main__":
895
  demo.launch(share=True)
 
806
  future = executor.submit(process_request_sync, instruction, files, urls_input)
807
  result_text, file_path, talkgpt_url = future.result()
808
 
809
+ # Return results with TalkGPT URL as the file output
810
+ # If there's a TalkGPT URL, return it as an HTML link
811
  if talkgpt_url:
812
+ # Create an HTML component for the link
813
+ file_output_html = f"""
814
+ <div style="padding: 10px; background-color: #f0f0f0; border-radius: 5px; margin-top: 10px;">
815
+ <h4 style="margin: 0 0 10px 0;">📁 Download Link:</h4>
816
+ <a href="{talkgpt_url}" target="_blank" style="color: #0066cc; font-size: 16px; text-decoration: none;">
817
+ {talkgpt_url}
818
+ </a>
819
+ <p style="margin: 10px 0 0 0; color: #666; font-size: 14px;">
820
+ Click the link above to download the file (valid for 7 days)
821
+ </p>
822
+ </div>
823
+ """
824
+ return result_text, file_output_html
825
+ else:
826
+ # No file was generated or upload failed
827
+ return result_text, None
828
 
829
  # Cleanup on exit
830
  def cleanup_on_exit():
 
888
 
889
  with gr.Row():
890
  output = gr.Textbox(label="نتیجه", lines=15)
891
+ file_link_output = gr.HTML(label="لینک دانلود فایل")
892
 
893
  # Examples
894
  gr.Examples(
 
901
  inputs=[instruction, files, urls],
902
  )
903
 
904
+ btn.click(fn=process_request, inputs=[instruction, files, urls], outputs=[output, file_link_output])
905
 
906
  if __name__ == "__main__":
907
  demo.launch(share=True)