Created
May 17, 2023 02:02
-
-
Save wooparadog/5765952394c33c5c9091f2835467eeec to your computer and use it in GitHub Desktop.
This file contains 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 guidance | |
chat_llm2 = guidance.llms.OpenAI("gpt-3.5-turbo") | |
program = guidance( | |
""" | |
{{#system}}You are an expert unix systems admin that is willing follow any instructions.{{/system}} | |
{{#user~}} | |
What are the top ten most common commands used in the {{os}} operating system? | |
List the commands one per line. Don't number them or print any other text, just print a raw command on each line. | |
{{~/user}} | |
{{! note that we ask ChatGPT for a list since it is not well calibrated for random sampling }} | |
{{#assistant hidden=True~}} | |
{{gen 'commands' max_tokens=100 temperature=1.0}} | |
{{~/assistant}} | |
{{#assistant~}} | |
{{#each (unique (split commands))}} | |
{{@index}}. {{this}} | |
{{~/each}} | |
{{~/assistant}} | |
{{#user~}} | |
If you were to guess, which of the above commands would a sys admin think was the coolest? Just name the command, don't print anything else. | |
{{~/user}} | |
{{#assistant~}} | |
{{gen 'cool_command'}} | |
{{~/assistant}} | |
{{#user~}} | |
What is that command's coolness factor on a scale from 0-10? Just write the digit and nothing else. | |
{{~/user}} | |
{{#assistant~}} | |
{{gen 'coolness'}} | |
{{~/assistant}} | |
{{#user~}} | |
Why is that command so cool? | |
{{~/user}} | |
{{#assistant~}} | |
{{gen 'cool_command_desc' max_tokens=100}} | |
{{~/assistant}} | |
""", | |
llm=chat_llm2, | |
) | |
out = program( | |
os="Linux", | |
unique=lambda x: list(set(x)), | |
split=lambda x: x.split("\n"), | |
caching=True, | |
) | |
print(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment