aixsatoshi commited on
Commit
9ce7647
β€’
1 Parent(s): 1f3161b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -70
app.py CHANGED
@@ -49,7 +49,6 @@ hf_hub_download(
49
  llm = None
50
  llm_model = None
51
 
52
- @spaces.GPU(duration=120)
53
  def respond(
54
  message,
55
  history: list[tuple[str, str]],
@@ -121,7 +120,7 @@ def respond(
121
  outputs += output
122
  yield outputs
123
 
124
- description = """<p align="center">γƒ’γƒ‡γƒ«γ¨γƒγƒ£γƒƒγƒˆγƒ†γƒ³γƒ—γƒ¬γƒΌγƒˆγ‚’ιΈζŠžγ—γ¦γγ γ•γ„ (you can switch to other models from additional inputs)</p>
125
  <p><center>
126
  <a href="https://huggingface.co/Aratako/Oumuamua-7b-RP-GGUF" target="_blank">[Oumuamua-7b-RP Model]</a>
127
  <a href="https://huggingface.co/bartowski/Oumuamua-7b-instruct-v2-GGUF" target="_blank">[Oumuamua-7b-instruct-v2 Model]</a>
@@ -138,74 +137,40 @@ templates = [
138
  "B22", "LLAMA_3", "PHI_3"
139
  ]
140
 
141
- model_dropdown = gr.Dropdown(
142
- choices=[
143
- 'Oumuamua-7b-RP_Q4_K_M.gguf',
144
- 'Oumuamua-7b-instruct-v2-Q4_K_M.gguf',
145
- 'umiyuki-Umievo-itr012-Gleipnir-7B-Q4_K_M.gguf',
146
- 'Ninja-V3-Q4_K_M.gguf',
147
- 'kagemusya-7b-v1Q8_0.gguf',
148
- 'Llama-3-ELYZA-JP-8B-q4_k_m.gguf'
149
- ],
150
- value="Oumuamua-7b-RP_Q4_K_M.gguf",
151
- label="Model"
152
- )
153
-
154
- template_dropdown = gr.Dropdown(
155
- choices=templates,
156
- value="LLAMA_3",
157
- label="Template"
158
- )
159
-
160
- chat_interface = gr.ChatInterface(
161
- respond,
162
- additional_inputs=[
163
- gr.Textbox(value="You are a helpful assistant.", label="System message"),
164
- gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens"),
165
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
166
- gr.Slider(
167
- minimum=0.1,
168
- maximum=1.0,
169
- value=0.95,
170
- step=0.05,
171
- label="Top-p",
172
- ),
173
- gr.Slider(
174
- minimum=0,
175
- maximum=100,
176
- value=40,
177
- step=1,
178
- label="Top-k",
179
- ),
180
- gr.Slider(
181
- minimum=0.0,
182
- maximum=2.0,
183
- value=1.1,
184
- step=0.1,
185
- label="Repetition penalty",
186
- ),
187
- ],
188
- retry_btn="Retry",
189
- undo_btn="Undo",
190
- clear_btn="Clear",
191
- submit_btn="Send",
192
- title="Chat with various models using llama.cpp",
193
- description=description,
194
- chatbot=gr.Chatbot(
195
- scale=1,
196
- likeable=False,
197
- show_copy_button=True
198
- )
199
- )
200
-
201
- demo = gr.Blocks()
202
-
203
- with demo:
204
  gr.Markdown(description)
205
- model_dropdown.render()
206
- template_dropdown.render()
207
- chat_interface.render()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
- if __name__ == "__main__":
210
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
 
 
49
  llm = None
50
  llm_model = None
51
 
 
52
  def respond(
53
  message,
54
  history: list[tuple[str, str]],
 
120
  outputs += output
121
  yield outputs
122
 
123
+ description = """<p align="center">Defaults to Oumuamua-7b-RP (you can switch to other models from additional inputs)</p>
124
  <p><center>
125
  <a href="https://huggingface.co/Aratako/Oumuamua-7b-RP-GGUF" target="_blank">[Oumuamua-7b-RP Model]</a>
126
  <a href="https://huggingface.co/bartowski/Oumuamua-7b-instruct-v2-GGUF" target="_blank">[Oumuamua-7b-instruct-v2 Model]</a>
 
137
  "B22", "LLAMA_3", "PHI_3"
138
  ]
139
 
140
+ with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  gr.Markdown(description)
142
+ model_dropdown = gr.Dropdown(
143
+ choices=[
144
+ 'Oumuamua-7b-RP_Q4_K_M.gguf',
145
+ 'Oumuamua-7b-instruct-v2-Q4_K_M.gguf',
146
+ 'umiyuki-Umievo-itr012-Gleipnir-7B-Q4_K_M.gguf',
147
+ 'Ninja-V3-Q4_K_M.gguf',
148
+ 'kagemusya-7b-v1Q8_0.gguf',
149
+ 'Llama-3-ELYZA-JP-8B-q4_k_m.gguf'
150
+ ],
151
+ value="Oumuamua-7b-RP_Q4_K_M.gguf",
152
+ label="Model"
153
+ )
154
+ template_dropdown = gr.Dropdown(
155
+ choices=templates,
156
+ value="LLAMA_3",
157
+ label="Template"
158
+ )
159
 
160
+ chat_interface = gr.ChatInterface(
161
+ fn=respond,
162
+ inputs=[
163
+ gr.Textbox(value="You are a helpful assistant.", label="System message"),
164
+ model_dropdown,
165
+ template_dropdown,
166
+ gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens"),
167
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
168
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
169
+ gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Top-k"),
170
+ gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty"),
171
+ gr.Chatbot(scale=1, likeable=False, show_copy_button=True)
172
+ ],
173
+ outputs="text"
174
+ )
175
 
176
+ chat_interface.launch()