davidberenstein1957 HF staff commited on
Commit
d39610d
·
1 Parent(s): e9b7220

Refactor URL generation in format_history_as_messages to use consistent variable naming for file paths, improving code clarity and maintainability.

Browse files
Files changed (1) hide show
  1. app/app.py +3 -4
app/app.py CHANGED
@@ -76,12 +76,11 @@ def format_history_as_messages(history: list):
76
  current_message_content = []
77
 
78
  if isinstance(content, tuple): # Handle file paths
79
- for path in content:
80
  if space_host := os.getenv("SPACE_HOST"):
81
- url = f"https://{space_host}/gradio_api/file%3D{path}"
82
  else:
83
- url = _convert_path_to_data_uri(path)
84
- print(url)
85
  current_message_content.append(
86
  {"type": "image_url", "image_url": {"url": url}}
87
  )
 
76
  current_message_content = []
77
 
78
  if isinstance(content, tuple): # Handle file paths
79
+ for temp_path in content:
80
  if space_host := os.getenv("SPACE_HOST"):
81
+ url = f"https://{space_host}/gradio_api/file%3D{temp_path}"
82
  else:
83
+ url = _convert_path_to_data_uri(temp_path)
 
84
  current_message_content.append(
85
  {"type": "image_url", "image_url": {"url": url}}
86
  )