AndreaAlessandrelli4 commited on
Commit
c3b55a3
·
verified ·
1 Parent(s): 3a5ce72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -48,7 +48,7 @@ def generate(
48
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
49
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
50
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
51
- gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
52
  input_ids = input_ids.to(model.device)
53
 
54
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
@@ -75,7 +75,7 @@ def generate(
75
  chat_interface = gr.ChatInterface(
76
  fn=generate,
77
  additional_inputs=[
78
- gr.Textbox(label="System prompt", lines=6),
79
  gr.Slider(
80
  label="Max new tokens",
81
  minimum=1,
@@ -90,6 +90,10 @@ chat_interface = gr.ChatInterface(
90
  step=0.1,
91
  value=0.6,
92
  ),
 
 
 
 
93
  gr.Slider(
94
  label="Top-p (nucleus sampling)",
95
  minimum=0.05,
@@ -114,16 +118,16 @@ chat_interface = gr.ChatInterface(
114
  ],
115
  stop_btn=None,
116
  examples=[
117
- ["Hello there! How are you doing?"],
118
- ["Can you explain briefly to me what is the Python programming language?"],
119
- ["Explain the plot of Cinderella in a sentence."],
120
- ["How many hours does it take a man to eat a Helicopter?"],
121
- ["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
122
  ],
123
  )
124
 
125
  with gr.Blocks(css="style.css") as demo:
126
  gr.Markdown("# AvvoChat")
 
127
  gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
128
  chat_interface.render()
129
 
 
48
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
49
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
50
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
51
+ gr.Warning(f"Domanda e/o conversazione troppo lungha: superati {MAX_INPUT_TOKEN_LENGTH} tokens.")
52
  input_ids = input_ids.to(model.device)
53
 
54
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
 
75
  chat_interface = gr.ChatInterface(
76
  fn=generate,
77
  additional_inputs=[
78
+ #gr.Textbox(label="System prompt", lines=6),
79
  gr.Slider(
80
  label="Max new tokens",
81
  minimum=1,
 
90
  step=0.1,
91
  value=0.6,
92
  ),
93
+ gr.Checkbox(
94
+ label = "Do-sample(False)",
95
+ value = False,
96
+ )
97
  gr.Slider(
98
  label="Top-p (nucleus sampling)",
99
  minimum=0.05,
 
118
  ],
119
  stop_btn=None,
120
  examples=[
121
+ ["Posso fare una grigliata sul balcone di casa?"],
122
+ ["Se esco di casa senza documento di identità posso essere multato?"],
123
+ ["Le persone single possono adottare un bambino?"],
124
+ ["Posso usare un'immagine prodotto dall'intelligenza artificiale?"],
 
125
  ],
126
  )
127
 
128
  with gr.Blocks(css="style.css") as demo:
129
  gr.Markdown("# AvvoChat")
130
+ gr.Image("AvvoVhat.png", width = 50, height=200)
131
  gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
132
  chat_interface.render()
133