from openai import OpenAI


def search(paragraphs, words):

	openai = OpenAI(api_key = "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")

	prompt = f"""
		From the PARAGRAPHS, extract the complete SENTENCES containing the WORDS. The words are 
		not necessarily together but in the same sentence. Words can be repeated in different 
		paragraphs. Paragraphs and words are enclosed in square brackets and separated by commas 
		as an array of strings. The output format should be only the paragraphs, without titles 
		or subtitles.

		EXAMPLE 

		**WORDS**: ['there small issue', 'in excellent condition', 'was super fast']

		**PARAGRAPHS**: ['My son has the same phone, purchased it new, and I feel my refurbished phone 
		is as good as his was when it was brand new. There is a small issue, and the seller took care 
		of it immediately. My phone is an absolutely pristine condition, works wonderfully, and I 
		couldn’t be happier. My entire family plans to come back here for future phone purchases. 
		Couldn’t give a higher recommendation for the seller.', 'Was a bit anxious to buy a used phone
		from Amazon, but the renewal program is great. Phone was in excellent condition & came exactly 
		as described. Good price, and had confidence if there was an issue it would be dealt with.  
		There wasn't an issue. Phone arrived fast, worked and looked exactly as described, and is up 
		and running in no time. Recommend for anyone looking for renewed phone!.', 'I went into this 
		not really sure what to expect due to the mixed reviews. I received the phone exactly when it 
		was supposed to get here and I set it up which was super fast. The phone itself was definitely 
		in excellent condition, no cracks, no scratches. The battery condition was at 100%, I don't 
		have issues with the speakers like many of the reviews say and I'm overall satisfied with my 
		purchase. I recommend purchasing this and hopefully I can eliminate some doubt (because again
		I definitely had some) To the seller, thank you!!]

		**SENTENCES**: 
		There is a small issue, and the seller took care of it immediately.
		Phone was in excellent condition & came exactly as described.
		I received the phone exactly when it was supposed to get here and I set it up which was 
		super fast.
		The phone itself was definitely in excellent condition, no cracks, no scratches.

		**WORDS**: {words}

		**PARAGRAPHS**: {paragraphs}

		**SENTENCES**: 
	"""

	response = openai.chat.completions.create(
		model = "gpt-4-turbo",
		messages = [
			{
				"role": "user",
				"content": [
					{
						"type": "text", 
						"text": prompt
					}
				]
			}
		]
	)

	return response.choices[0].message.content