-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimg.lua
More file actions
64 lines (55 loc) · 1.64 KB
/
img.lua
File metadata and controls
64 lines (55 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- Check for invalid repository name
local isMain = fs.exists("/DALL-CC-main/")
local isDALL = fs.exists("/DALL-CC/")
if isMain then
error("Incorrect repository name, please rename DALL-CC-main to simply DALL-CC.")
elseif not isDALL then
error("Incorrect repository location or name, please ensure DALL-CC is installed on root, as /DALL-CC/.")
end
-- Import openai and quill
local pathOG = package.path
package.path = "/DALL-CC/?.lua;" .. package.path
local sketch = require("lib/sketch")
local quill = require("lib/quill")
-- User input for risk and personality
local number, magnitude = ...
number = tonumber(number)
-- Input testing for non-number
if type(number) ~= "number" then
number = 1
end
-- Input testing for out of range
if number < 1 then
number = 1
elseif number > 10 then
number = 10
end
-- Magnitude conversion, defaults to large
if magnitude then
magnitude = string.lower(magnitude)
else
magnitude = "sm"
end
local size
if magnitude == "sm" then
size = "256x256"
elseif magnitude == "md" or magnitude == "lg" then -- Medium AND large
size = "512x512"
elseif magnitude == "lg" then --! Large images not rendering, thus temporarily disabled
size = "1024x1024"
end
-- Printing chosen arguments
print('Number: ' .. number .. ' Size: "' .. size .. '"\n')
-- Read input
term.setTextColour(colours.red)
local prompt = read()
print("\n")
term.setTextColour(colours.orange)
print("Read...\n")
-- Prompt testing
if not prompt then
error('Error: no prompt provided. Usage: img [number] [magnitude](sm, md, lg)')
end
-- Generate and display images
local links = sketch.generate(prompt, number, size)
sketch.display(links)