Skip to content

Commit

Permalink
black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed May 6, 2024
1 parent 2c3fa2e commit 0d763ee
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/tools/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PIL import Image

from vision_agent.tools import TOOLS, Tool, register_tool
from vision_agent.tools.tools import BboxIoU, BoxDistance, SegArea, SegIoU, MaskDistance
from vision_agent.tools.tools import BboxIoU, BoxDistance, MaskDistance, SegArea, SegIoU


def test_bbox_iou():
Expand Down
2 changes: 1 addition & 1 deletion vision_agent/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .agent import Agent
from .agent_coder import AgentCoder
from .automated_vision_agent import AutomatedVisionAgent
from .easytool import EasyTool
from .reflexion import Reflexion
from .vision_agent import VisionAgent
from .automated_vision_agent import AutomatedVisionAgent
1 change: 0 additions & 1 deletion vision_agent/agent/agent_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from .agent_coder_prompts import DEBUG, FIX_BUG, PROGRAM, TEST, VISUAL_TEST


IMPORT_HELPER = """
import math
import re
Expand Down
20 changes: 15 additions & 5 deletions vision_agent/agent/automated_vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def write_plan(
return plan["plan"]


def write_code(user_req: str, subtask: str, tool_info: str, code: str, model: LLM) -> str:
def write_code(
user_req: str, subtask: str, tool_info: str, code: str, model: LLM
) -> str:
prompt = CODE.format(
context=USER_REQ_SUBTASK_CONTEXT.format(user_requirement=user_req, subtask=subtask),
context=USER_REQ_SUBTASK_CONTEXT.format(
user_requirement=user_req, subtask=subtask
),
tool_info=tool_info,
code=code,
)
Expand All @@ -62,9 +66,13 @@ def write_code(user_req: str, subtask: str, tool_info: str, code: str, model: LL
return extract_code(code)


def write_test(user_req: str, subtask: str, tool_info: str, code: str, model: LLM) -> str:
def write_test(
user_req: str, subtask: str, tool_info: str, code: str, model: LLM
) -> str:
prompt = TEST.format(
context=USER_REQ_SUBTASK_CONTEXT.format(user_requirement=user_req, subtask=subtask),
context=USER_REQ_SUBTASK_CONTEXT.format(
user_requirement=user_req, subtask=subtask
),
tool_info=tool_info,
code=code,
)
Expand Down Expand Up @@ -164,7 +172,9 @@ def run_plan(
f"""
{tabulate(tabular_data=[task], headers="keys", tablefmt="mixed_grid", maxcolwidths=_MAX_TABULATE_COL_WIDTH)}"""
)
tool_info = "\n".join([e["doc"] for e in tool_recommender.top_k(task["instruction"])])
tool_info = "\n".join(
[e["doc"] for e in tool_recommender.top_k(task["instruction"])]
)
success, code, result, task_memory = write_and_exec_code(
user_req,
task["instruction"],
Expand Down
6 changes: 3 additions & 3 deletions vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from PIL import Image
from tabulate import tabulate

from vision_agent.llm import LLM, OpenAILLM
from vision_agent.lmm import LMM, OpenAILMM
from vision_agent.tools import TOOLS
from vision_agent.utils.image_utils import (
convert_to_b64,
overlay_bboxes,
overlay_heat_map,
overlay_masks,
)
from vision_agent.llm import LLM, OpenAILLM
from vision_agent.lmm import LMM, OpenAILMM
from vision_agent.tools import TOOLS

from .agent import Agent
from .easytool_prompts import (
Expand Down
4 changes: 2 additions & 2 deletions vision_agent/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
TOOLS,
BboxArea,
BboxIoU,
ObjectDistance,
BoxDistance,
MaskDistance,
Crop,
DINOv,
ExtractFrames,
GroundingDINO,
GroundingSAM,
ImageCaption,
ImageQuestionAnswering,
MaskDistance,
ObjectDistance,
SegArea,
SegIoU,
Tool,
Expand Down
6 changes: 3 additions & 3 deletions vision_agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from PIL.Image import Image as ImageType
from scipy.spatial import distance # type: ignore

from vision_agent.lmm import OpenAILMM
from vision_agent.tools.tool_utils import _send_inference_request
from vision_agent.utils import extract_frames_from_video
from vision_agent.utils.image_utils import (
b64_to_pil,
convert_to_b64,
Expand All @@ -19,9 +22,6 @@
normalize_bbox,
rle_decode,
)
from vision_agent.lmm import OpenAILMM
from vision_agent.tools.tool_utils import _send_inference_request
from vision_agent.utils import extract_frames_from_video

_LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions vision_agent/tools/tools_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import tempfile
from importlib import resources
from pathlib import Path
from typing import Any, Callable, Dict, List, Union, Tuple
from typing import Any, Callable, Dict, List, Tuple, Union

import numpy as np
import pandas as pd
import requests
from PIL import Image, ImageDraw, ImageFont

from vision_agent.utils.image_utils import convert_to_b64, normalize_bbox, rle_decode
from vision_agent.tools.tool_utils import _send_inference_request
from vision_agent.utils import extract_frames_from_video
from vision_agent.utils.image_utils import convert_to_b64, normalize_bbox, rle_decode

COLORS = [
(158, 218, 229),
Expand Down
2 changes: 1 addition & 1 deletion vision_agent/utils/sim.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import List, Optional, Sequence, Union, Dict
from typing import Dict, List, Optional, Sequence, Union

import pandas as pd
from openai import Client
Expand Down

0 comments on commit 0d763ee

Please sign in to comment.