Skip to content

Instantly share code, notes, and snippets.

@athmanar
Last active January 9, 2024 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athmanar/241105836487d0b393f44f9bf6b9e0ee to your computer and use it in GitHub Desktop.
Save athmanar/241105836487d0b393f44f9bf6b9e0ee to your computer and use it in GitHub Desktop.
OPENAI
import openai
from openai import OpenAI
import os
import pandas as pd
import time
import os
def get_completion(prompt):
client = OpenAI(api_key='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', )
chat_completion = client.chat.completions.create( messages=[ { "role": "user", "content": prompt, } ], model="gpt-4-1106-preview", )
return response.choices[0].message.content
prompt = "give me an example code using numpy to reverse a list. give only the code and no extra text before and after code.wrap any code result in <code></code> block"
response = get_completion(prompt)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment