MrOvkill commited on
Commit
b0fd9db
·
verified ·
1 Parent(s): f52e596

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -4,11 +4,18 @@ from llama_cpp import Llama
4
  llm = Llama.from_pretrained("bartowski/starcoder2-15b-instruct-v0.1-GGUF", filename="starcoder2-15b-instruct-v0.1-Q6_K.gguf", n_ctx=16384, n_gpu_layers=99)
5
 
6
  def code_block(txt, mdn):
7
- return txt + (res := llm(
8
- prompt=txt,
9
- stop=['###', '///', '\n\n\n\n'],
10
- )['choices'][0]['text']), mdn+"\n\n"+txt+res
11
- # COnvert this to gr.Blocks()
 
 
 
 
 
 
 
12
 
13
  with gr.Blocks() as apps:
14
  with gr.Row():
 
4
  llm = Llama.from_pretrained("bartowski/starcoder2-15b-instruct-v0.1-GGUF", filename="starcoder2-15b-instruct-v0.1-Q6_K.gguf", n_ctx=16384, n_gpu_layers=99)
5
 
6
  def code_block(txt, mdn):
7
+ txt = ""
8
+ mdn = mdn + "\n\n```javascript\n"
9
+ res = llm(
10
+ prompt=txt,
11
+ stop=['###', '///', '\n\n\n']
12
+ stream=True
13
+ )
14
+ for chk in res:
15
+ txt += chk['choices'][0]['text']
16
+ yield txt, mdn + txt + "\n````\n"
17
+ return txt, mdn+txt+"\n```\n"
18
+
19
 
20
  with gr.Blocks() as apps:
21
  with gr.Row():