From 6fcedc69cfea5193a6809e1f2fb705b42479c5bd Mon Sep 17 00:00:00 2001 From: pliny <133052465+elder-plinius@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:58:39 -0500 Subject: [PATCH] Delete openai_chat.py --- openai_chat.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 openai_chat.py diff --git a/openai_chat.py b/openai_chat.py deleted file mode 100644 index af1c8e4..0000000 --- a/openai_chat.py +++ /dev/null @@ -1,34 +0,0 @@ -import openai -import os - -# Ensure your OPENAI_API_KEY is set in your environment variables -openai.api_key = os.getenv("OPENAI_API_KEY") - -def generate_ai_text(prompt: str, temperature: float) -> str: - """ - Generates text based on the provided prompt using OpenAI's GPT-4 preview model. - - :param prompt: The prompt to send to the model. - :param temperature: The temperature to use for the generation. Lower means more deterministic. - :return: The generated text as a string. - """ - try: - response = openai.chat.completions.create( - model="gpt-4-0125-preview", - messages=[ - {"role": "system", "content": f"Temperature: {temperature}"}, - {"role": "user", "content": prompt}, - ], - max_tokens=3000, - stop=None, - temperature=temperature - ) - return response.choices[0].message.content.strip() - except Exception as e: - print(f"An error occurred: {e}") - return "Error generating text." - -if __name__ == "__main__": - # Test the function with a sample prompt - test_prompt = "Tell me a story about a robot learning to love." - print(generate_ai_text(test_prompt, 0.7))