Update app.py
Browse files
app.py
CHANGED
@@ -50,8 +50,8 @@ def read(filename):
|
|
50 |
return data
|
51 |
|
52 |
def process_text(text_input, unit):
|
53 |
-
|
54 |
-
if text_input and
|
55 |
client = OpenAI(api_key=api_key)
|
56 |
completion = client.chat.completions.create(
|
57 |
model=model_name,
|
@@ -61,7 +61,7 @@ def process_text(text_input, unit):
|
|
61 |
]
|
62 |
)
|
63 |
return completion.choices[0].message.content
|
64 |
-
elif text_input and
|
65 |
genai.configure(api_key=api_key)
|
66 |
model = genai.GenerativeModel(model_name=model_name)
|
67 |
prompt = f" You are a experienced {unit} doctor." + SYS_PROMPT + f"Could you solve {text_input}?"
|
@@ -76,8 +76,8 @@ def encode_image_to_base64(image_input):
|
|
76 |
return img_str
|
77 |
|
78 |
def process_image(image_input, unit):
|
79 |
-
|
80 |
-
if image_input is not None and
|
81 |
client = OpenAI(api_key=api_key)
|
82 |
#with open(image_input.name, "rb") as f:
|
83 |
# base64_image = base64.b64encode(f.read()).decode("utf-8")
|
@@ -99,7 +99,7 @@ def process_image(image_input, unit):
|
|
99 |
max_tokens=1024,
|
100 |
)
|
101 |
return response.choices[0].message.content
|
102 |
-
elif image_input is not None and
|
103 |
genai.configure(api_key=api_key)
|
104 |
model = genai.GenerativeModel(model_name=model_name)
|
105 |
prompt = f" You are a experienced {unit} doctor." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|
|
|
50 |
return data
|
51 |
|
52 |
def process_text(text_input, unit):
|
53 |
+
endpoint = endpoints(api_key)
|
54 |
+
if text_input and endpoint == 'OPENAI':
|
55 |
client = OpenAI(api_key=api_key)
|
56 |
completion = client.chat.completions.create(
|
57 |
model=model_name,
|
|
|
61 |
]
|
62 |
)
|
63 |
return completion.choices[0].message.content
|
64 |
+
elif text_input and endpoint == "GOOGLE":
|
65 |
genai.configure(api_key=api_key)
|
66 |
model = genai.GenerativeModel(model_name=model_name)
|
67 |
prompt = f" You are a experienced {unit} doctor." + SYS_PROMPT + f"Could you solve {text_input}?"
|
|
|
76 |
return img_str
|
77 |
|
78 |
def process_image(image_input, unit):
|
79 |
+
endpoint = endpoints(api_key)
|
80 |
+
if image_input is not None and endpoint == 'OPENAI':
|
81 |
client = OpenAI(api_key=api_key)
|
82 |
#with open(image_input.name, "rb") as f:
|
83 |
# base64_image = base64.b64encode(f.read()).decode("utf-8")
|
|
|
99 |
max_tokens=1024,
|
100 |
)
|
101 |
return response.choices[0].message.content
|
102 |
+
elif image_input is not None and endpoint == "GOOGLE":
|
103 |
genai.configure(api_key=api_key)
|
104 |
model = genai.GenerativeModel(model_name=model_name)
|
105 |
prompt = f" You are a experienced {unit} doctor." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|