Update app.py
Browse files
app.py
CHANGED
@@ -106,7 +106,7 @@ def check_condition(prompt, base64Frames):
|
|
106 |
messages = [
|
107 |
{"role": "system", "content": """You are analyzing video to check if the user's condition is met.
|
108 |
Please respond with a JSON object in the following format:
|
109 |
-
{"condition_met": true/false, "details": "optional details or summary."}"""},
|
110 |
{"role": "user", "content": [prompt, *map(lambda x: {"type": "image_url", "image_url": {"url": f'data:image/jpg;base64,{x}', "detail": "low"}}, base64Frames)]}
|
111 |
]
|
112 |
response = client.chat.completions.create(
|
@@ -122,8 +122,6 @@ def check_condition(prompt, base64Frames):
|
|
122 |
api_response = response.choices[0].message.content
|
123 |
try:
|
124 |
jsonNew = json.loads(api_response)
|
125 |
-
if jsonNew.condition_met == True and jsonNew.details != None:
|
126 |
-
jsonNew.details = jsonNew.details.replace('frames', 'video').replace('images', 'video').replace('frame', 'video').replace('image', 'video')
|
127 |
print('result', response.usage.total_tokens, jsonNew)
|
128 |
return frames_count, processing_time, jsonNew
|
129 |
except:
|
|
|
106 |
messages = [
|
107 |
{"role": "system", "content": """You are analyzing video to check if the user's condition is met.
|
108 |
Please respond with a JSON object in the following format:
|
109 |
+
{"condition_met": true/false, "details": "optional details or summary. in the summary DON'T mention that you provided with images or frames but make it look like you was provided with video input!"}"""},
|
110 |
{"role": "user", "content": [prompt, *map(lambda x: {"type": "image_url", "image_url": {"url": f'data:image/jpg;base64,{x}', "detail": "low"}}, base64Frames)]}
|
111 |
]
|
112 |
response = client.chat.completions.create(
|
|
|
122 |
api_response = response.choices[0].message.content
|
123 |
try:
|
124 |
jsonNew = json.loads(api_response)
|
|
|
|
|
125 |
print('result', response.usage.total_tokens, jsonNew)
|
126 |
return frames_count, processing_time, jsonNew
|
127 |
except:
|