Spaces:
Runtime error
Runtime error
mhenrichsen
commited on
Commit
•
1cb9e76
1
Parent(s):
e0b3798
Upload folder using huggingface_hub
Browse files- .github/workflows/update_space.yml +28 -0
- README.md +3 -9
- chat-ui/main.py +54 -0
.github/workflows/update_space.yml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Run Python script
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Set up Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: '3.9'
|
20 |
+
|
21 |
+
- name: Install Gradio
|
22 |
+
run: python -m pip install gradio
|
23 |
+
|
24 |
+
- name: Log in to Hugging Face
|
25 |
+
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
+
|
27 |
+
- name: Deploy to Spaces
|
28 |
+
run: gradio deploy
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
title: DanskGPT
|
3 |
-
|
4 |
-
colorFrom: pink
|
5 |
-
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
-
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: DanskGPT
|
3 |
+
app_file: chat-ui/main.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 3.40.1
|
6 |
+
---
|
|
|
|
|
|
|
|
chat-ui/main.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
|
5 |
+
def http_bot(prompt, history, system_prompt, endpoint_url):
|
6 |
+
print(prompt, history, system_prompt, endpoint_url)
|
7 |
+
prompt = f"### Instruction:\n{system_prompt}\n\n### Input:\n{prompt}\n\n### Response:\n"
|
8 |
+
|
9 |
+
headers = {"User-Agent": "vLLM Client"}
|
10 |
+
pload = {
|
11 |
+
"prompt": prompt,
|
12 |
+
"stream": True,
|
13 |
+
"max_tokens": 3000,
|
14 |
+
}
|
15 |
+
response = requests.post(endpoint_url,
|
16 |
+
headers=headers,
|
17 |
+
json=pload,
|
18 |
+
stream=True)
|
19 |
+
|
20 |
+
for chunk in response.iter_lines(chunk_size=8192,
|
21 |
+
decode_unicode=False,
|
22 |
+
delimiter=b"\0"):
|
23 |
+
if chunk:
|
24 |
+
data = json.loads(chunk.decode("utf-8"))
|
25 |
+
output = data["text"][0]
|
26 |
+
|
27 |
+
yield output[len(prompt):]
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="DanskGPT") as demo:
|
33 |
+
gr.Markdown("# DanskGPT v0.3")
|
34 |
+
gr.Markdown("Et dansk alternativ til ChatGPT der kører lokalt.")
|
35 |
+
system_prompt = gr.Textbox(value="Du er en dansk AI-assistent. Du vil blive givet en opgave. Du skal hjælpe så meget du kan.",
|
36 |
+
label="System besked")
|
37 |
+
endpoint_url = gr.Textbox(label="Endpoint url", value="https://h6lsu4k84eqhh4-8000.proxy.runpod.net/generate", render=False)
|
38 |
+
|
39 |
+
|
40 |
+
gr.ChatInterface(
|
41 |
+
http_bot,
|
42 |
+
additional_inputs=[system_prompt, endpoint_url],
|
43 |
+
clear_btn=None,
|
44 |
+
undo_btn=None,
|
45 |
+
retry_btn=None,
|
46 |
+
submit_btn="Send",
|
47 |
+
|
48 |
+
)
|
49 |
+
|
50 |
+
gr.Markdown("Version 0.3 - instruktionsmodel trænet på data op til 31-06-2023.")
|
51 |
+
gr.Markdown("Lavet af Mads Henrichsen - Kontakt: mads.gade.henrichsen@live.dk")
|
52 |
+
gr.Markdown("Bemærk: DanskGPT producerer ikke nødvendigvis sandfærdig information - der er en ny model på vej der er meget bedre til dette.")
|
53 |
+
|
54 |
+
demo.queue(concurrency_count=100).launch()
|