Spaces:
Sleeping
Sleeping
error
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from typing import List
|
3 |
from utils import get_base_answer, get_nudging_answer
|
4 |
from constant import js_code_label, custom_css, HEADER_MD, BASE_MODELS, NUDGING_MODELS
|
5 |
import datetime
|
6 |
import logging
|
7 |
-
import urllib.request
|
8 |
# add logging info to console
|
9 |
logging.basicConfig(level=logging.INFO)
|
10 |
|
@@ -29,8 +27,8 @@ def respond_base(
|
|
29 |
host_addr = request.client.host
|
30 |
if host_addr not in addr_limit_counter:
|
31 |
addr_limit_counter[host_addr] = 0
|
32 |
-
if addr_limit_counter[host_addr] >
|
33 |
-
|
34 |
|
35 |
base_answer = get_base_answer(base_model=base_model, system_prompt=system_prompt, question=message, max_tokens=max_tokens)
|
36 |
addr_limit_counter[host_addr] += 1
|
@@ -56,8 +54,8 @@ def respond_nudging(
|
|
56 |
host_addr = request.client.host
|
57 |
if host_addr not in addr_limit_counter:
|
58 |
addr_limit_counter[host_addr] = 0
|
59 |
-
if addr_limit_counter[host_addr] >
|
60 |
-
|
61 |
all_info = get_nudging_answer(base_model=base_model, nudging_model=nudging_model, system_prompt=system_prompt, question=message, max_token_total=max_tokens, top_prob_thres=nudging_thres)
|
62 |
all_completions = all_info["all_completions"]
|
63 |
nudging_words = all_info["all_nudging_words"]
|
|
|
1 |
+
import gradio as gr
|
|
|
2 |
from utils import get_base_answer, get_nudging_answer
|
3 |
from constant import js_code_label, custom_css, HEADER_MD, BASE_MODELS, NUDGING_MODELS
|
4 |
import datetime
|
5 |
import logging
|
|
|
6 |
# add logging info to console
|
7 |
logging.basicConfig(level=logging.INFO)
|
8 |
|
|
|
27 |
host_addr = request.client.host
|
28 |
if host_addr not in addr_limit_counter:
|
29 |
addr_limit_counter[host_addr] = 0
|
30 |
+
if addr_limit_counter[host_addr] > 0:
|
31 |
+
raise gr.Error("You have reached the limit of 50 requests for today. Please use your own API key.", duration=10)
|
32 |
|
33 |
base_answer = get_base_answer(base_model=base_model, system_prompt=system_prompt, question=message, max_tokens=max_tokens)
|
34 |
addr_limit_counter[host_addr] += 1
|
|
|
54 |
host_addr = request.client.host
|
55 |
if host_addr not in addr_limit_counter:
|
56 |
addr_limit_counter[host_addr] = 0
|
57 |
+
if addr_limit_counter[host_addr] > 0:
|
58 |
+
raise gr.Error("You have reached the limit of 50 requests for today. Please use your own API key.", duration=10)
|
59 |
all_info = get_nudging_answer(base_model=base_model, nudging_model=nudging_model, system_prompt=system_prompt, question=message, max_token_total=max_tokens, top_prob_thres=nudging_thres)
|
60 |
all_completions = all_info["all_completions"]
|
61 |
nudging_words = all_info["all_nudging_words"]
|