Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,17 +36,102 @@ def print_output(input):
|
|
| 36 |
# outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
| 37 |
# tokenizer.batch_decode(outputs)
|
| 38 |
|
| 39 |
-
outputs = model.generate(**inputs, max_new_tokens =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return tokenizer.batch_decode(outputs)
|
| 41 |
|
| 42 |
|
| 43 |
-
# Streamlit app UI
|
| 44 |
-
st.title("Echo Input Example")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
if st.button("
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
| 36 |
# outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
| 37 |
# tokenizer.batch_decode(outputs)
|
| 38 |
|
| 39 |
+
outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True, temperature=0.5)
|
| 40 |
+
|
| 41 |
+
n1 = tokenizer.batch_decode(outputs)[0].index('### Response:')
|
| 42 |
+
output_ = tokenizer.batch_decode(outputs)[0][n1+13:].replace('.com','')
|
| 43 |
+
n2 = output_.index('\n\n')
|
| 44 |
+
|
| 45 |
+
dom_names = []
|
| 46 |
+
|
| 47 |
+
for name in output_[:n2].split('\n'):
|
| 48 |
+
if name != '':
|
| 49 |
+
dom_names.append(name.split('.')[1])
|
| 50 |
+
|
| 51 |
+
s = '\n'.join(dom_names)
|
| 52 |
+
|
| 53 |
return tokenizer.batch_decode(outputs)
|
| 54 |
|
| 55 |
|
| 56 |
+
# # Streamlit app UI
|
| 57 |
+
# st.title("Echo Input Example")
|
| 58 |
+
|
| 59 |
+
# # Text box for user input
|
| 60 |
+
# user_input = st.text_input("Type something here:")
|
| 61 |
+
|
| 62 |
+
# # Button to submit input
|
| 63 |
+
# if st.button("Submit"):
|
| 64 |
+
# # Reprint the user input
|
| 65 |
+
# st.write(f"You typed: {print_output(user_input)}")
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def main():
|
| 69 |
+
|
| 70 |
+
css_dark_mode = """
|
| 71 |
+
<style>
|
| 72 |
+
body {
|
| 73 |
+
background-color: #121212;
|
| 74 |
+
color: #f8f9fa;
|
| 75 |
+
font-family: Arial, sans-serif;
|
| 76 |
+
}
|
| 77 |
+
.header {
|
| 78 |
+
background: linear-gradient(90deg, #005c97, #363795);
|
| 79 |
+
padding: 15px;
|
| 80 |
+
margin-bottom: 15px;
|
| 81 |
+
border-radius: 10px;
|
| 82 |
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
| 83 |
+
text-align: center;
|
| 84 |
+
}
|
| 85 |
+
.header h1 {
|
| 86 |
+
color: #ffffff;
|
| 87 |
+
font-size: 36px;
|
| 88 |
+
}
|
| 89 |
+
.header h2 {
|
| 90 |
+
color: #b0b0b0;
|
| 91 |
+
font-size: 22px;
|
| 92 |
+
font-family: Georgia, serif;
|
| 93 |
+
}
|
| 94 |
+
.stButton > button {
|
| 95 |
+
background-color: #20c997;
|
| 96 |
+
color: #ffffff;
|
| 97 |
+
border: none;
|
| 98 |
+
border-radius: 8px;
|
| 99 |
+
padding: 10px 20px;
|
| 100 |
+
font-size: 16px;
|
| 101 |
+
cursor: pointer;
|
| 102 |
+
transition: background-color 0.3s;
|
| 103 |
+
}
|
| 104 |
+
.stButton > button:hover {
|
| 105 |
+
background-color: #17a589;
|
| 106 |
+
}
|
| 107 |
+
.success-box {
|
| 108 |
+
background-color: #A1D6CB;
|
| 109 |
+
padding: 10px;
|
| 110 |
+
margin: 10px 0;
|
| 111 |
+
border-radius: 8px;
|
| 112 |
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
| 113 |
+
}
|
| 114 |
+
</style>
|
| 115 |
+
"""
|
| 116 |
+
# Inject the custom CSS
|
| 117 |
+
st.markdown(css_dark_mode, unsafe_allow_html=True)
|
| 118 |
+
|
| 119 |
+
# Header Section
|
| 120 |
+
html_temp = """
|
| 121 |
+
<div class="header">
|
| 122 |
+
<h1>Dominious</h1>
|
| 123 |
+
<h2>AI Based Domain Name Suggestion System</h2>
|
| 124 |
+
</div>
|
| 125 |
+
"""
|
| 126 |
+
st.markdown(html_temp, unsafe_allow_html=True)
|
| 127 |
+
# st.title("Domain Name Suggestion System")
|
| 128 |
|
| 129 |
+
# Get user input
|
| 130 |
+
context = st.text_input("Describe your business here...")
|
| 131 |
|
| 132 |
+
# Generate the response
|
| 133 |
+
if st.button("Generate"):
|
| 134 |
+
with st.spinner("Generating Domain Names..."):
|
| 135 |
+
result = print_output(user_input)
|
| 136 |
+
if __name__ == "__main__":
|
| 137 |
+
main()
|