AI API
Provides an API to interact with LLMs
ai.codegen
Signatures
codegen(prompt)
Description
Generate lua code from the prompt.
Example:
local codegen = ai.codegen("Navigate home, wait 5 seconds, then press up and enter")
print(codegen)
-- control.home() wait(5000) control.up() control.ok()
ai.navigate
Signatures
navigate(target, opts \ [])
navigate(arg, target, opts)
Description
Navigate menus using AI
ai.prompt
Signatures
prompt(user_prompt, opts \ [])
prompt(arg, prompt, opts)
Description
Runs a prompt with a provided image, or the current screen and returns the response, and the viewpoint of the AI.
Example:
local response, viewpoint = ai.prompt("What is the color of the screen?")
print(response)
-- "The general color of the screen is blue."
ai.run
Signatures
run(prompt, state)
Description
The same as codegen
, but runs the generated code immediately.
Example:
ai.run("Navigate home, wait 5 seconds, then press up and enter")