From a72084cfd030acc39938f8d2d33188a63b2fc21b Mon Sep 17 00:00:00 2001 From: Yazhou Cao Date: Mon, 17 Jun 2024 09:29:10 -0700 Subject: [PATCH 1/5] Changes to support benchmarking --- examples/mask_app/app.py | 3 ++- poetry.lock | 6 +++--- vision_agent/agent/vision_agent_prompts.py | 2 ++ vision_agent/utils/execute.py | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/examples/mask_app/app.py b/examples/mask_app/app.py index 23a5fc78..cbe5ab25 100644 --- a/examples/mask_app/app.py +++ b/examples/mask_app/app.py @@ -1,8 +1,9 @@ import cv2 -import streamlit as st from PIL import Image from streamlit_drawable_canvas import st_canvas +import streamlit as st + st.title("Image Segmentation Mask App") uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"]) diff --git a/poetry.lock b/poetry.lock index 0a5128e4..5f25ac37 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1145,13 +1145,13 @@ test = ["ipykernel", "pre-commit", "pytest (<8)", "pytest-cov", "pytest-timeout" [[package]] name = "langsmith" -version = "0.1.75" +version = "0.1.77" description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." optional = false python-versions = "<4.0,>=3.8.1" files = [ - {file = "langsmith-0.1.75-py3-none-any.whl", hash = "sha256:d08b08dd6b3fa4da170377f95123d77122ef4c52999d10fff4ae08ff70d07aed"}, - {file = "langsmith-0.1.75.tar.gz", hash = "sha256:61274e144ea94c297dd78ce03e6dfae18459fe9bd8ab5094d61a0c4816561279"}, + {file = "langsmith-0.1.77-py3-none-any.whl", hash = "sha256:2202cc21b1ed7e7b9e5d2af2694be28898afa048c09fdf09f620cbd9301755ae"}, + {file = "langsmith-0.1.77.tar.gz", hash = "sha256:4ace09077a9a4e412afeb4b517ca68e7de7b07f36e4792dc8236ac5207c0c0c7"}, ] [package.dependencies] diff --git a/vision_agent/agent/vision_agent_prompts.py b/vision_agent/agent/vision_agent_prompts.py index b2074c79..09105ca1 100644 --- a/vision_agent/agent/vision_agent_prompts.py +++ b/vision_agent/agent/vision_agent_prompts.py @@ -179,6 +179,8 @@ def find_text(image_path: str, text: str) -> str: 8. DO NOT use try except block to handle the error, let the error be raised if the code is incorrect. 9. DO NOT import the testing function as it will available in the testing environment. 10. Print the output of the function that is being tested. +11. Use the output of the function that is being tested as the return value of the testing function. +12. Run the testing function in the end and don't assign a variable to its output. """ diff --git a/vision_agent/utils/execute.py b/vision_agent/utils/execute.py index f38a123d..c3211ac9 100644 --- a/vision_agent/utils/execute.py +++ b/vision_agent/utils/execute.py @@ -2,6 +2,7 @@ import atexit import base64 import copy +import json import logging import os import platform @@ -309,6 +310,21 @@ def success(self) -> bool: """ return self.error is None + def get_main_result(self) -> Optional[Result]: + """ + Get the main result of the execution. + An execution may have multiple results, e.g. intermediate outputs. The main result is the last output of the cell execution. + """ + if not self.success: + _LOGGER.info("Result is not available as the execution was not successful.") + return None + if not self.results or not any(res.is_main_result for res in self.results): + _LOGGER.info("Execution was successful but there is no main result.") + return None + main_result = self.results[-1] + assert main_result.is_main_result, "The last result should be the main result." + return main_result + def to_json(self) -> str: """ Returns the JSON representation of the Execution object. From 188c00308a51ffd7ad42c7fea8d693e70f1154aa Mon Sep 17 00:00:00 2001 From: Yazhou Cao Date: Mon, 17 Jun 2024 09:33:56 -0700 Subject: [PATCH 2/5] Fix lint --- vision_agent/utils/execute.py | 1 - 1 file changed, 1 deletion(-) diff --git a/vision_agent/utils/execute.py b/vision_agent/utils/execute.py index c3211ac9..e755e498 100644 --- a/vision_agent/utils/execute.py +++ b/vision_agent/utils/execute.py @@ -2,7 +2,6 @@ import atexit import base64 import copy -import json import logging import os import platform From f4910fabdb5747a0e47d4f795cd5f106e15b058e Mon Sep 17 00:00:00 2001 From: Yazhou Cao Date: Mon, 17 Jun 2024 09:50:35 -0700 Subject: [PATCH 3/5] Empty-Commit From 894884e11befb1da24118e2886abc0c255ee736b Mon Sep 17 00:00:00 2001 From: Yazhou Cao Date: Mon, 17 Jun 2024 10:21:10 -0700 Subject: [PATCH 4/5] Replace pkg_resources with importlib --- vision_agent/utils/execute.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision_agent/utils/execute.py b/vision_agent/utils/execute.py index e755e498..76a487bc 100644 --- a/vision_agent/utils/execute.py +++ b/vision_agent/utils/execute.py @@ -426,11 +426,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: """ import platform import sys -import pkg_resources +import importlib.metadata print(f"Python version: {sys.version}") print(f"OS version: {platform.system()} {platform.release()} ({platform.architecture()})") -va_version = pkg_resources.get_distribution("vision-agent").version +va_version = importlib.metadata.version("vision-agent") print(f"Vision Agent version: {va_version}")""" ) sys_versions = "\n".join(result.logs.stdout) From 919fee7a6f588e443eaf04a8860de70eba45efbb Mon Sep 17 00:00:00 2001 From: Yazhou Cao Date: Mon, 17 Jun 2024 10:30:30 -0700 Subject: [PATCH 5/5] Empty-Commit