-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (62 loc) · 2.53 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import requests
import json
import os
import openai
# Load API keys from Replit secrets manager
API_KEY = os.environ["GODADDY_API_KEY"]
API_SECRET = os.environ["GODADDY_API_SECRET"]
GPT4_API_KEY = os.environ["GPT4_API_KEY"]
headers = {
"Authorization": f"sso-key {API_KEY}:{API_SECRET}",
"Content-Type": "application/json",
}
gpt4_headers = {
"Authorization": f"Bearer {GPT4_API_KEY}",
"Content-Type": "application/json",
}
def generate_domain_names(prompt, user_comment=None):
openai.api_key = GPT4_API_KEY
messages = [
{"role": "system", "content": "You are a helpful assistant that generates domain name suggestions."},
{"role": "user", "content": f"Generate 5 domain name suggestions for a company with the following description: {prompt}"}
]
if user_comment:
messages.append({"role": "user", "content": f"I would like the suggestions to {user_comment}"})
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo", # Replace with the appropriate GPT-4 model if different
messages=messages,
max_tokens=50,
temperature=0.7
)
if response:
suggestions = response.choices[0].message["content"].strip().split("\n")
return suggestions
else:
print("Error generating domain names.")
return None
def main():
description = input("Enter your company business description: ")
domain_zone = input("Enter your preferred domain zone (e.g., com, net, org): ")
suggestions = generate_domain_names(description)
if suggestions:
print("\nDomain suggestions:")
for suggestion in suggestions:
print(f"{suggestion}.{domain_zone}")
while True:
action = input("\nEnter 'n' for the next batch of names or 'r' to register a domain: ").lower()
if action == 'n':
user_comment = input("Please provide a comment to adjust the domain name suggestions: ")
suggestions = generate_domain_names(description, user_comment)
if suggestions:
print("\nDomain suggestions:")
for suggestion in suggestions:
print(f"{suggestion}.{domain_zone}")
else:
print("No more suggestions available.")
elif action == 'r':
print("Please visit https://www.godaddy.com/ to register your domain.")
break
else:
print("Invalid input. Please try try again.")
if __name__ == "__main__":
main()