File size: 6,051 Bytes
c0085cc
 
 
 
 
b7deda8
c0085cc
 
c9bd7b7
c0085cc
 
 
 
 
 
c9bd7b7
 
c0085cc
 
 
ae7e299
 
 
 
 
 
 
 
 
 
 
c0085cc
 
 
 
 
 
 
 
365a4d0
c0085cc
1a5ecc3
c0085cc
 
 
 
 
 
0510b89
c0085cc
 
 
 
7d7050b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7e2e90
 
365a4d0
 
 
5199e9b
365a4d0
 
5199e9b
365a4d0
d0f192f
 
 
 
 
 
 
 
365a4d0
d0f192f
365a4d0
d0f192f
 
 
 
 
365a4d0
 
 
 
 
 
 
 
 
 
 
 
 
 
e6c4e44
365a4d0
 
 
e6c4e44
365a4d0
e6c4e44
365a4d0
 
 
e6c4e44
365a4d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import streamlit as st
from unsloth import FastLanguageModel
import torch
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True



model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "Mudditha/test-phi-3", # YOUR MODEL YOU USED FOR TRAINING
    max_seq_length = max_seq_length,
    dtype = dtype,
    load_in_4bit = load_in_4bit,
)


FastLanguageModel.for_inference(model)


inf_prompt_1 = """You are a creative domain name generator with a sound knowledge about how the creative name are formed according to requirement and language use.
You need to create and output 10 different unique names, which are not in your knowledge base, based on your knowledge on considered facts when generating domain names.
Don't use same keyword for every name. Instead use different attractive similar word combinations. make the names short as possible
output should be in following format. 
don't include '.com' in outputs and give different names.

"" 1. ......
2. .......
.......
.......
10. ....... ""

### Input:
{}

### Response:
{}"""



def print_output(input):

    inputs = tokenizer(
    [
        inf_prompt_1.format(
            input, # instruction
            "", # output - leave this blank for generation!
        ),
    ], return_tensors = "pt").to('cuda')
    
    # outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
    # tokenizer.batch_decode(outputs)
    
    # outputs = model.generate(**inputs, max_new_tokens = 100, use_cache = True)
    # return tokenizer.batch_decode(outputs)


    outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True, temperature=0.5)

    n1 = tokenizer.batch_decode(outputs)[0].index('### Response:')
    output_ = tokenizer.batch_decode(outputs)[0][n1+13:].replace('.com','')
    n2 = output_.index('\n\n')

    dom_names = []
    
    for name in output_[:n2].split('\n'):
      if name != '':
          dom_names.append(name.split('.')[1])
    
    # s = '\n'.join(dom_names)
    return dom_names


# Streamlit app UI
st.title("AI Based Domain Names Suggestion")

# Text box for user input
user_input = st.text_input("Type your idea here:")

# # Button to submit input
# if st.button("Submit"):
#     # Reprint the user input
#     for item in print_output(user_input):
#         st.write(item)
col1, col2 = st.columns(2)

# Loop through the output list and distribute items between the two columns
if st.button("Submit"):
    output_list = print_output(user_input)
    
    for i, item in enumerate(output_list):
        if i % 2 == 0:
            col1.write(item)  # Even-indexed items in column 1
        else:
            col2.write(item)  # Odd-indexed items in column 2

# def print_output(input):
#     inputs = tokenizer(
#     [
#         inf_prompt_1.format(
#             input, # instruction
#             "", # output - leave this blank for generation!
#         ),
#     ], return_tensors = "pt").to("cuda")
    
#     # outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
#     # tokenizer.batch_decode(outputs)
    
#     outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True, temperature=0.5)

#     n1 = tokenizer.batch_decode(outputs)[0].index('### Response:')
#     output_ = tokenizer.batch_decode(outputs)[0][n1+13:].replace('.com','')
#     n2 = output_.index('\n\n')

#     dom_names = []
    
#     for name in output_[:n2].split('\n'):
#       if name != '':
#           dom_names.append(name.split('.')[1])
    
#     s = '\n'.join(dom_names)

#     return tokenizer.batch_decode(s)


# # # Streamlit app UI
# # st.title("Echo Input Example")

# # # Text box for user input
# # user_input = st.text_input("Type something here:")

# # # Button to submit input
# # if st.button("Submit"):
# #     # Reprint the user input
# #     st.write(f"You typed: {print_output(user_input)}")


# def main():

#     css_dark_mode = """
#     <style>
#         body {
#             background-color: #121212;
#             color: #f8f9fa;
#             font-family: Arial, sans-serif;
#         }
#         .header {
#             background: linear-gradient(90deg, #005c97, #363795);
#             padding: 15px;
#             margin-bottom: 15px;
#             border-radius: 10px;
#             box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
#             text-align: center;
#         }
#         .header h1 {
#             color: #ffffff;
#             font-size: 36px;
#         }
#         .header h2 {
#             color: #b0b0b0;
#             font-size: 22px;
#             font-family: Georgia, serif;
#         }
#         .stButton > button {
#             background-color: #20c997;
#             color: #ffffff;
#             border: none;
#             border-radius: 8px;
#             padding: 10px 20px;
#             font-size: 16px;
#             cursor: pointer;
#             transition: background-color 0.3s;
#         }
#         .stButton > button:hover {
#             background-color: #17a589;
#         }
#         .success-box {
#             background-color: #A1D6CB;
#             padding: 10px;
#             margin: 10px 0;
#             border-radius: 8px;
#             box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
#         }
#     </style>
#     """
#     # Inject the custom CSS
#     st.markdown(css_dark_mode, unsafe_allow_html=True)

#     # Header Section
#     html_temp = """
#     <div class="header">
#         <h1>Dominious</h1>
#         <h2>AI Based Domain Name Suggestion System</h2>
#     </div>
#     """
#     st.markdown(html_temp, unsafe_allow_html=True)
#     # st.title("Domain Name Suggestion System")

#     # Get user input
#     user_input = st.text_input("Describe your business here...")

#     # Generate the response
#     if st.button("Generate"):
#         with st.spinner("Generating Domain Names..."):
#             result = print_output(user_input)
# if __name__ == "__main__":
#     main()