Skip to content

Commit

Permalink
Only use third party modules in optional imports not autogen imports …
Browse files Browse the repository at this point in the history
…in test/agentchat/contrib files
  • Loading branch information
kumaranvpl committed Jan 22, 2025
1 parent a5d0aea commit 8df9550
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
22 changes: 11 additions & 11 deletions test/agentchat/contrib/test_img_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
import unittest
from unittest.mock import patch

import numpy as np
import pytest
import requests

from autogen.agentchat.contrib.img_utils import (
convert_base64_to_data_uri,
extract_img_paths,
get_image_data,
get_pil_image,
gpt4v_formatter,
llava_formatter,
message_formatter_pil_to_b64,
num_tokens_from_gpt_image,
)
from autogen.import_utils import optional_import_block

with optional_import_block() as result:
import numpy as np
from PIL import Image

from autogen.agentchat.contrib.img_utils import (
convert_base64_to_data_uri,
extract_img_paths,
get_image_data,
get_pil_image,
gpt4v_formatter,
llava_formatter,
message_formatter_pil_to_b64,
num_tokens_from_gpt_image,
)

skip = not result.is_successful

Expand Down
3 changes: 2 additions & 1 deletion test/agentchat/contrib/test_llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

import pytest

from autogen.agentchat.contrib.llava_agent import LLaVAAgent, _llava_call_binary_with_config, llava_call
from autogen.import_utils import optional_import_block

from ...conftest import MOCK_OPEN_AI_API_KEY

with optional_import_block() as result:
from autogen.agentchat.contrib.llava_agent import LLaVAAgent, _llava_call_binary_with_config, llava_call
import replicate # noqa: F401

skip = not result.is_successful

Expand Down
6 changes: 4 additions & 2 deletions test/agentchat/contrib/test_lmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import pytest

import autogen
from autogen.agentchat.contrib.img_utils import get_pil_image
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
from autogen.agentchat.conversable_agent import ConversableAgent
from autogen.import_utils import optional_import_block

from ...conftest import MOCK_OPEN_AI_API_KEY

with optional_import_block() as result:
from autogen.agentchat.contrib.img_utils import get_pil_image
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
from PIL import Image # noqa: F401


skip = not result.is_successful

Expand Down
8 changes: 7 additions & 1 deletion test/agentchat/contrib/test_web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pytest

from autogen import UserProxyAgent
from autogen.agentchat.contrib.web_surfer import WebSurferAgent
from autogen.import_utils import optional_import_block

from ...conftest import MOCK_OPEN_AI_API_KEY, Credentials
Expand All @@ -21,7 +22,12 @@
BING_QUERY = "Microsoft"

with optional_import_block() as result:
from autogen.agentchat.contrib.web_surfer import WebSurferAgent
import markdownify # noqa: F401
import pathvalidate # noqa: F401
import pdfminer # noqa: F401
import requests # noqa: F401
from bs4 import BeautifulSoup # noqa: F401


skip_all = not result.is_successful

Expand Down

0 comments on commit 8df9550

Please sign in to comment.