import openai def analyze_chunk(chunk, openai_key): openai.api_key = openai_key try: response = openai.ChatCompletion.create( model="gpt-4-turbo", messages=[ {"role": "system", "content": "Summarize and analyze the following chunk."}, {"role": "user", "content": chunk} ] ) return response['choices'][0]['message']['content'] except Exception as e: return f"Error: {str(e)}"