victor HF staff commited on
Commit
d79d8bb
·
1 Parent(s): 2401abf

refactor: Improve asset information display with markdown table format

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -85,16 +85,17 @@ def get_files_infos(files):
85
 
86
 
87
  def get_completion(prompt, files_info, top_p, temperature):
88
- files_info_string = ""
 
 
 
 
89
  for file_info in files_info:
90
- files_info_string += f"""{file_info["type"]} {file_info["name"]}"""
91
- if file_info["type"] == "video" or file_info["type"] == "image":
92
- files_info_string += f""" {file_info["dimensions"]}"""
93
- if file_info["type"] == "video" or file_info["type"] == "audio":
94
- files_info_string += f""" {file_info["duration"]}s"""
95
- if file_info["type"] == "audio" or file_info["type"] == "video/audio":
96
- files_info_string += f""" {file_info["audio_channels"]} audio channels"""
97
- files_info_string += "\n"
98
 
99
  messages = [
100
  {
 
85
 
86
 
87
  def get_completion(prompt, files_info, top_p, temperature):
88
+ # Create table header
89
+ files_info_string = "| Type | Name | Dimensions | Duration | Audio |\n"
90
+ files_info_string += "|------|------|------------|-----------|--------|\n"
91
+
92
+ # Add each file as a table row
93
  for file_info in files_info:
94
+ dimensions = file_info.get("dimensions", "-")
95
+ duration = f"{file_info.get('duration', '-')}s" if "duration" in file_info else "-"
96
+ audio = f"{file_info.get('audio_channels', '-')} channels" if "audio_channels" in file_info else "-"
97
+
98
+ files_info_string += f"| {file_info['type']} | {file_info['name']} | {dimensions} | {duration} | {audio} |\n"
 
 
 
99
 
100
  messages = [
101
  {