-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathillustrate.py
executable file
·67 lines (48 loc) · 1.65 KB
/
illustrate.py
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
65
66
67
#!python3
import typer
from loguru import logger
from rich.console import Console
import openai_wrapper
import ell
from ell_helper import init_ell, run_studio, get_ell_model
from typer import Option
import os
console = Console()
app = typer.Typer(no_args_is_help=True)
# Initialize ELL
init_ell()
def show(img):
if "TMUX" in os.environ:
os.system(f"timg --grid 4 --title -ps {img}")
else:
os.system(f"timg --grid 4 --title -p {img}")
@app.command()
def studio(port: int = Option(None, help="Port to run the ELL Studio on")):
"""
Launch the ELL Studio interface for interactive model exploration and testing.
This command opens the ELL Studio, allowing users to interactively work with
language models, test prompts, and analyze responses in a user-friendly environment.
"""
run_studio(port=port)
@ell.simple(model=get_ell_model(openai=True), n=2)
def prompt_illustrate(content: str):
"""
Create an image to represent this blog post. It should be fun whimsical and if it features people make them a 3d render of a cartoon racoon in the pixar style, the main racoon should be in his late 30s wearing very colorful glasses, and whimsical.
"""
return content # This will be the user prompt
# https://docs.ell.so/core_concepts/multimodality.html
# Dalle-3 isn't implemented yet :(
@app.command()
def draw(
path: str = typer.Argument(None),
):
import image
user_text = openai_wrapper.get_text_from_path_or_stdin(path)
ret = prompt_illustrate(user_text)
for r in ret:
image.gen_igor(str(r))
@logger.catch()
def app_wrap_loguru():
app()
if __name__ == "__main__":
app_wrap_loguru()