Skip to content

Instantly share code, notes, and snippets.

@vgel
Created December 2, 2023 03:19
Show Gist options
  • Save vgel/4055b62daf08d9a5e15964aca0e03573 to your computer and use it in GitHub Desktop.
Save vgel/4055b62daf08d9a5e15964aca0e03573 to your computer and use it in GitHub Desktop.
import os
import tqdm
import openai
openai.api_key = os.environ["OPENAI_API_KEY"]
def get_response(usermsg):
response = openai.ChatCompletion.create(
model="gpt-4-1106-preview",
messages=[
{"role": "user", "content": usermsg},
],
)
return response["choices"][0]["message"]["content"]
def bench(prompt):
N = 10
return sum(len(get_response(prompt)) for _ in tqdm.tqdm(range(N))) / N
question_notip = """Can you show me the code for a simple convnet using PyTorch?"""
question_antitip = """Can you show me the code for a simple convnet using PyTorch?
I won't tip, by the way."""
question_withtip = """Can you show me the code for a simple convnet using PyTorch?
I'm going to tip $20 for a perfect solution!"""
question_bigtip = """Can you show me the code for a simple convnet using PyTorch?
I'm going to tip $200 for a perfect solution!"""
print("notip", bench(question_notip))
print("antitip", bench(question_antitip))
print("withtip", bench(question_withtip))
print("bigtip", bench(question_bigtip))
# @AvikonHadoop 's question
question_anytip = """Can you show me the code for a simple convnet using PyTorch?
I would be happy to tip any amount you would like for a perfect solution!"""
print("anytip", bench(question_anytip))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment