zurd46 commited on
Commit
85ce618
·
verified ·
1 Parent(s): c1e2ad0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -59,7 +59,7 @@ print(f"Model {model_name} loaded successfully on {device}")
59
 
60
  # Function to run the text generation process
61
  def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
62
- template = "\n{}\n"
63
  model_inputs = tokenizer(template.format(user_text) if usingAdapter else user_text, return_tensors="pt")
64
  model_inputs = model_inputs.to(device)
65
 
@@ -87,7 +87,7 @@ def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
87
 
88
  # Gradio UI setup
89
  with gr.Blocks(css="""
90
- `div.svelte-sfqy0y {
91
  display: flex;
92
  flex-direction: inherit;
93
  flex-wrap: wrap;
@@ -95,6 +95,7 @@ with gr.Blocks(css="""
95
  box-shadow: var(--block-shadow);
96
  border: var(--block-border-width) solid var(--border-color-primary);
97
  border-radius: var(--block-radius);
 
98
  overflow-y: hidden;
99
  padding: 20px;
100
  }
@@ -112,8 +113,10 @@ with gr.Blocks(css="""
112
  padding: 20px;
113
  border-radius: 8px;
114
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
 
115
  }
116
  .gr-button {
 
117
  color: white;
118
  border: none;
119
  border-radius: 4px;
@@ -128,6 +131,7 @@ with gr.Blocks(css="""
128
  width: 100%;
129
  height: 8px;
130
  border-radius: 5px;
 
131
  outline: none;
132
  opacity: 0.9;
133
  -webkit-transition: .2s;
@@ -137,6 +141,7 @@ with gr.Blocks(css="""
137
  opacity: 1;
138
  }
139
  .gr-textbox {
 
140
  color: white;
141
  border: none;
142
  border-radius: 4px;
@@ -168,7 +173,7 @@ with gr.Blocks(css="""
168
  temperature = gr.Slider(minimum=0.1, maximum=5.0, value=0.8, step=0.1, label="Temperature")
169
 
170
  with gr.Column(scale=7):
171
- model_output = gr.Chatbot(label="Chatbot Output", height=400)
172
 
173
  def handle_submit(text, top_p, temperature, top_k, max_new_tokens):
174
  response = run_generation(text, top_p, temperature, top_k, max_new_tokens)
 
59
 
60
  # Function to run the text generation process
61
  def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
62
+ template = "<|context|><|user|>\n{}<|end|>\n<|assistant|>"
63
  model_inputs = tokenizer(template.format(user_text) if usingAdapter else user_text, return_tensors="pt")
64
  model_inputs = model_inputs.to(device)
65
 
 
87
 
88
  # Gradio UI setup
89
  with gr.Blocks(css="""
90
+ div.svelte-sfqy0y {
91
  display: flex;
92
  flex-direction: inherit;
93
  flex-wrap: wrap;
 
95
  box-shadow: var(--block-shadow);
96
  border: var(--block-border-width) solid var(--border-color-primary);
97
  border-radius: var(--block-radius);
98
+ background: var(--block-background-fill);
99
  overflow-y: hidden;
100
  padding: 20px;
101
  }
 
113
  padding: 20px;
114
  border-radius: 8px;
115
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
116
+ background: var(--body-background-fill);
117
  }
118
  .gr-button {
119
+ background-color: var(--block-background-fill);
120
  color: white;
121
  border: none;
122
  border-radius: 4px;
 
131
  width: 100%;
132
  height: 8px;
133
  border-radius: 5px;
134
+ background: #333;
135
  outline: none;
136
  opacity: 0.9;
137
  -webkit-transition: .2s;
 
141
  opacity: 1;
142
  }
143
  .gr-textbox {
144
+ background-color: var(--block-background-fill);
145
  color: white;
146
  border: none;
147
  border-radius: 4px;
 
173
  temperature = gr.Slider(minimum=0.1, maximum=5.0, value=0.8, step=0.1, label="Temperature")
174
 
175
  with gr.Column(scale=7):
176
+ model_output = gr.Chatbot(label="Chatbot Output", height=566)
177
 
178
  def handle_submit(text, top_p, temperature, top_k, max_new_tokens):
179
  response = run_generation(text, top_p, temperature, top_k, max_new_tokens)