• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 2 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Do you worry that you'll get to the end of a good list and have nothing more, leaving you sad and starved of data? Worry no more!

Infinite AI Array

Do you worry that you'll get to the end of a good list and have nothing more, leaving you sad and starved of data? Worry no more!

How are YOU helping to bring AI into your runtimes?

I hear this all the time:

  • Why are my programs so deterministic? How can I make them more exciting and fresh?
  • My lists are small and boring. How can I make them bigger and more interesting?
  • My functions were written by humans. Even copying and pasting without thinking is too much work. How can I make them more dangerously unpredictable?
  • When I write dictionaries I keep getting KeyError. I don't want my computer to tell me what doesn't work, I want to hear answers not problems!

Why this is a solution to your made-up problems

>>> from iaia import InfiniteAIArray
>>> coolest_cities_ranked = InfiniteAIArray()
>>> print(coolest_cities_ranked[:5])
['Tokyo, Japan', 'London, England', 'San Francisco, USA', 'Sydney, Australia', 'Barcelona, Spain']
>>> coldest_cities_ranked = InfiniteAIArray()
>>> print(coldest_cities_ranked[:5])
['Yakutsk, Russia', 'Verkhoyansk, Russia', 'Oymyakon, Russia', 'Ulaanbaatar, Mongolia', 'Yellowknife, Canada']
>>> names = InfiniteAIArray(["Bingo", "Spot", "Fido"])
>>> print(names[:5])
['Bingo', 'Spot', 'Fido', 'Rover', 'Daisy']

Just ask (for values) and you shall receive (more values in your lists).

Also dictionaries...

>>> from iaia import InfiniteAIDict
>>> city_populations = InfiniteAIDict()
>>> for i, city_name in zip(range(5), coolest_cities_ranked):
>>>     print(f"{i+1}. {city_name:<20} {city_populations[city_name]}")
1. Tokyo, Japan         9.273 million
2. New York City, USA   8.623 million
3. London, UK           8.9 million
4. Singapore, Singapore 5.7 million
5. Seoul, South Korea   9.793 million

Strings are cool, but how can I be more daring?

>>> import iaia.magic
>>> iaia.magic.first_primes(5)
[2, 3, 5]

Ugh, typical human error, I didn't make it clearer that I wanted the first 5 primes. What did it do?

>>> print(iaia.magic.first_primes)
def first_primes(arg1: int):
    """
    This function takes an integer argument and returns a list of the first
    prime numbers up to the argument.

    Parameters:
    arg1 (int): The number up to which the prime numbers should be returned.

    Returns:
    list: A list of prime numbers up to the argument.
    """

    prime_list = []
    for num in range(2, arg1 + 1):
        for i in range(2, num):
            if (num % i) == 0:
                break
        else:
            prime_list.append(num)
    return prime_list

Ah, it thought I wanted the primes up to 5, not 5 primes. Let's be clearer:

>>> iaia.magic.first_primes(count=5)
[2, 3, 5, 7, 11]

Exciting stuff...

>>> iaia.magic.fetch_wikipedia_source("Apples")
'#REDIRECT [[Apple]]\n\n{{Redirect category shell|1=\n{{R from plural}}\n}}'
>>> iaia.magic.fetch_wikipedia_source("Apple")
... page source ...

