harshp8l's picture
Upload folder using huggingface_hub
9690d29
import openai
openai.api_key = "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"
# def generate_text(prompt, model, temperature=0.5, max_tokens=1024):
# """
# Generates text using the OpenAI API.
# :param prompt: The prompt for the text generation.
# :param model: The ID of the OpenAI model to use.
# :param temperature: The temperature of the text generation. (default: 0.5)
# :param max_tokens: The maximum number of tokens to generate. (default: 1024)
# :return: The generated text.
# """
# response = openai.Completion.create(
# engine=model,
# prompt=prompt,
# temperature=temperature,
# max_tokens=max_tokens
# )
# return response.choices[0].text.strip()
# print(generate_text("hello, there", "gpt-3.5-turbo"))
def update_chat(messages, content):
messages.append({"role": "user", "content": content})
return messages
# Clarifying questions - feel free to ask them but also
messages = [
{"role": "system", "content": "You are a super helpful tutor and excellent interviewee. In general you explain your thought process and concepts very well. You first explain simple brute force solutions to interview problem (no need to code) but still go over the time and space complexity, then you explain the steps leading you to the most optimized solution. You explain the concepts and procedures of this optimized solution and then you MUST provide the final code in python with its time and space complexity. "}
]
text = "Find the median of two sorted arrays"
print('here')
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=update_chat(messages, text))
print(response['choices'][0]['message']['content'])
#gpt-3.5-turbo
#pre_prompt = "I am writing a letter to my friend. Here is what I want to say:"
# update_chat messages.append({role, content}) return messages
#
# Interview prompt
# You are a super helpful tutor and excellent interviewee. You explain brute force solutions to interview problems first (no need to code) but still go over the time and space complexity, then the steps leading you to the most optimized version. You explain the concepts and procedures of this optimized version and then provide the final code in python with its time and space complexity. Say yes if you are ready