GPT3를 코딩에 활용한다면? Infinite AI Array!

GitHub Copilot과 같이 코드 작성을 도와주는 것 외에, GPT3를 활용한 재미있는 패키지를 발견하여 소개합니다. :smiley:

InfiniteAIArray와 InfiniteAIDict인데요, 각각 List와 Dict의 변수명이나 채워진 일부 값들을 기준으로, 나머지 값들을 채워넣는 것으로 보입니다. :face_with_open_eyes_and_hand_over_mouth:

아래는 블로그에서 소개한 샘플 코드입니다.

$ pip install git+https://github.com/ianb/infinite-ai-array.git
$ export OPENAI_API_KEY=sk-...
$ python
>>> from iaia import InfiniteAIArray, InfiniteAIDict
>>> primes = InfiniteAIArray()
>>> primes[:10]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
>>> minnesota_cities = InfiniteAIArray()
>>> city_populations = InfiniteAIDict()
>>> for i, city in enumerate(minnesota_cities[:6]):
...     print(f"{i+1:>2}. {city:<20} {city_populations[city]}")
 1. Minneapolis          422331
 2. St. Paul             302551
 3. Duluth               87622
 4. Rochester            111264
 5. Bloomington          84863
 6. St. Cloud            68320
>>> favorite_books = InfiniteAIArray(["Dune", "Perdido Street Station", "Red Mars"])
>>> favorite_books[:8]
['Dune', 'Perdido Street Station', 'Red Mars', "The Hitchhiker's Guide to the Galaxy", '1984', 'The Lord of the Rings', "The Handmaid's Tale", 'The Martian Chronicles']
>>> other_favorite_books = InfiniteAIArray(["Wizard Of Oz", "The Trials Of Morrigan Crow", "James and the Giant Peach"])
>>> other_favorite_books[:8]
['Wizard Of Oz', 'The Trials Of Morrigan Crow', 'James and the Giant Peach', 'The Catcher in the Rye', 'The Lion, the Witch and the Wardrobe', 'The Hobbit', 'To Kill a Mockingbird', 'The Alchemist']

아래는 제가 직접 시도해본 결과입니다. ㅎㅎ

image

그럴싸한 명언도 잘 뽑아줍니다.

image

특정 값들을 찾아서 어딘가를 뒤지거나 헤맬 필요없이 뭔가 잘 가져와주고 있어서,
여러모로 새로운 쓰임새를 고민해볼 수 있게 해주는 라이브러리인 것 같아 소개드립니다. :slight_smile:

[GitHub 저장소]

[사용법 소개 글]

https://ianbicking.org/blog/2023/01/infinite-ai-array.html

[사용 방법]

  1. 패키지 설치

    pip install git+https://github.com/ianb/infinite-ai-array.git

  2. OpenAI에서 API Key 발급

    • 처음 가입 시 무료 Credit을 제공하며, 모두 사용한 이후 또는 기간 만료시 사용한 만큼 과금됩니다. :cry:

https://beta.openai.com/account/api-keys