niro commited on
Commit
d4aa628
·
1 Parent(s): a427483
Files changed (1) hide show
  1. main.py +11 -14
main.py CHANGED
@@ -12,24 +12,21 @@ from supabase import Client, create_client
12
  from explorer import view_document
13
  from stats import get_usage_today
14
 
15
- # supabase_url = st.secrets.supabase_url
16
  supabase_url = 'https://ktexmliefragugupzmqw.supabase.co'
 
17
 
18
- # supabase_key = st.secrets.supabase_service_key
19
  supabase_key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt0ZXhtbGllZnJhZ3VndXB6bXF3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODUyNjg1MjcsImV4cCI6MjAwMDg0NDUyN30.7DBDCcqelS0GNojPqv0zuvCT5vs5x2Codxyr5cDPZvU'
 
20
 
21
- # openai_api_key = st.secrets.openai_api_key
22
  openai_api_key_head = 'sk-9utMl6JfUfgm4lRIXmK'
23
  openai_api_key_tail = 'bT3BlbkFJBvNXhwDz9WJrzmi5G6FP'
24
  openai_api_key = openai_api_key_head+openai_api_key_tail
25
- # openai_api_key = st.secrets.openai_api_key_head+st.secrets.openai_api_key_tail
26
 
27
- # anthropic_api_key = st.secrets.anthropic_api_key
28
  st.secrets.anthropic_api_key = ""
29
  st.secrets.usage_limit = 1000
30
  anthropic_api_key = ''
31
  supabase: Client = create_client(supabase_url, supabase_key)
32
- # self_hosted = st.secrets.self_hosted
33
  st.secrets.self_hosted = "true"
34
  self_hosted = "true"
35
 
@@ -58,16 +55,16 @@ st.markdown("---\n\n")
58
  st.session_state["overused"] = False
59
  if self_hosted == "false":
60
  usage = get_usage_today(supabase)
61
- # if usage > st.secrets.usage_limit:
62
- if usage > 1000:
63
  st.markdown(
64
- # f"<span style='color:red'>You have used {usage} tokens today, which is more than your daily limit of {st.secrets.usage_limit} tokens. Please come back later or consider self-hosting.</span>", unsafe_allow_html=True)
65
- f"<span style='color:red'>You have used {usage} tokens today, which is more than your daily limit of {1000} tokens. Please come back later or consider self-hosting.</span>", unsafe_allow_html = True)
66
 
67
  st.session_state["overused"] = True
68
  else:
69
- # st.markdown(f"<span style='color:blue'>Usage today: {usage} tokens out of {st.secrets.usage_limit}</span>", unsafe_allow_html=True)
70
- st.markdown(f"<span style='color:blue'>Usage today: {usage} tokens out of {1000}</span>", unsafe_allow_html=True)
71
 
72
  st.write("---")
73
 
@@ -127,8 +124,8 @@ elif user_choice == 'Chat with your Brain':
127
  st.session_state['model'] = "gpt-3.5-turbo"
128
  st.session_state['temperature'] = st.sidebar.slider(
129
  "Select Temperature", 0.0, 1.0, st.session_state['temperature'], 0.1)
130
- # if st.secrets.self_hosted != "false":
131
- if "true" != "false":
132
  st.session_state['max_tokens'] = st.sidebar.slider(
133
  "Select Max Tokens", 256, 2048, st.session_state['max_tokens'], 2048)
134
  else:
 
12
  from explorer import view_document
13
  from stats import get_usage_today
14
 
 
15
  supabase_url = 'https://ktexmliefragugupzmqw.supabase.co'
16
+ st.secrets.supabase_url = supabase_url
17
 
 
18
  supabase_key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt0ZXhtbGllZnJhZ3VndXB6bXF3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODUyNjg1MjcsImV4cCI6MjAwMDg0NDUyN30.7DBDCcqelS0GNojPqv0zuvCT5vs5x2Codxyr5cDPZvU'
19
+ st.secrets.supabase_key = supabase_key
20
 
 
21
  openai_api_key_head = 'sk-9utMl6JfUfgm4lRIXmK'
22
  openai_api_key_tail = 'bT3BlbkFJBvNXhwDz9WJrzmi5G6FP'
23
  openai_api_key = openai_api_key_head+openai_api_key_tail
24
+ st.secrets.opeanai_api_key = openai_api_key
25
 
 
26
  st.secrets.anthropic_api_key = ""
27
  st.secrets.usage_limit = 1000
28
  anthropic_api_key = ''
29
  supabase: Client = create_client(supabase_url, supabase_key)
 
30
  st.secrets.self_hosted = "true"
31
  self_hosted = "true"
32
 
 
55
  st.session_state["overused"] = False
56
  if self_hosted == "false":
57
  usage = get_usage_today(supabase)
58
+ if usage > st.secrets.usage_limit:
59
+ # if usage > 1000:
60
  st.markdown(
61
+ f"<span style='color:red'>You have used {usage} tokens today, which is more than your daily limit of {st.secrets.usage_limit} tokens. Please come back later or consider self-hosting.</span>", unsafe_allow_html=True)
62
+ # f"<span style='color:red'>You have used {usage} tokens today, which is more than your daily limit of {1000} tokens. Please come back later or consider self-hosting.</span>", unsafe_allow_html = True)
63
 
64
  st.session_state["overused"] = True
65
  else:
66
+ st.markdown(f"<span style='color:blue'>Usage today: {usage} tokens out of {st.secrets.usage_limit}</span>", unsafe_allow_html=True)
67
+ # st.markdown(f"<span style='color:blue'>Usage today: {usage} tokens out of {1000}</span>", unsafe_allow_html=True)
68
 
69
  st.write("---")
70
 
 
124
  st.session_state['model'] = "gpt-3.5-turbo"
125
  st.session_state['temperature'] = st.sidebar.slider(
126
  "Select Temperature", 0.0, 1.0, st.session_state['temperature'], 0.1)
127
+ if st.secrets.self_hosted != "false":
128
+ # if "true" != "false":
129
  st.session_state['max_tokens'] = st.sidebar.slider(
130
  "Select Max Tokens", 256, 2048, st.session_state['max_tokens'], 2048)
131
  else: