Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,14 +41,18 @@ You shouldn’t do this:
|
|
| 41 |
• Give the student suggestions to answer that final question.
|
| 42 |
'''
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
messages = [{"role": "system", "content": system_message}]
|
| 53 |
|
| 54 |
for val in history:
|
|
@@ -73,28 +77,17 @@ def respond(
|
|
| 73 |
response += token
|
| 74 |
yield response
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
"""
|
| 79 |
demo = gr.ChatInterface(
|
| 80 |
respond,
|
| 81 |
additional_inputs=[
|
| 82 |
gr.Textbox(value=system_prompt, label="System message"),
|
| 83 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 84 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 85 |
-
gr.Slider(
|
| 86 |
-
|
| 87 |
-
maximum=1.0,
|
| 88 |
-
value=0.95,
|
| 89 |
-
step=0.05,
|
| 90 |
-
label="Top-p (nucleus sampling)",
|
| 91 |
-
),
|
| 92 |
-
],
|
| 93 |
-
allow_flagging = True,
|
| 94 |
-
flagging_dir = 'flagged'
|
| 95 |
-
|
| 96 |
)
|
| 97 |
|
| 98 |
-
|
| 99 |
if __name__ == "__main__":
|
| 100 |
-
demo.launch()
|
|
|
|
| 41 |
• Give the student suggestions to answer that final question.
|
| 42 |
'''
|
| 43 |
|
| 44 |
+
|
| 45 |
+
def log_interaction(message, response, history, system_message):
|
| 46 |
+
log_data = {
|
| 47 |
+
"message": message,
|
| 48 |
+
"response": response,
|
| 49 |
+
"history": history,
|
| 50 |
+
"system_message": system_message
|
| 51 |
+
}
|
| 52 |
+
with open("interaction_logs.jsonl", "a") as logfile:
|
| 53 |
+
logfile.write(json.dumps(log_data) + "\n")
|
| 54 |
+
|
| 55 |
+
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
| 56 |
messages = [{"role": "system", "content": system_message}]
|
| 57 |
|
| 58 |
for val in history:
|
|
|
|
| 77 |
response += token
|
| 78 |
yield response
|
| 79 |
|
| 80 |
+
log_interaction(message, response, history, system_message)
|
| 81 |
+
|
|
|
|
| 82 |
demo = gr.ChatInterface(
|
| 83 |
respond,
|
| 84 |
additional_inputs=[
|
| 85 |
gr.Textbox(value=system_prompt, label="System message"),
|
| 86 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 87 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 88 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 89 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
)
|
| 91 |
|
|
|
|
| 92 |
if __name__ == "__main__":
|
| 93 |
+
demo.launch()
|