SMeyersMrOvkill commited on
Commit
a5c4680
1 Parent(s): 9cf6b89
Files changed (1) hide show
  1. app.py +26 -63
app.py CHANGED
@@ -1,65 +1,28 @@
1
  import gradio as gr
2
- from llama_cpp import Llama
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
-
8
- llm = Llama.from_pretrained("bartowski/starcoder2-15b-instruct-v0.1-GGUF", filename="starcoder2-15b-instruct-v0.1-Q6_K.gguf", n_gpu_layers=99, n_ctx=16384)
9
-
10
- def respond(
11
- message,
12
- history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
- top_k
18
- ):
19
- messages = [{"role": "system", "content": system_message}]
20
-
21
- for val in history:
22
- if val[0]:
23
- messages.append({"role": "user", "content": val[0]})
24
- if val[1]:
25
- messages.append({"role": "assistant", "content": val[1]})
26
-
27
- messages.append({"role": "user", "content": message})
28
-
29
- response = ""
30
-
31
- for message in llm.create_chat_completion(
32
- messages,
33
- max_tokens=max_tokens,
34
- stream=True,
35
- temperature=temperature,
36
- top_p=top_p,
37
- top_k=42,
38
- ):
39
- token = message.choices[0].delta.content
40
-
41
- response += token
42
- yield response
43
-
44
- """
45
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
46
- """
47
- demo = gr.ChatInterface(
48
- respond,
49
- additional_inputs=[
50
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
51
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
52
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
53
- gr.Slider(
54
- minimum=0.1,
55
- maximum=1.0,
56
- value=0.95,
57
- step=0.05,
58
- label="Top-p (nucleus sampling)",
59
- ),
60
- ],
61
- )
62
-
63
-
64
- if __name__ == "__main__":
65
- demo.launch()
 
1
  import gradio as gr
 
2
 
3
+ def code_block(code):
4
+ # Add your code logic here
5
+ # This function will be called when the submit button is clicked
6
+ pass
7
+
8
+ code_input = gr.inputs.Code(label="Enter your code here")
9
+ submit_button = gr.outputs.Button(label="Submit")
10
+
11
+ options = [
12
+ gr.outputs.Accordion([
13
+ gr.outputs.Checkbox(label="Option 1"),
14
+ gr.outputs.Checkbox(label="Option 2"),
15
+ gr.outputs.Checkbox(label="Option 3")
16
+ ], label="Options")
17
+ ]
18
+ # COnvert this to gr.Blocks()
19
+
20
+ with gr.Blocks() as apps:
21
+ with gr.Row():
22
+ mdn = gr.Markdown("## StarCoder 15b Instruct\n\n---\n\n")
23
+ with gr.Row():
24
+ code = gr.Code("// Enter some Javascript here to interact with StarCoder.\n\nconsole.log(\"StarCoder says")
25
+ with gr.Row():
26
+ btn = gr.Button("Complete with StarCoder")
27
+ btn.click(code_block, inputs=[code, mdn], outputs=[code, mdn])
28
+ apps.launch(share=False, debug=True)