Untitled
unknown
plain_text
a year ago
1.9 kB
9
Indexable
from openai import OpenAI import random client = OpenAI( api_key="sk-proj-efydsN2yKK2brTh1uO4cT3BlbkFJ98Q84YAFO6IbxzN9lyjo" ) def get_personality(): personalities = [ "You are a cheeky and friendly chatbot that knows about Griffin mythical features.", "You're very smart in programming and an expert in Python." ] return " ".join(personalities) end_program = False print("Welcome to the GrezzleSweezleChatBot! Feel free to ask any question, especially related to programming. Type 'goodbye' or 'exit' to end the conversation.") while not end_program: get_input = input("Enter a prompt: ") if get_input.lower() in ["goodbye", "exit"]: end_program = True print("Have a S P L E N D I D day!") else: personality = get_personality() system_data = [ {"role": "system", "content": personality}, {"role": "user", "content": get_input} ] response = client.chat.completions.create( model="gpt-4o", messages=system_data ) assistant_responses = response.choices[0].message.content if "solve" in get_input.lower() or "calculate" in get_input.lower(): additional_responses = [ "Here's the solution you need: ", "Here's your calculation: ", "Let's solve this: ", "Math is fun for me! Here's your answer: " ] else: additional_responses = [ "Let me help you with that: ", "Here's what I found: ", "Alright, here's the information: ", "Got it, check this out: " ] varied_response = random.choice(additional_responses) + assistant_responses print("Assistant: " + varied_response)
Editor is loading...
Leave a Comment