Alert

Actor is under maintenance

This actor may be unreliable while under maintenance. Would you like to try a similar actor instead?

Actor picture

Open AI Completion

tkapler/openai-completion-actor

Provides a simple but powerful text-in, text-out interface to any OpenAI models. You input some text as a prompt, and the model will generate a text completion that attempts to match whatever context or pattern you gave it. https://beta.openai.com/docs/guides/completion

No credit card required

Author's avatarTomas Kapler
  • Modified
  • Users12
  • Runs59
Actor picture
Open AI Completion

This Apify Actor use Open AI beta and its Completions Guide to provide advance AI answers to your prompts using GPT-3 and Codex models.

*You must recieve the Open AI beta access / API key. Join the waitlist if you do not have it yet (it can take few weeks)

Input properties

There are 2 key input properties

Details about the other properties you can find under the (?) help icon, in INPUT_SCHEMA.json and in Open AI Codex Reference.

Example prompt

You can type almost anything, good examples can be found in Open AI examples section, e.g.

Grammar correction - Davinci GPT-3

link This zero-shot prompt corrects sentences into standard English.

Prompt

Original: She no went to the market.
Standard American English:

Sample response

She didn't go to the market.

Explain code - Davinci Codex

link Explain a complicated piece of code.

Prompt

class Log:
    def __init__(self, path):
        dirname = os.path.dirname(path)
        os.makedirs(dirname, exist_ok=True)
        f = open(path, "a+")

        # Check that the file is newline-terminated
        size = os.path.getsize(path)
        if size > 0:
            f.seek(size - 1)
            end = f.read(1)
            if end != "\n":
                f.write("\n")
        self.f = f
        self.path = path

    def log(self, event):
        event["_event_id"] = str(uuid.uuid4())
        json.dump(event, self.f)
        self.f.write("\n")

    def state(self):
        state = {"complete": set(), "last": None}
        for line in open(self.path):
            event = json.loads(line)
            if event["type"] == "submit" and event["success"]:
                state["complete"].add(event["id"])
                state["last"] = event
        return state

"""
Here's what the above class is doing:

Sample response

1. Create a directory for the log file if it doesn't exist.
2. Open the log file in append mode.
3. Check that the file is newline-terminated. If it isn't, add a newline.
4. Create a state dictionary with two keys:
    - complete: a set of all completed job IDs
    - last: the last event in the log file
5. Return the state dictionary.

Industries

See how Open AI Completion is used in industries around the world