import os from openai import OpenAI class ChatBot: def __init__(self): self.client = OpenAI(api_key=os.environ["OPENAI_API_KEY"]) self.history = [{"role": "system", "content": "You are a helpful assistant."}] def generate_response(self, prompt: str) -> str: self.history.append({"role": "user", "content": prompt}) completion = self.client.chat.completions.create( model="gpt-3.5-turbo", # NOTE: feel free to change it to gpt-4, or gpt-4o messages=self.history ) response = completion.choices[0].message.content self.history.append({"role": "assistant", "content": response}) return response def get_history(self) -> list: return self.history