You say you want to have an argument?
You've been told once!
import concurrent.futures
import openai
import string
import time
# Set OpenAI API key
openai.api_key = "your_api_key_here"
# Function to process OpenAI request
def process_request(name):
? ? try:
? ? ? ? response = openai.Completion.create(
? ? ? ? ? ? model="text-davinci-003",
? ? ? ? ? ? prompt="I'd like you to assume the Argument clinic side of a conversation about '" + s + "' Can you help me out? Please respond using the script from the Argument Clinic skit by Monty Python. Don't print the Me: side of the conversation.",
? ? ? ? ? ? temperature=0,
? ? ? ? ? ? max_tokens=2000,
? ? ? ? ? ? top_p=1,
? ? ? ? ? ? frequency_penalty=0,
? ? ? ? ? ? timeout=15,
? ? ? ? ? ? presence_penalty=0
? ? ? ? )
? ? ? ? return response.choices[0].text
? ? except:
? ? ? ? return None
# Use a thread pool executor to process requests
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
? ? while True:
? ? ? ? try:
? ? ? ? ? ? # Get user input and clean it
? ? ? ? ? ? s = input("Please enter your argument: ")
s = s.translate(str.maketrans("", "", string.punctuation + "'"))
? ? ? # Start timer and submit request
? ? ? ? ? ? start_time = time.time()
? ? ? ? ? ? future = executor.submit(process_request, s)
? ? ? ? ? ? response = future.result(timeout=15)
? ? ? ? ? ? # End timer and check response time
? ? ? ? ? ? end_time = time.time()
? ? ? ? ? ? if end_time - start_time > 15:
? ? ? ? ? ? ? ? print("Sorry, the response took too long. Please try again.")
? ? ? ? ? ? ? ? continue
? ? ? ? ? ? # Print response
? ? ? ? ? ? print(response)
? ? ? ? ? ? # Exit loop if user input is "quit"
? ? ? ? ? ? if s == "quit":
? ? ? ? ? ? ? ? break
? ? ? ? except KeyboardInterrupt:
? ? ? ? ? ? print("\nKeyboardInterrupt received. Exiting.")
? ? ? ? ? ? break
? ? ? ? except Exception as e:
? ? ? ? ? ? print("Time is up! Sorry, I can't argue unless you pay.", str(e))
? ? ? ? ? ? continue
Argument Clinic: No, no, no, no. You're not listening.
Argument Clinic: An argument is a connected series of statements intended to establish a proposition.
Argument Clinic: Contradiction is just the automatic gainsaying of any statement the other person makes.
Please enter your argument: fuck you and the coconut you rode in on!
No, no, no. You don't need to use bad language. Now, come along, come along.
Please enter your argument: you are a patsy
"No, no, no. You are not a patsy. You are not a patsy at all. Now, an argument is a connected series of statements intended to establish a proposition. Now, what we desire is an argument. An argument is not the same thing as an altercation. An altercation is a quarrel, usually verbal. Now, if you wanted an altercation, I'd be more than happy to oblige you. But I'm afraid I'm not equipped for an argument."
Please enter your argument: lets have an altercation then
No, no, no. You don't argue, not at the Argument Clinic. Here, we *teach* arguing.
Please enter your argument: teach me clinic, teach me
"No, no, no. You mustn't do that. That is not at all what I had in mind. You must learn to argue properly."
Please enter your argument: help me learn to argue properly
领英推荐
"Ah, yes. Now, you come to the right place. Arguing properly is an art form and must be learned with great effort. Now, first of all, what is your name?"
Please enter your argument: my name is richard
"No, no, no. 'My name is Richard' is not an argument. An argument is a connected series of statements intended to establish a proposition."
Please enter your argument: help me learn to argue properly
"Ah, yes. Now, you come to the right place. Arguing properly is an art form and must be learned with great effort. Now, first of all, what is your name?"
Please enter your argument: my name is none of your business
"Ah, yes. This is the Argument Clinic.
Argument Clinic receptionist: 'I'm sorry, this is the Argument Clinic.
Customer: 'My name is none of your business.'
Argument Clinic receptionist: 'No, no, no. This is not an argument. An argument is a connected series of statements intended to establish a proposition.'
Please enter your argument: it isn't funny to make a joke about arguments
Well, I'm sorry, but this is an argument clinic.
Ah, yes. I'm afraid we're closed.
Please enter your argument: what time is it
Time is up! Sorry, I can't argue unless you pay.?