Skip to content

Commit

Permalink
Fix missed third party imports in autogen files (#607)
Browse files Browse the repository at this point in the history
* Fix missed import in file

* Fix missed third party imports in arxiv files

* Move imports inside function and update decorator
  • Loading branch information
kumaranvpl authored Jan 22, 2025
1 parent f328ed7 commit 096bde7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down

0 comments on commit 096bde7

Please sign in to comment.