Mayur2 commited on
Commit
9ce873e
·
1 Parent(s): f7390f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -119,15 +119,19 @@ def upload_and_process(image, promptText, promptImg, lens_option, n_images, size
119
  split_pairs = responses.split(" ")
120
 
121
  # Initialize an empty dictionary to store the key-value pairs
122
- key_value_dict = {}
123
-
124
- # Iterate over each pair, splitting it further at the ":" character
125
  for pair in split_pairs:
126
- pair_parts = pair.split(":", 1)
127
- if len(pair_parts) == 2:
128
- key = pair_parts[0].strip()
129
- value = pair_parts[1].strip()
130
- key_value_dict[key] = value
 
 
 
 
 
131
 
132
  # Print each key-value pair on a new line
133
  for key, value in key_value_dict.items():
 
119
  split_pairs = responses.split(" ")
120
 
121
  # Initialize an empty dictionary to store the key-value pairs
122
+ key = None
123
+ value = ""
 
124
  for pair in split_pairs:
125
+ if ":" in pair:
126
+ if key is not None:
127
+ key_value_dict[key.strip()] = value.strip()
128
+ key, value = pair.split(":", 1)
129
+ else:
130
+ value += " " + pair.strip()
131
+
132
+ # Add the last key-value pair
133
+ if key is not None:
134
+ key_value_dict[key.strip()] = value.strip()
135
 
136
  # Print each key-value pair on a new line
137
  for key, value in key_value_dict.items():