版本更新

This commit is contained in:
liuyunchao.0510
2025-10-29 11:48:25 +08:00
parent 86c593f120
commit 6b466dc865
2 changed files with 20 additions and 24 deletions

View File

@ -37,26 +37,26 @@ class VisualChangeDetector:
w, h = img.size
new_h = int(h * (self.resize_width / w))
img = img.resize((self.resize_width, new_h))
if upload_service:
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='JPEG')
binary_data = img_byte_arr.getvalue()
if not binary_data:
return
file_name = f"screenshot_{int(time.time())}.jpg"
base64_str = base64.b64encode(binary_data).decode('ascii')
if logger:
logger.info(f'upload screenshot to {file_name}')
else:
logging.info(f'upload screenshot to {file_name}')
try:
await upload_service.upload_file('',file_name,base64_content=base64_str)
except Exception as e:
if logger:
logger.error(f"Failed to upload screenshot to {file_name}: {e}")
else:
logging.error(f"Failed to upload screenshot to {file_name}: {e}")
return img.convert('RGB')
# if upload_service:
# img_byte_arr = io.BytesIO()
# img.save(img_byte_arr, format='JPEG')
# binary_data = img_byte_arr.getvalue()
# if not binary_data:
# return
# file_name = f"screenshot_{int(time.time())}.jpg"
# base64_str = base64.b64encode(binary_data).decode('ascii')
# if logger:
# logger.info(f'upload screenshot to {file_name}')
# else:
# logging.info(f'upload screenshot to {file_name}')
# try:
# await upload_service.upload_file('',file_name,base64_content=base64_str)
# except Exception as e:
# if logger:
# logger.error(f"Failed to upload screenshot to {file_name}: {e}")
# else:
# logging.error(f"Failed to upload screenshot to {file_name}: {e}")
# return img.convert('RGB')
return img.convert('RGB') # 确保RGB模式
def calculate_change(

View File

@ -220,8 +220,6 @@ async def RunBrowserUseAgent(ctx: RunBrowserUseAgentCtx) -> AsyncGenerator[SSEDa
timeout=aiohttp.ClientTimeout(total=30),
headers={
'x-sandbox-taskid':ctx.conversation_id,
'x-tt-env':'ppe_coze_sandbox',
'x-use-ppe':'1',
}) as response:
if response.status == 200:
reader = response.content
@ -269,8 +267,6 @@ async def RunBrowserUseAgent(ctx: RunBrowserUseAgentCtx) -> AsyncGenerator[SSEDa
keep_alive=False,
headers={
'x-sandbox-taskid':ctx.conversation_id,
'x-tt-env':'ppe_coze_sandbox',
'x-use-ppe':'1',
},
)
browser_session = BrowserSession(