import openai model = "gpt-3.5-turbo" def get_keywords(question): prompt = f"Extract 10 keywords from the following question, including synonyms. Use only lowercase letters:\n\n{question}" response = openai.Completion.create(model=model, prompt=prompt, max_tokens=60) 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.Completion.create(model=model, prompt=prompt, max_tokens=150) 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)