At least that's what it'll (probably) do if you have the requests library installed. (If you don't it will ask if you want to install it.)

"Nothing in life is free" is false, but for this it is true

All those calls were actually backed by GPT-3. GPT-3 costs money. To use it you must sign up for the API and create an API key. Then you can use it like this:

$ export OPENAAI_API_KEY=sk-...

Or while in Python:

>>> import iaia
>>> iaia.set_gpt_key("sk...")

Note that any requests will go in iaia-cache/ and be cached forever.

Seeing what's going on

You'll probably like to see what's going on. To do this either:

$ export IAIA_VERBOSE=1

Or while in Python:

>>> import iaia
>>> iaia.set_verbose(True)

With this is will print the prompts that create all this data, and the responses received. For some list operations it may make multiple requests.

The result looks like this:

>>> import iaia
>>> iaia.set_verbose(True)
>>> book_recommendations = iaia.InfiniteAIArray()
>>> book_recommendations[:3]
Request 1: temperature=0.5
A list of 5 items, created with the code `book_recommendations = iaia. ...# book_recommendations`:


2.
------------------------------------------------------------ Response
 The Catcher in the Rye by J.D. Salinger
3. To Kill a Mockingbird by Harper
Stop reason: length
Response time: 1.64s
Tokens used: 34+24  total: 58 + cached: 0 = 58 ($0.0012 w/o cache $0.0012)
============================================================
...
['The Catcher in the Rye by J.D. Salinger', 'To Kill a Mockingbird by Harper Lee', '1984 by George Orwell']

InfiniteAIArray and InfiniteAIDict both look at the call context to understand the purpose of the list, as well as using the contents of the data structure.

iaia.magic does not use the call context, but it does use the function name, argument types, and keyword names.

Contributing

Hopefully you can see this is not meant to be serious. Contributions to make it serious aren't really the idea. Contributions to make it sillier or more audacious are the idea. Silly examples are also welcome.

More Repositories

1

git-sync

Use git as a sync tool, without munging your source and sync VCS operations
Shell
160
star
2

walkabout.js

An automatic web app tester
JavaScript
155
star
3

doctestjs

Javascript testing made easy and explicit
JavaScript
145
star
4

llm-garden

A number of experiments using GPT-3, delivered in a web app
JavaScript
48
star
5

jsshell

Shell (ala bash) written in Javascript for the browser and Node.js (incomplete prototype!)
JavaScript
47
star
6

personal-history-archive

An experiment in creating a dump of your personal browser history for analysis
Jupyter Notebook
33
star
7

neighborly

Neighbor-to-neighbor communication tool
Python
28
star
8

pywebapp

Support library for Python Web Applications
Python
19
star
9

sticky-reader-mode

A browser extension to turn on Reader Mode automatically per your preference
JavaScript
18
star
10

seeitsaveit

A Firefox Addon to extract and route information from web pages using ad hoc user scripts
JavaScript
16
star
11

whrandom

A port of Python's pseudo-random generator, whrandom
JavaScript
13
star
12

thecutout

A data storage and synchronozation system for client/browser-based applications
Python
11
star
13

wsgibrowserid

Stand-alone app to implement relying-party browserid.org support
Python
8
star
14

copy-keeper

An experimental add-on for saving everything you copy
JavaScript
7
star
15

webannotate

Annotate (add comments to) web pages
JavaScript
6
star
16

blog

My blog
HTML
6
star
17

find-plus-one

An experimental browser extension for search in pages linked from the current page
JavaScript
6
star
18

tab-switchr

Experimental super-simple tab switching add-on
JavaScript
5
star
19

wsgi-access-control

Access-Control-Allow-Origin etc middleware for WSGI
Python
4
star
20

apppkg

Application Package, a format for executable introspectable stuff
Python
4
star
21

fatfingers

A Javascript library to turn inaccurate touches into a modal selection to disambiguate
JavaScript
3
star
22

python-dc311

Python API for the Washington DC 311 API
Python
3
star
23

copy-url-extension

Small Firefox extension to make it easy to copy the page URL with the title
JavaScript
3
star
24

emailit

A very little Python app to email web pages to people
JavaScript
3
star
25

statusnet-firefoxshare

A Status.net plugin for Firefox Share (F1) support
PHP
2
star
26

alexa-sites

Whitelist of common sites, using Alexa as a basis
Shell
2
star
27

browsercommander

A browser-based shell and general system commander
JavaScript
2
star
28

thrive-ai

Implementation of the game Thrive, with some basic AI
Python
2
star
29

cmdutils

Python
2
star
30

phrase-matcher

JavaScript library to pattern-match English phrases
JavaScript
2
star
31

bitplanning

Playing around with Logic Planning, as described in Artificial Intelligence: A Modern Approach
Jupyter Notebook
2
star
32

app1.ianbicking.org

Test app
HTML
2
star
33

xmasapp

Little (open)webapp for Christmas Lyrics
Python
2
star
34

aitc-html

Apps In The Cloud HTML implementation
JavaScript
1
star
35

partial-language

An experiment with a partially-evaluated language: https://www.ianbicking.org/blog/2020/09/project-ideas-2020.html#partial-evaluation
JavaScript
1
star
36

intent-experiment

Just playing around with intent parsing
Shell
1
star
37

fungpt

Code for a presentation on coding with GPT
JavaScript
1
star
38

silverlining

(deprecated) A system to make easily deployable applications
Python
1
star
39

soul-faith

Open Soul named "Faith"
TypeScript
1
star
40

logdb-app

App structure for logdb
1
star
41

wphp

(deprecated) WSGI wrapper for PHP
Python
1
star
42

sheets

Experimenting with a Jupyter Notebook-style Python interface
Python
1
star
43

memebot

Messing around with meBot programming
Python
1
star
44

misc-recipes

These are old bits of code I kept on my once-SVN server
Python
1
star
45

crossnav

An experimental add-on to offer different ways to navigate from a page (besides in-page hyperlinks)
1
star
46

intra-game

An LLM text adventure game
TypeScript
1
star