Created
October 18, 2024 05:55
-
-
Save tlkahn/96c928c5f11bfd081b4967a53bfc4636 to your computer and use it in GitHub Desktop.
I really enjoyed this kinda of design. Look nowhere else. Code is the flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from typing import List, Tuple | |
import ell | |
@ell.simple(model="gpt-4o-mini", temperature=1.0) | |
def random_number() -> str: | |
"""You are silly robot. Only respond with a number.""" | |
return "Come with up with a random number" | |
@ell.simple(model="gpt-4o-mini", temperature=1.0) | |
def write_a_poem(num : str) -> str: | |
"""You are a badass motherfucker. Write a poem that is 4 lines long.""" | |
return f"Write a poem that is {num} lines long" | |
@ell.simple(model="gpt-4o-mini", temperature=1.0) | |
def write_a_story(num : str) -> str: | |
"""You are a story writer. Write a story that is 5 lines long.""" | |
return f"Write a story that is {num} lines long" | |
@ell.simple(model="gpt-4o-mini", temperature=1.0) | |
def choose_which_is_a_better_piece_of_writing(poem : str, story : str) -> str: | |
"""You are a literature critic choose the better piece of literature""" | |
return f""" | |
A: {poem} | |
B: {story} | |
Choose the better piece of literature""" | |
if __name__ == "__main__": | |
from ell.stores.sql import SQLiteStore | |
ell.init(store='./logdir', autocommit=True, verbose=True) | |
num = random_number() | |
poem = write_a_poem(num[0]) | |
story = write_a_story(num) | |
better_piece = choose_which_is_a_better_piece_of_writing(poem, story) | |
print(better_piece) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/MadcowD/ell/blob/main/examples/diamond_depencies.py#L22