HamaWhiteGG / autogen4j

Java version of Microsoft AutoGen, Enable Next-Gen Large Language Model Applications
34 stars 4 forks source link

[Optimization][autogen4j-core] Support parsing the '# filename: xxx.py' in the code. #16

Open HamaWhiteGG opened 9 months ago

HamaWhiteGG commented 9 months ago

Search before asking

Description

Oh, I apologize for the confusion. There was a minor issue with how I used the arxiv library.

The arxiv.Search object doesn't have a get() method. Instead, the arxiv.Search objects are iterable, so we should directly iterate over the result of the search.

Here's the corrected python code:

# filename: fetch_arxiv_papers.py
import arxiv
import datetime
from operator import itemgetter

def fetch_gpt_4_papers():
    search = arxiv.Search(
        query='gpt-4',
        max_results=1000,
        sort_by=arxiv.SortCriterion.SubmittedDate
    )
    papers = []
    for result in search.results():
        papers.append({
            'title': result.title,
            'authors': result.authors,
            'url': result.entry_id,
            'published': result.published,
            'summary': result.summary
        })

    papers_sorted = sorted(papers, key=itemgetter('published'), reverse=True)
    return papers_sorted

def main():
    papers = fetch_gpt_4_papers()
    for paper in papers:
        print('Title: ', paper['title'])
        print('Authors: ', ', '.join(paper['authors']))
        print('Published Date: ', paper['published'].strftime("%Y-%m-%d"))
        print('URL: ', paper['url'])
        print('Abstract: ', paper['summary'])
        print('\n\n')

if __name__ == "__main__":
    main()

You can save this Python script as 'fetch_arxiv_papers.py' and run it as follows:

python fetch_arxiv_papers.py

This script will print out the details of the latest papers about GPT-4 from arXiv.org. After running the script, use your language analyzing skills to read the abstracts and find out the potential applications of GPT-4 in software from these papers.