1 gpt.py:
2 import openai
3 {
4 def process_gpt(request):
5 message = request.form['message']
6 openai.api_key = ""
7 response = openai.Completion.create(
8 engine="text-davinci-003",
9 prompt=message,
10 max_tokens=1024,
11 temperature=0.5,
12 )
13 {
14 # Format the response text
15 response_text = response.choices[0].text.strip() # Remove leading and trailing whitespace
16 response_text = response_text.replace("\n", "
") # Replace newlines with line breaks
17 # Return the formatted response text
18 return response_text
19 }