Spaces:
Running
Running
Commit
•
d4a29e2
1
Parent(s):
c194e76
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,6 @@ import re
|
|
6 |
|
7 |
API_TOKEN = os.environ.get("API_TOKEN")
|
8 |
|
9 |
-
KEY = os.environ.get("KEY")
|
10 |
-
|
11 |
SPECIAL_SYMBOLS_AI = ["ㅤ", "ㅤ"]
|
12 |
SPECIAL_SYMBOLS_USER = ["⠀", "⠀"] # ["‹", "›"] ['"', '"']
|
13 |
|
@@ -47,12 +45,7 @@ def format(instruction, history, input, wrap):
|
|
47 |
formatted_input = f"{sy_la}{instruction}{sy_ra}{formatted_history}{sy_l}{input}{sy_r}{sy_la}"
|
48 |
return f"{formatted_input}{wrapped_input}", formatted_input
|
49 |
|
50 |
-
def predict(
|
51 |
-
|
52 |
-
if (access_key != KEY):
|
53 |
-
print(">>> MODEL FAILED: Input: " + input + ", Attempted Key: " + access_key)
|
54 |
-
return ("[UNAUTHORIZED ACCESS]", input, []);
|
55 |
-
|
56 |
instruction = instruction or DEFAULT_INSTRUCTION
|
57 |
history = history or []
|
58 |
input = input or ""
|
@@ -112,7 +105,6 @@ with gr.Blocks() as demo:
|
|
112 |
input = gr.Textbox(label = "Input", value = DEFAULT_INPUT, lines = 2)
|
113 |
wrap = gr.Textbox(label = "Wrap", value = DEFAULT_WRAP, lines = 1)
|
114 |
instruction = gr.Textbox(label = "Instruction", value = DEFAULT_INSTRUCTION, lines = 4)
|
115 |
-
access_key = gr.Textbox(label = "Access Key", lines = 1)
|
116 |
run = gr.Button("▶")
|
117 |
clear = gr.Button("🗑️")
|
118 |
maintain = gr.Button("☁️")
|
@@ -131,7 +123,7 @@ with gr.Blocks() as demo:
|
|
131 |
with gr.Column():
|
132 |
output = gr.Textbox(label = "Output", value = "", lines = 50)
|
133 |
|
134 |
-
run.click(predict, inputs = [
|
135 |
clear.click(clear_history, [], history, queue = False)
|
136 |
maintain.click(cloud, inputs = [], outputs = [], queue = False)
|
137 |
|
|
|
6 |
|
7 |
API_TOKEN = os.environ.get("API_TOKEN")
|
8 |
|
|
|
|
|
9 |
SPECIAL_SYMBOLS_AI = ["ㅤ", "ㅤ"]
|
10 |
SPECIAL_SYMBOLS_USER = ["⠀", "⠀"] # ["‹", "›"] ['"', '"']
|
11 |
|
|
|
45 |
formatted_input = f"{sy_la}{instruction}{sy_ra}{formatted_history}{sy_l}{input}{sy_r}{sy_la}"
|
46 |
return f"{formatted_input}{wrapped_input}", formatted_input
|
47 |
|
48 |
+
def predict(instruction, history, input, wrap, model, temperature, top_p, top_k, rep_p, max_tokens, stop_seqs, seed):
|
|
|
|
|
|
|
|
|
|
|
49 |
instruction = instruction or DEFAULT_INSTRUCTION
|
50 |
history = history or []
|
51 |
input = input or ""
|
|
|
105 |
input = gr.Textbox(label = "Input", value = DEFAULT_INPUT, lines = 2)
|
106 |
wrap = gr.Textbox(label = "Wrap", value = DEFAULT_WRAP, lines = 1)
|
107 |
instruction = gr.Textbox(label = "Instruction", value = DEFAULT_INSTRUCTION, lines = 4)
|
|
|
108 |
run = gr.Button("▶")
|
109 |
clear = gr.Button("🗑️")
|
110 |
maintain = gr.Button("☁️")
|
|
|
123 |
with gr.Column():
|
124 |
output = gr.Textbox(label = "Output", value = "", lines = 50)
|
125 |
|
126 |
+
run.click(predict, inputs = [instruction, history, input, wrap, model, temperature, top_p, top_k, rep_p, max_tokens, stop_seqs, seed], outputs = [output, input, history], queue = False)
|
127 |
clear.click(clear_history, [], history, queue = False)
|
128 |
maintain.click(cloud, inputs = [], outputs = [], queue = False)
|
129 |
|