Skip to content

Instantly share code, notes, and snippets.

@bmidgley
Last active December 4, 2023 06:05
Show Gist options
  • Save bmidgley/58d2dc3741a9e875ce86932d7c9fed58 to your computer and use it in GitHub Desktop.
Save bmidgley/58d2dc3741a9e875ce86932d7c9fed58 to your computer and use it in GitHub Desktop.
from openai import OpenAI
import os
client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
def get_response(passage):
prompt = f'Define each of the words in the following passage in English, Spanish and Chinese:\n\n{passage}'
print(prompt)
response = client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": prompt}])
return response
response = get_response('What is the diameter of the unit circle?')
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment