Spaces:
Runtime error
Runtime error
feat: get the username of the user
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ PUSH_FREQUENCY = 60 # every minute
|
|
19 |
|
20 |
HISTORY = ""
|
21 |
PROMPT = ""
|
|
|
22 |
|
23 |
DATA_FILENAME = "data.jsonl"
|
24 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
@@ -91,7 +92,9 @@ def format_prompt(message, history, system_prompt):
|
|
91 |
return prompt
|
92 |
|
93 |
def generate(
|
94 |
-
prompt, history, system_prompt,
|
|
|
|
|
95 |
):
|
96 |
global HISTORY
|
97 |
HISTORY = history
|
@@ -227,7 +230,7 @@ def vote(data: gr.LikeData):
|
|
227 |
{
|
228 |
"time_stamp": time.time(),
|
229 |
"model_version":MODEL_VERSION,
|
230 |
-
"username":
|
231 |
"prompt": PROMPT,
|
232 |
"history": HISTORY,
|
233 |
"system prompt": additional_inputs[0].value,
|
@@ -242,7 +245,16 @@ def vote(data: gr.LikeData):
|
|
242 |
]
|
243 |
jsonlfile.write("\n".join(json_data) + "\n")
|
244 |
|
|
|
|
|
|
|
|
|
|
|
245 |
with gr.Blocks(css=CSS) as demo:
|
|
|
|
|
|
|
|
|
246 |
with gr.Row():
|
247 |
with gr.Column():
|
248 |
gr.Markdown(
|
|
|
19 |
|
20 |
HISTORY = ""
|
21 |
PROMPT = ""
|
22 |
+
USERNAME = ""
|
23 |
|
24 |
DATA_FILENAME = "data.jsonl"
|
25 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
|
|
92 |
return prompt
|
93 |
|
94 |
def generate(
|
95 |
+
prompt, history, system_prompt,
|
96 |
+
temperature=0.9, max_new_tokens=100, top_p=0.95,
|
97 |
+
repetition_penalty=1.0, seed=42,
|
98 |
):
|
99 |
global HISTORY
|
100 |
HISTORY = history
|
|
|
230 |
{
|
231 |
"time_stamp": time.time(),
|
232 |
"model_version":MODEL_VERSION,
|
233 |
+
"username":USERNAME,
|
234 |
"prompt": PROMPT,
|
235 |
"history": HISTORY,
|
236 |
"system prompt": additional_inputs[0].value,
|
|
|
245 |
]
|
246 |
jsonlfile.write("\n".join(json_data) + "\n")
|
247 |
|
248 |
+
def create_greeting(request: gr.Request):
|
249 |
+
global USERNAME
|
250 |
+
USERNAME = request.username
|
251 |
+
return gr.Markdown.update(value=f"Thanks for logging in, {request.username}")
|
252 |
+
|
253 |
with gr.Blocks(css=CSS) as demo:
|
254 |
+
|
255 |
+
user_ip = gr.Markdown(value="Not logged in")
|
256 |
+
demo.load(create_greeting, inputs=None, outputs=user_ip)
|
257 |
+
|
258 |
with gr.Row():
|
259 |
with gr.Column():
|
260 |
gr.Markdown(
|