Antonela Tamagnini commited on
Commit
9353f69
·
1 Parent(s): db8443c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -4,9 +4,7 @@ from transformers import pipeline
4
 
5
  # Initialize the local pipeline for the model
6
  pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", torch_dtype=torch.bfloat16, device_map="auto")
7
- # You can choose another model if needed, and adjust parameters as necessary
8
 
9
- # Define the response function for local execution
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -27,7 +25,7 @@ def respond(
27
 
28
  response = ""
29
 
30
- # Use the local pipeline to generate text
31
  for message in pipe(
32
  messages,
33
  max_new_tokens=max_tokens,
@@ -39,7 +37,7 @@ def respond(
39
  response += token
40
  yield response
41
 
42
- # Custom CSS for styling the header and logo
43
  custom_css = """
44
  #header {
45
  display: flex;
@@ -57,7 +55,7 @@ custom_css = """
57
  }
58
  """
59
 
60
- # Gradio interface with additional components and a funny subtitle
61
  demo = gr.ChatInterface(
62
  respond,
63
  title="<div id='header'><h1>Bee Chatbot</h1><img id='logo' src='https://raw.githubusercontent.com/atamagnini/mlops-cs553-fall24/main/assets/logo.png'></div>",
 
4
 
5
  # Initialize the local pipeline for the model
6
  pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", torch_dtype=torch.bfloat16, device_map="auto")
 
7
 
 
8
  def respond(
9
  message,
10
  history: list[tuple[str, str]],
 
25
 
26
  response = ""
27
 
28
+ # Use local pipeline to gen text
29
  for message in pipe(
30
  messages,
31
  max_new_tokens=max_tokens,
 
37
  response += token
38
  yield response
39
 
40
+ # Custom CSS for header and logo
41
  custom_css = """
42
  #header {
43
  display: flex;
 
55
  }
56
  """
57
 
58
+ # Gradio interface
59
  demo = gr.ChatInterface(
60
  respond,
61
  title="<div id='header'><h1>Bee Chatbot</h1><img id='logo' src='https://raw.githubusercontent.com/atamagnini/mlops-cs553-fall24/main/assets/logo.png'></div>",