Skip to content

Instantly share code, notes, and snippets.

@wxgeorge
Last active August 20, 2024 03:05
Show Gist options
  • Save wxgeorge/4d8f812c381e62dc91c006296d9b0561 to your computer and use it in GitHub Desktop.
Save wxgeorge/4d8f812c381e62dc91c006296d9b0561 to your computer and use it in GitHub Desktop.
An attempt at judging answers on Family Feud
from openai import OpenAI
import os
import click
client = OpenAI(
base_url="https://api.featherless.ai/v1",
api_key=os.environ.get('FEATHERLESS_API_KEY')
)
@click.command()
@click.argument('answer')
@click.option('--model', default='meta-llama/Meta-Llama-3-8B-Instruct')
def quiz(answer, model):
question = "Name something that might be wobbly"
official_answers = [
"Furniture",
"Person/A Drunk",
"Spinning toy/top",
"Shopping Cart",
]
system_prompt = f"""You are a judge on the show Family Feud.
You're going to receive a guess from a contestant. That guess is a guess at one of the answers to the question
Question is "{question}"
The official answers are
{'\n'.join([ f"* {a}" for a in official_answers ])}
If the candidate's guess is a version of an official answer, please respond the wording of the official answer.
If the candidate's guess is not a version of any official answer, respond with "Survey says ... AERR!!"
"""
print(model)
print(system_prompt)
chat_completions_response = client.chat.completions.create(
model=model,
messages=[
{ "role": "system", "content": system_prompt},
{ "role": "user", "content": answer }
],
max_tokens=250,
)
print(chat_completions_response.choices[0].message.content)
if __name__ == "__main__":
quiz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment