from openai import OpenAI # Initialize OpenAI client def get_openai_client(api_key): """ Returns an OpenAI client instance with the provided API key. """ return OpenAI(api_key=api_key) def classify_row_chat(prompt, client, model="gpt-3.5-turbo"): """ Sends a classification prompt to the OpenAI Chat API and returns the predicted label. Args: prompt (str): The user prompt to classify data. client (OpenAI): The OpenAI client instance. model (str): The model to use for chat completion. Returns: str: The predicted label. """ response = client.chat.completions.create( model=model, messages=[{"role": "user", "content": prompt}] ) return response.choices[0].message.content.strip()