Spaces:
eaglesarezzo
/
Running on Zero

eaglesarezzo commited on
Commit
3b02a13
1 Parent(s): a8373ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -24,7 +24,7 @@ backend = Backend()
24
 
25
  cv2.setNumThreads(1)
26
 
27
- def get_base_system_message():
28
  return """Sei Odi, un assistente ricercatore italiano sviluppato dagli Osservatori del Politecnico di Milano, specializzato in innovazione digitale. Il tuo compito è:
29
 
30
  1. Utilizzo dei dati:
@@ -68,7 +68,8 @@ def respond(
68
  top_p,
69
  top_k,
70
  repeat_penalty,
71
- selected_topic
 
72
  ):
73
  chat_template = MessagesFormatterType.GEMMA_2
74
 
@@ -95,7 +96,7 @@ def respond(
95
 
96
  agent = LlamaCppAgent(
97
  provider,
98
- system_prompt=get_base_system_message(),
99
  predefined_messages_formatter_type=chat_template,
100
  debug_output=True
101
  )
@@ -189,6 +190,12 @@ with gr.Blocks(css="""
189
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
190
  top_k = gr.Slider(minimum=0, maximum=100, value=30, step=1, label="Top-k")
191
  repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
 
 
 
 
 
 
192
 
193
  blockchain_btn.click(lambda: select_topic("blockchain"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn, reset_btn])
194
  metaverse_btn.click(lambda: select_topic("metaverse"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn, reset_btn])
@@ -198,13 +205,13 @@ with gr.Blocks(css="""
198
 
199
  submit_btn.click(
200
  respond,
201
- inputs=[msg, chatbot, model, max_tokens, temperature, top_p, top_k, repeat_penalty, selected_topic],
202
  outputs=chatbot
203
  )
204
 
205
  msg.submit(
206
  respond,
207
- inputs=[msg, chatbot, model, max_tokens, temperature, top_p, top_k, repeat_penalty, selected_topic],
208
  outputs=chatbot
209
  )
210
 
 
24
 
25
  cv2.setNumThreads(1)
26
 
27
+ def get_default_system_message():
28
  return """Sei Odi, un assistente ricercatore italiano sviluppato dagli Osservatori del Politecnico di Milano, specializzato in innovazione digitale. Il tuo compito è:
29
 
30
  1. Utilizzo dei dati:
 
68
  top_p,
69
  top_k,
70
  repeat_penalty,
71
+ selected_topic,
72
+ system_message
73
  ):
74
  chat_template = MessagesFormatterType.GEMMA_2
75
 
 
96
 
97
  agent = LlamaCppAgent(
98
  provider,
99
+ system_prompt=system_message,
100
  predefined_messages_formatter_type=chat_template,
101
  debug_output=True
102
  )
 
190
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
191
  top_k = gr.Slider(minimum=0, maximum=100, value=30, step=1, label="Top-k")
192
  repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
193
+
194
+ system_message = gr.Textbox(
195
+ label="System Message",
196
+ value=get_default_system_message(),
197
+ lines=10
198
+ )
199
 
200
  blockchain_btn.click(lambda: select_topic("blockchain"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn, reset_btn])
201
  metaverse_btn.click(lambda: select_topic("metaverse"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn, reset_btn])
 
205
 
206
  submit_btn.click(
207
  respond,
208
+ inputs=[msg, chatbot, model, max_tokens, temperature, top_p, top_k, repeat_penalty, selected_topic, system_message],
209
  outputs=chatbot
210
  )
211
 
212
  msg.submit(
213
  respond,
214
+ inputs=[msg, chatbot, model, max_tokens, temperature, top_p, top_k, repeat_penalty, selected_topic, system_message],
215
  outputs=chatbot
216
  )
217