forked from AmrMKayid/co-movies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
74 lines (68 loc) · 7.47 KB
/
utils.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
import os
import random
import numpy as np
import streamlit as st
import torch
def seed_everything(seed: int):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = True
def streamlit_header_and_footer_setup():
st.markdown(
'<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">',
unsafe_allow_html=True)
st.markdown("""
<style>
.navbar-nav{
display: flex;
flex-direction: row;
}
@media only screen and (max-width: 525px) {
nav{
flex-direction: column !important;
gap: 15px !important;
}
}
</style>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark" style="background-color: #000; justify-content:space-between;">
<a href="https://cohere.ai" target="_blank"><svg width="144" height="80" viewBox="0 -10 144 80" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M40.5262 23.9952C44.0913 23.9952 47.2113 22.2126 48.4448 18.6137C48.6842 17.893 48.3408 17.4141 47.6563 17.4141H46.3188C45.7021 17.4141 45.2909 17.6874 45.0152 18.2703C43.9534 20.3624 42.478 21.1146 40.6278 21.1146C37.336 21.1146 35.3141 18.8169 35.3141 14.9785C35.3141 11.1402 37.4062 8.84249 40.5577 8.84249C42.478 8.84249 44.055 9.66482 45.049 11.6191C45.3586 12.202 45.7335 12.4753 46.3527 12.4753H47.6902C48.3746 12.4753 48.7181 12.0302 48.4786 11.3772C47.0396 7.46871 43.8155 5.96191 40.5262 5.96191C35.5559 5.96191 31.853 9.63096 31.853 14.9785C31.853 20.3261 35.3842 23.9952 40.5262 23.9952ZM130.235 13.4016C130.68 10.4872 132.669 8.67076 135.377 8.67076C138.086 8.67076 140.108 10.521 140.348 13.4016H130.235ZM135.515 23.9952C138.669 23.9952 141.823 22.5222 143.366 19.1966C143.743 18.4081 143.4 17.8591 142.715 17.8591H141.448C140.831 17.8591 140.454 18.1324 140.144 18.6814C139.117 20.4978 137.334 21.2524 135.518 21.2524C132.398 21.2524 130.376 19.1265 130.136 15.6654H142.718C143.402 15.6654 143.85 15.2881 143.85 14.5674C143.712 9.18593 140.217 5.96432 135.382 5.96432C130.547 5.96432 126.709 9.46165 126.709 14.981C126.709 20.5002 130.446 23.9976 135.52 23.9976L135.515 23.9952ZM115.564 15.426H116.696C117.38 15.426 117.758 15.0487 117.862 14.3279C118.515 9.69626 121.226 9.08193 124.109 9.21979C124.726 9.24882 125.231 8.77477 125.231 8.1556V7.09382C125.231 6.40935 124.888 5.99577 124.203 5.96191C121.652 5.86516 119.376 6.7407 118.06 9.21979C117.987 9.35523 117.784 9.31896 117.767 9.16658L117.555 7.29699C117.487 6.61252 117.109 6.26907 116.423 6.26907H111.247C110.642 6.26907 110.149 6.76005 110.149 7.36713V7.95001C110.149 8.55467 110.64 9.04807 111.247 9.04807H113.373C113.977 9.04807 114.471 9.53905 114.471 10.1461V14.3279C114.471 14.9326 114.962 15.426 115.569 15.426H115.564ZM110.937 23.6541H121.666C122.351 23.6541 122.764 23.243 122.764 22.5561V21.9732C122.764 21.2887 122.353 20.8751 121.666 20.8751H118.923C118.239 20.8751 117.825 20.464 117.825 19.7771V17.8906C117.825 17.2061 117.414 16.7925 116.727 16.7925H115.562C114.877 16.7925 114.464 17.2037 114.464 17.8906V19.7771C114.464 20.4616 114.052 20.8751 113.365 20.8751H110.932C110.248 20.8751 109.834 21.2863 109.834 21.9732V22.5561C109.834 23.2406 110.245 23.6541 110.932 23.6541H110.937ZM94.3793 13.404C94.8243 10.4896 96.8124 8.67318 99.5213 8.67318C102.23 8.67318 104.252 10.5234 104.492 13.404H94.3793ZM99.6591 23.9976C102.813 23.9976 105.967 22.5246 107.51 19.199C107.887 18.4106 107.544 17.8615 106.859 17.8615H105.592C104.975 17.8615 104.598 18.1348 104.288 18.6839C103.26 20.5003 101.478 21.2549 99.6616 21.2549C96.5415 21.2549 94.5196 19.1289 94.2801 15.6678H106.862C107.546 15.6678 107.994 15.2905 107.994 14.5698C107.856 9.18835 104.361 5.96674 99.5261 5.96674C94.6913 5.96674 90.8529 9.46407 90.8529 14.9834C90.8529 20.5027 94.5897 24 99.664 24L99.6591 23.9976ZM59.9985 23.9976C65.1405 23.9976 68.8096 20.1931 68.8096 14.981C68.8096 9.76882 65.1405 5.96432 59.9985 5.96432C54.8566 5.96432 51.1875 9.83896 51.1875 14.981C51.1875 16.1806 51.3931 17.5181 52.0098 18.991C52.3194 19.7118 52.9023 19.8134 53.5191 19.3683L54.5131 18.6476C55.0283 18.2703 55.1637 17.8253 54.992 17.1746C54.7187 16.3185 54.6486 15.5638 54.6486 14.9132C54.6486 11.3143 56.8084 8.8449 59.9961 8.8449C63.1839 8.8449 65.3437 11.278 65.3437 14.981C65.3437 18.6839 63.2177 21.117 60.0639 21.117C58.9658 21.117 57.9379 20.9114 56.7044 19.9851C56.1892 19.5739 55.7103 19.5062 55.1613 19.9174L54.4067 20.4664C53.7899 20.9114 53.7222 21.5282 54.3027 22.0095C56.0852 23.4486 58.141 23.9976 59.9937 23.9976H59.9985ZM73.1607 23.6541H74.2926C74.8973 23.6541 75.3907 23.1632 75.3907 22.5561V14.3642C75.3907 10.9032 77.2409 8.8449 80.1215 8.8449C82.7263 8.8449 84.2356 10.5597 84.2356 13.7136V22.5585C84.2356 23.1632 84.7266 23.6566 85.3336 23.6566H86.4994C87.1041 23.6566 87.5975 23.1656 87.5975 22.5585V13.1646C87.5975 8.53774 85.232 5.96674 81.222 5.96674C78.4913 5.96674 76.8781 7.08415 75.6736 8.63932C75.5817 8.75784 75.3955 8.69253 75.3955 8.545V1.09806C75.3882 0.490981 74.8973 0 74.2926 0H73.1607C72.556 0 72.0626 0.490981 72.0626 1.09806V22.5561C72.0626 23.1607 72.5536 23.6541 73.1607 23.6541Z" fill="#355146"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.77562 14.2897C8.4216 14.2897 9.70659 14.2543 11.4828 13.523C13.5526 12.6708 17.6705 11.1239 20.6411 9.53491C22.7187 8.42355 23.6293 6.95369 23.6293 4.97427C23.6294 2.22707 21.4024 0 18.6551 0H7.14487C3.19886 0 0 3.19886 0 7.14487C0 11.0909 2.99508 14.2897 7.77562 14.2897Z" fill="#355146"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.72217 19.2123C9.72217 17.2781 10.8866 15.5341 12.6731 14.7926L16.298 13.2882C19.9645 11.7665 24.0001 14.461 24.0001 18.4308C24.0001 21.5064 21.5064 23.9995 18.4308 23.9986L14.5062 23.9976C11.8638 23.9969 9.72217 21.8547 9.72217 19.2123Z" fill="#D18EE2"/>
<path d="M4.11881 15.229H4.11874C1.84402 15.229 0 17.073 0 19.3477V19.8812C0 22.1559 1.84402 24 4.11874 24H4.11881C6.39353 24 8.23755 22.1559 8.23755 19.8812V19.3477C8.23755 17.073 6.39353 15.229 4.11881 15.229Z" fill="#FF7759"/>
</g>
</svg></a>
<div style="justify-content: flex-end;">
<ul class="navbar-nav">
<li>
<a class="nav-link text-white" href="https://dashboard.cohere.ai/welcome/register" style="background: #917EF3; border-radius: 100px; padding-left: 15px; padding-right: 15px;">Sign up for free</a>
</li>
<li>
<a class="nav-link text-white" href="https://docs.cohere.ai" target="_blank">Read our docs →</a>
</li>
</ul>
</div>
</nav>
""",
unsafe_allow_html=True)
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
header {visibility: hidden;}
footer {visibility: hidden;}
footer:after {
content:'Cohere Inc';
visibility: visible;
display: block;
position: relative;
#background-color: red;
padding: 5px;
top: 2px;
}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)