Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -125,34 +125,34 @@ def predict_image(image_url, text, file_pref):
|
|
125 |
]
|
126 |
}
|
127 |
],
|
128 |
-
|
129 |
-
|
130 |
-
# top_p=1,
|
131 |
-
# stream=True
|
132 |
-
|
133 |
-
temperature=1,
|
134 |
-
max_completion_tokens=4096,
|
135 |
top_p=1,
|
136 |
-
stream=
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
138 |
)
|
139 |
print(f"Completions: {completion}")
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
except Exception as e:
|
145 |
print(f"Error in generate_response: {e}")
|
146 |
streamer.put(None)
|
147 |
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
buffer = completion.choices[0].message
|
155 |
-
print(buffer)
|
156 |
return buffer
|
157 |
|
158 |
except Exception as e:
|
|
|
125 |
]
|
126 |
}
|
127 |
],
|
128 |
+
temperature=0.7,
|
129 |
+
max_tokens=4096,
|
|
|
|
|
|
|
|
|
|
|
130 |
top_p=1,
|
131 |
+
stream=True
|
132 |
+
|
133 |
+
# temperature=1,
|
134 |
+
# max_completion_tokens=4096,
|
135 |
+
# top_p=1,
|
136 |
+
# stream=False,
|
137 |
+
# stop=None,
|
138 |
)
|
139 |
print(f"Completions: {completion}")
|
140 |
+
for chunk in completion:
|
141 |
+
if chunk.choices[0].delta.content:
|
142 |
+
streamer.put(chunk.choices[0].delta.content)
|
143 |
+
streamer.put(None) # Signal the end
|
144 |
except Exception as e:
|
145 |
print(f"Error in generate_response: {e}")
|
146 |
streamer.put(None)
|
147 |
|
148 |
+
thread = Thread(target=generate_response)
|
149 |
+
thread.start()
|
150 |
|
151 |
+
buffer = ""
|
152 |
+
for new_text in streamer:
|
153 |
+
buffer += new_text
|
154 |
+
# buffer = completion.choices[0].message
|
155 |
+
# print(buffer)
|
156 |
return buffer
|
157 |
|
158 |
except Exception as e:
|