-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (22 loc) · 844 Bytes
/
main.py
File metadata and controls
25 lines (22 loc) · 844 Bytes
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
import argparse
from poem import PoemConfig, generate_poem
def parse_args():
p = argparse.ArgumentParser(
description="Generate a short AI poem in the terminal."
)
p.add_argument("theme", help="Theme/topic of the poem, e.g., 'first rain on campus'")
p.add_argument("--form", default="free", help="Style hint: free | haiku | sonnet | limerick")
p.add_argument("--lines", type=int, default=4, help="Number of lines to return")
p.add_argument("--max-new-tokens", type=int, default=80, help="Upper bound on model generation length")
return p.parse_args()
def main():
args = parse_args()
poem = generate_poem(PoemConfig(
theme=args.theme,
form=args.form,
lines=args.lines,
max_new_tokens=args.max_new_tokens,
))
print(poem)
if __name__ == "__main__":
main()