Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
+
|
4 |
+
llm = Llama(
|
5 |
+
model_path="deepseek-coder-6.7b.Q4_K_M.gguf",
|
6 |
+
n_ctx=2048,
|
7 |
+
n_threads=4
|
8 |
+
)
|
9 |
+
|
10 |
+
def chat(prompt):
|
11 |
+
system_prompt = "You are a helpful coding assistant. Answer precisely."
|
12 |
+
full_prompt = f"### Instruction:\n{prompt}\n### Response:\n"
|
13 |
+
output = llm(full_prompt, max_tokens=1024)
|
14 |
+
return output["choices"][0]["text"]
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=chat,
|
18 |
+
inputs="text",
|
19 |
+
outputs="text",
|
20 |
+
title="DeepSeek Coder 6.7B",
|
21 |
+
description="Free ChatGPT-style coding assistant",
|
22 |
+
theme="soft"
|
23 |
+
).launch()
|