Update app.py
Browse files
app.py
CHANGED
@@ -33,27 +33,24 @@ def process_text(text_input, unit):
|
|
33 |
return ""
|
34 |
|
35 |
|
36 |
-
def process_image(image_input,
|
37 |
if image_input is not None:
|
38 |
with open(image_input.name, "rb") as f:
|
39 |
base64_image = base64.b64encode(f.read()).decode("utf-8")
|
40 |
-
messages = [
|
41 |
-
{"role": "system", "content": f" You are a helpful {unit} doctor." + sys_prompt},
|
42 |
-
{"role": "user", "content": [
|
43 |
-
{"type": "text", "text": "Help me understand what this image"},
|
44 |
-
{"type": "image_url", "image_url": {
|
45 |
-
"url": f"data:image/png;base64,{base64_image}"}
|
46 |
-
}
|
47 |
-
]}
|
48 |
-
]
|
49 |
response = client.chat.completions.create(
|
50 |
model=MODEL,
|
51 |
-
messages=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
temperature=0.0,
|
53 |
)
|
54 |
-
print(response)
|
55 |
return response.choices[0].message.content
|
56 |
-
return ""
|
57 |
|
58 |
|
59 |
def main(text_input="", image_input=None, unit=""):
|
|
|
33 |
return ""
|
34 |
|
35 |
|
36 |
+
def process_image(image_input,unit):
|
37 |
if image_input is not None:
|
38 |
with open(image_input.name, "rb") as f:
|
39 |
base64_image = base64.b64encode(f.read()).decode("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
response = client.chat.completions.create(
|
41 |
model=MODEL,
|
42 |
+
messages=[
|
43 |
+
{"role": "system", "content": f" You are a helpful {unit} doctor." + sys_prompt},
|
44 |
+
{"role": "user", "content": [
|
45 |
+
{"type": "text", "text": "Help me understand what this image"},
|
46 |
+
{"type": "image_url", "image_url": {
|
47 |
+
"url": f"data:image/png;base64,{base64_image}"}
|
48 |
+
}
|
49 |
+
]}
|
50 |
+
],
|
51 |
temperature=0.0,
|
52 |
)
|
|
|
53 |
return response.choices[0].message.content
|
|
|
54 |
|
55 |
|
56 |
def main(text_input="", image_input=None, unit=""):
|