Spaces:
Sleeping
Sleeping
File size: 1,162 Bytes
0729a88 6847a4d 0729a88 f8c3ed7 6847a4d a5c4680 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from llama_cpp import Llama
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)
def code_block(txt, mdn):
return txt + (res := llm(
prompt=txt,
max_length=16384-len(txt),
stop=['###', '///', '\n\n\n\n'],
)['generated_text']), mdn+txt+res
code_input = gr.inputs.Code(label="Enter your code here")
submit_button = gr.outputs.Button(label="Submit")
options = [
gr.outputs.Accordion([
gr.outputs.Checkbox(label="Option 1"),
gr.outputs.Checkbox(label="Option 2"),
gr.outputs.Checkbox(label="Option 3")
], label="Options")
]
# COnvert this to gr.Blocks()
with gr.Blocks() as apps:
with gr.Row():
mdn = gr.Markdown("## StarCoder 15b Instruct\n\n---\n\n")
with gr.Row():
code = gr.Code("// Enter some Javascript here to interact with StarCoder.\n\nconsole.log(\"StarCoder says")
with gr.Row():
btn = gr.Button("Complete with StarCoder")
btn.click(code_block, inputs=[code, mdn], outputs=[code, mdn])
apps.launch(share=False, debug=True) |