Update app.py
Browse files
app.py
CHANGED
@@ -22,9 +22,6 @@ app = FastAPI()
|
|
22 |
api_key = os.getenv("MISTRAL_API_KEY")
|
23 |
Mistralclient = Mistral(api_key=api_key)
|
24 |
|
25 |
-
def flip_image(x):
|
26 |
-
return np.fliplr(x)
|
27 |
-
|
28 |
def encode_image(image_path):
|
29 |
"""Encode the image to base64."""
|
30 |
try:
|
@@ -77,7 +74,7 @@ def feifeichat(image):
|
|
77 |
partial_message = partial_message + chunk.data.choices[
|
78 |
0].delta.content
|
79 |
yield partial_message
|
80 |
-
except Exception as e: #
|
81 |
print(f"Error: {e}")
|
82 |
return "Please upload a photo"
|
83 |
|
@@ -95,8 +92,7 @@ with gr.Blocks(theme=theme, elem_id="app-container") as app:
|
|
95 |
clr_button.click(lambda: gr.Textbox(value=""), None, output_text)
|
96 |
|
97 |
submit_btn.click(feifeichat, [input_img], [output_text])
|
98 |
-
|
99 |
-
|
100 |
|
101 |
if __name__ == "__main__":
|
102 |
app.launch()
|
|
|
22 |
api_key = os.getenv("MISTRAL_API_KEY")
|
23 |
Mistralclient = Mistral(api_key=api_key)
|
24 |
|
|
|
|
|
|
|
25 |
def encode_image(image_path):
|
26 |
"""Encode the image to base64."""
|
27 |
try:
|
|
|
74 |
partial_message = partial_message + chunk.data.choices[
|
75 |
0].delta.content
|
76 |
yield partial_message
|
77 |
+
except Exception as e: # 添加通用异常处理
|
78 |
print(f"Error: {e}")
|
79 |
return "Please upload a photo"
|
80 |
|
|
|
92 |
clr_button.click(lambda: gr.Textbox(value=""), None, output_text)
|
93 |
|
94 |
submit_btn.click(feifeichat, [input_img], [output_text])
|
95 |
+
|
|
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
app.launch()
|