redael commited on
Commit
52291b3
·
verified ·
1 Parent(s): b256eab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -30,14 +30,28 @@ def generate_response(prompt, model=model, tokenizer=tokenizer, max_length=100,
30
  early_stopping=True
31
  )
32
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
33
- return response.strip()
 
 
 
34
 
35
  # Define the Gradio interface
36
  def chatbot_interface(user_input):
37
  return generate_response(user_input)
38
 
39
- iface = gr.Interface(fn=chatbot_interface, inputs="text", outputs="text", title="Chatbot", description="Ask anything to the chatbot.")
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  # Launch the Gradio interface
42
- iface.launch()
43
-
 
30
  early_stopping=True
31
  )
32
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
33
+
34
+ # Clean up the response to make it more natural
35
+ response = response.replace('User:', '').replace('Assistant:', '').strip()
36
+ return response
37
 
38
  # Define the Gradio interface
39
  def chatbot_interface(user_input):
40
  return generate_response(user_input)
41
 
42
+ iface = gr.Interface(
43
+ fn=chatbot_interface,
44
+ inputs="text",
45
+ outputs="text",
46
+ title="Chatbot",
47
+ description="Ask anything to the chatbot.",
48
+ examples=[
49
+ ["What is the command to get a list of all files in /var/cache/apt/archives?"],
50
+ ["How do I change to root in Ubuntu?"],
51
+ ["What are the best practices for securing a web server?"]
52
+ ],
53
+ live=True
54
+ )
55
 
56
  # Launch the Gradio interface
57
+ iface.launch()