import openai openai.api_key = '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' model = "gpt-3.5-turbo-1106" def get_keywords(question): prompt = f"Extract 10 keywords from the following question, including synonyms. Use only lowercase letters:\n\n{question}" response = openai.completions.create(model=model, prompt=prompt, max_tokens=60, temperature=0) keywords = response.choices[0].text.strip().split(', ') return keywords def answer_question(chunk, question): prompt = f"Based on the following information, what is the answer to this question?\n\nText:\n{chunk}\n\nQuestion:\n{question}" response = openai.completions.create(model=model, prompt=prompt, max_tokens=150, temperature=0) answer = response.choices[0].text.strip() return answer # Example usage question = "What are the key aspects of climate change?" keywords = get_keywords(question) print("Keywords:", keywords) chunk = "Climate change is a long-term change in the average weather patterns..." answer = answer_question(chunk, question) print("Answer:", answer)