Spaces:
Build error
Build error
Commit
Β·
d53389b
0
Parent(s):
Duplicate from matthoffner/wizardcoder-ggml
Browse filesCo-authored-by: Matt Hoffner <[email protected]>
- .gitattributes +34 -0
- Dockerfile +23 -0
- README.md +19 -0
- main.py +56 -0
- requirements.txt +11 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:latest
|
2 |
+
|
3 |
+
ENV PYTHONUNBUFFERED 1
|
4 |
+
|
5 |
+
EXPOSE 8000
|
6 |
+
|
7 |
+
RUN useradd -m -u 1000 user
|
8 |
+
USER user
|
9 |
+
ENV HOME=/home/user \
|
10 |
+
PATH=/home/user/.local/bin:$PATH
|
11 |
+
|
12 |
+
WORKDIR $HOME/app
|
13 |
+
|
14 |
+
COPY requirements.txt ./
|
15 |
+
RUN pip install --upgrade pip && \
|
16 |
+
pip install -r requirements.txt
|
17 |
+
|
18 |
+
|
19 |
+
COPY --chown=user . $HOME/app
|
20 |
+
|
21 |
+
RUN ls -al
|
22 |
+
|
23 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: wizardcoder
|
3 |
+
emoji: π§ββοΈπ»π«
|
4 |
+
sdk: docker
|
5 |
+
app_port: 8000
|
6 |
+
duplicated_from: matthoffner/wizardcoder-ggml
|
7 |
+
---
|
8 |
+
|
9 |
+
# WizardCoder-ggml
|
10 |
+
|
11 |
+
## <a href="https://github.com/ggerganov/ggml" target="_blank">ggml</a>
|
12 |
+
## <a href="https://github.com/marella/ctransformers" target="_blank">ctransformers</a>
|
13 |
+
## [FastAPI Docs](https://matthoffner-wizardcoder-ggml.hf.space/docs)
|
14 |
+
|
15 |
+
### Updates
|
16 |
+
|
17 |
+
* Added /v1/chat/completions
|
18 |
+
* [Start using ctransformers](https://github.com/marella/ctransformers)
|
19 |
+
* [Added starcoder example](https://github.com/ggerganov/ggml/tree/master/examples/starcoder)
|
main.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fastapi
|
2 |
+
import json
|
3 |
+
import markdown
|
4 |
+
import uvicorn
|
5 |
+
from fastapi.responses import HTMLResponse
|
6 |
+
from fastapi.middleware.cors import CORSMiddleware
|
7 |
+
from sse_starlette.sse import EventSourceResponse
|
8 |
+
from ctransformers import AutoModelForCausalLM
|
9 |
+
from pydantic import BaseModel
|
10 |
+
|
11 |
+
llm = AutoModelForCausalLM.from_pretrained("TheBloke/WizardCoder-15B-1.0-GGML",
|
12 |
+
model_file="WizardCoder-15B-1.0.ggmlv3.q4_0.bin",
|
13 |
+
model_type="starcoder")
|
14 |
+
app = fastapi.FastAPI(title="WizardCoder")
|
15 |
+
app.add_middleware(
|
16 |
+
CORSMiddleware,
|
17 |
+
allow_origins=["*"],
|
18 |
+
allow_credentials=True,
|
19 |
+
allow_methods=["*"],
|
20 |
+
allow_headers=["*"],
|
21 |
+
)
|
22 |
+
|
23 |
+
@app.get("/")
|
24 |
+
async def index():
|
25 |
+
html_content = """
|
26 |
+
<html>
|
27 |
+
<head>
|
28 |
+
</head>
|
29 |
+
<body>
|
30 |
+
<h1><a href="https://matthoffner-wizardcoder-ggml.hf.space/docs">FastAPI Docs</a></h1>
|
31 |
+
<iframe
|
32 |
+
src="https://matthoffner-monacopilot.hf.space"
|
33 |
+
frameborder="0"
|
34 |
+
width="850"
|
35 |
+
height="450"
|
36 |
+
></iframe>
|
37 |
+
</body>
|
38 |
+
</html>
|
39 |
+
"""
|
40 |
+
return HTMLResponse(content=html_content, status_code=200)
|
41 |
+
|
42 |
+
class ChatCompletionRequest(BaseModel):
|
43 |
+
prompt: str
|
44 |
+
|
45 |
+
@app.post("/v1/chat/completions")
|
46 |
+
async def chat(request: ChatCompletionRequest, response_mode=None):
|
47 |
+
tokens = llm.tokenize(request.prompt)
|
48 |
+
async def server_sent_events(chat_chunks, llm):
|
49 |
+
for chat_chunk in llm.generate(chat_chunks):
|
50 |
+
yield dict(data=json.dumps(llm.detokenize(chat_chunk)))
|
51 |
+
yield dict(data="[DONE]")
|
52 |
+
|
53 |
+
return EventSourceResponse(server_sent_events(tokens, llm))
|
54 |
+
|
55 |
+
if __name__ == "__main__":
|
56 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
requirements.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
uvicorn
|
2 |
+
markdown
|
3 |
+
fastapi
|
4 |
+
loguru
|
5 |
+
torch
|
6 |
+
numpy
|
7 |
+
transformers
|
8 |
+
ctransformers
|
9 |
+
accelerate
|
10 |
+
langchain
|
11 |
+
sse_starlette
|