Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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():
|