diff --git a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py index d7a2fed0b2..1afdb3099d 100644 --- a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py +++ b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py @@ -1,12 +1,12 @@ # Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai # # SPDX-License-Identifier: Apache-2.0 -import arxiv + from ......coding.func_with_reqs import with_requirements -@with_requirements(["arxiv"], ["arxiv"]) +@with_requirements(["arxiv"]) def arxiv_download(id_list: list, download_dir="./"): """Downloads PDF files from ArXiv based on a list of arxiv paper IDs. @@ -17,6 +17,8 @@ def arxiv_download(id_list: list, download_dir="./"): Returns: list: A list of paths to the downloaded PDF files. """ + import arxiv + paths = [] for paper in arxiv.Client().results(arxiv.Search(id_list=id_list)): path = paper.download_pdf(download_dir, filename=paper.get_short_id() + ".pdf") diff --git a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py index 41df6fd92c..e0fd9883e2 100644 --- a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py +++ b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py @@ -1,12 +1,12 @@ # Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai # # SPDX-License-Identifier: Apache-2.0 -import arxiv + from ......coding.func_with_reqs import with_requirements -@with_requirements(["arxiv"], ["arxiv"]) +@with_requirements(["arxiv"]) def arxiv_search(query, max_results=10, sortby="relevance"): """Search for articles on arXiv based on the given query. @@ -24,6 +24,7 @@ def arxiv_search(query, max_results=10, sortby="relevance"): - 'doi': The DOI of the article (If applicable). - 'published': The publication date of the article in the format 'Y-M'. """ + import arxiv def get_author(r): return ", ".join(a.name for a in r.authors) diff --git a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py index 5b9eb9fd02..76f9341c56 100644 --- a/autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py +++ b/autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py @@ -3,12 +3,10 @@ # SPDX-License-Identifier: Apache-2.0 import os -from PIL import Image - from ......coding.func_with_reqs import with_requirements -@with_requirements(["transformers", "torch"], ["transformers", "torch", "PIL", "os"]) +@with_requirements(["transformers", "torch", "PIL"], ["transformers", "torch", "os"]) def image_qa(image, question, ckpt="Salesforce/blip-vqa-base"): """Perform question answering on an image using a pre-trained VQA model. @@ -20,6 +18,7 @@ def image_qa(image, question, ckpt="Salesforce/blip-vqa-base"): dict: The generated answer text. """ import torch + from PIL import Image from transformers import BlipForQuestionAnswering, BlipProcessor def image_processing(img):