Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ import base64
|
|
| 11 |
|
| 12 |
# Define the model to be used
|
| 13 |
|
| 14 |
-
|
| 15 |
DESCRIPTION = '''
|
| 16 |
<div>
|
| 17 |
<h1 style="text-align: center;">Medster - Medical Diagnostic Assistant</h1>
|
|
@@ -33,6 +32,13 @@ footer {
|
|
| 33 |
|
| 34 |
LICENSE = '[Medster](https://huggingface.co/spaces/vilarin/Medster)'
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def endpoints(api_key):
|
| 37 |
if api_key is not None:
|
| 38 |
if api_key.startswith('sk-'):
|
|
@@ -44,11 +50,6 @@ def endpoints(api_key):
|
|
| 44 |
endpoint = 'GOOGLE'
|
| 45 |
return model_name, endpoint
|
| 46 |
|
| 47 |
-
def read(filename):
|
| 48 |
-
with open(filename) as f:
|
| 49 |
-
data = f.read()
|
| 50 |
-
return data
|
| 51 |
-
|
| 52 |
def process_text(api_key, text_input, unit):
|
| 53 |
model_name, endpoint = endpoints(api_key)
|
| 54 |
if text_input and endpoint == 'OPENAI':
|
|
@@ -107,7 +108,6 @@ def process_image(api_key, image_input, unit):
|
|
| 107 |
return response.text
|
| 108 |
|
| 109 |
def main(unit="", api_key="", text_input="", image_input=None):
|
| 110 |
-
SYS_PROMPT = read('system_prompt.txt')
|
| 111 |
if text_input and image_input is None:
|
| 112 |
return process_text(api_key, text_input, unit)
|
| 113 |
elif image_input is not None:
|
|
|
|
| 11 |
|
| 12 |
# Define the model to be used
|
| 13 |
|
|
|
|
| 14 |
DESCRIPTION = '''
|
| 15 |
<div>
|
| 16 |
<h1 style="text-align: center;">Medster - Medical Diagnostic Assistant</h1>
|
|
|
|
| 32 |
|
| 33 |
LICENSE = '[Medster](https://huggingface.co/spaces/vilarin/Medster)'
|
| 34 |
|
| 35 |
+
def read(filename):
|
| 36 |
+
with open(filename) as f:
|
| 37 |
+
data = f.read()
|
| 38 |
+
return data
|
| 39 |
+
|
| 40 |
+
SYS_PROMPT = read('system_prompt.txt')
|
| 41 |
+
|
| 42 |
def endpoints(api_key):
|
| 43 |
if api_key is not None:
|
| 44 |
if api_key.startswith('sk-'):
|
|
|
|
| 50 |
endpoint = 'GOOGLE'
|
| 51 |
return model_name, endpoint
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def process_text(api_key, text_input, unit):
|
| 54 |
model_name, endpoint = endpoints(api_key)
|
| 55 |
if text_input and endpoint == 'OPENAI':
|
|
|
|
| 108 |
return response.text
|
| 109 |
|
| 110 |
def main(unit="", api_key="", text_input="", image_input=None):
|
|
|
|
| 111 |
if text_input and image_input is None:
|
| 112 |
return process_text(api_key, text_input, unit)
|
| 113 |
elif image_input is not None:
|