Update app.py
Browse files
app.py
CHANGED
|
@@ -52,6 +52,7 @@ def read(filename):
|
|
| 52 |
return data
|
| 53 |
|
| 54 |
def process_text(text_input, unit):
|
|
|
|
| 55 |
if text_input and endpoints == 'OPENAI':
|
| 56 |
client = OpenAI(api_key=api_key)
|
| 57 |
completion = client.chat.completions.create(
|
|
@@ -77,6 +78,7 @@ def encode_image_to_base64(image_input):
|
|
| 77 |
return img_str
|
| 78 |
|
| 79 |
def process_image(image_input, unit):
|
|
|
|
| 80 |
if image_input is not None and endpoints == 'OPENAI':
|
| 81 |
client = OpenAI(api_key=api_key)
|
| 82 |
#with open(image_input.name, "rb") as f:
|
|
@@ -107,7 +109,6 @@ def process_image(image_input, unit):
|
|
| 107 |
return response.text
|
| 108 |
|
| 109 |
def main(api_key="", text_input="", image_input=None, unit=""):
|
| 110 |
-
endpoints = endpoints(api_key)
|
| 111 |
SYS_PROMPT = read('system_prompt.txt')
|
| 112 |
if text_input and image_input is None:
|
| 113 |
return process_text(text_input,unit)
|
|
|
|
| 52 |
return data
|
| 53 |
|
| 54 |
def process_text(text_input, unit):
|
| 55 |
+
endpoints = endpoints(api_key)
|
| 56 |
if text_input and endpoints == 'OPENAI':
|
| 57 |
client = OpenAI(api_key=api_key)
|
| 58 |
completion = client.chat.completions.create(
|
|
|
|
| 78 |
return img_str
|
| 79 |
|
| 80 |
def process_image(image_input, unit):
|
| 81 |
+
endpoints = endpoints(api_key)
|
| 82 |
if image_input is not None and endpoints == 'OPENAI':
|
| 83 |
client = OpenAI(api_key=api_key)
|
| 84 |
#with open(image_input.name, "rb") as f:
|
|
|
|
| 109 |
return response.text
|
| 110 |
|
| 111 |
def main(api_key="", text_input="", image_input=None, unit=""):
|
|
|
|
| 112 |
SYS_PROMPT = read('system_prompt.txt')
|
| 113 |
if text_input and image_input is None:
|
| 114 |
return process_text(text_input,unit)
|