Update app.py
Browse files
app.py
CHANGED
|
@@ -116,30 +116,19 @@ def upload_and_process(image, promptText, promptImg, lens_option, n_images, size
|
|
| 116 |
# Remove backdrop
|
| 117 |
responses = chatgpt_chain.predict(human_input=promptText)
|
| 118 |
print(responses)
|
| 119 |
-
|
| 120 |
|
|
|
|
|
|
|
| 121 |
|
| 122 |
-
#
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
# Extract the desired string value
|
| 126 |
-
output_string = input_string[input_string.find("Output :") + 9:]
|
| 127 |
-
|
| 128 |
-
# Remove leading/trailing whitespace and double quotes
|
| 129 |
-
output_string = output_string.strip().strip('"')
|
| 130 |
-
|
| 131 |
-
# Split the string into key-value pairs
|
| 132 |
-
output_list = [pair.strip() for pair in output_string.split("\\n")]
|
| 133 |
-
|
| 134 |
-
# Create a dictionary from the key-value pairs
|
| 135 |
-
output_dict = {}
|
| 136 |
-
for pair in output_list:
|
| 137 |
key, value = pair.split(":", 1)
|
| 138 |
-
|
| 139 |
|
| 140 |
-
#
|
| 141 |
-
|
| 142 |
-
|
| 143 |
# json_string = responses.strip()
|
| 144 |
|
| 145 |
# # Add indentation and new lines after each key-value pair
|
|
|
|
| 116 |
# Remove backdrop
|
| 117 |
responses = chatgpt_chain.predict(human_input=promptText)
|
| 118 |
print(responses)
|
| 119 |
+
split_pairs = string.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 |
key, value = pair.split(":", 1)
|
| 127 |
+
key_value_dict[key.strip()] = value.strip()
|
| 128 |
|
| 129 |
+
# Print each key-value pair on a new line
|
| 130 |
+
for key, value in key_value_dict.items():
|
| 131 |
+
print("He",key + ": " + value)
|
| 132 |
# json_string = responses.strip()
|
| 133 |
|
| 134 |
# # Add indentation and new lines after each key-value pair
|