rbantog commited on
Commit
4f0cbe4
·
1 Parent(s): 6171ec4

initial commit

Browse files
Files changed (3) hide show
  1. Dockerfile +45 -0
  2. helloworld.patch +61 -0
  3. replace_hw.py +41 -0
Dockerfile ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM ubuntu:20.04
5
+
6
+ ARG MODEL_DOWNLOAD_LINK
7
+ ENV MODEL_DOWNLOAD_LINK=${MODEL_DOWNLOAD_LINK:-https://huggingface.co/unsloth/DeepSeek-R1-Distill-Qwen-1.5B-GGUF/resolve/main/DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf?download=true}
8
+
9
+ ENV DEBIAN_FRONTEND=noninteractive
10
+
11
+ RUN useradd -m -u 1000 user
12
+ USER user
13
+ ENV PATH="/home/user/.local/bin:$PATH"
14
+
15
+ WORKDIR /app
16
+
17
+
18
+ COPY --chown=user . /app
19
+
20
+ USER root
21
+
22
+ RUN apt-get update && apt-get install -y git cmake build-essential g++ wget curl python3
23
+
24
+ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
25
+ RUN apt-get install -y nodejs
26
+
27
+ USER user
28
+
29
+ RUN python3 replace_hw.py
30
+ RUN git clone https://github.com/ggerganov/llama.cpp.git
31
+
32
+ WORKDIR /app/llama.cpp
33
+ RUN git apply ../helloworld.patch
34
+
35
+ WORKDIR /app/llama.cpp/examples/server/webui
36
+ RUN npm i
37
+ RUN npm run build
38
+
39
+ WORKDIR /app/llama.cpp
40
+ RUN cmake -B build -DBUILD_SHARED_LIBS=OFF
41
+ RUN cmake --build build --config Release -j 8
42
+
43
+ WORKDIR /app/llama.cpp/build/bin
44
+ RUN wget -nv -O local_model.gguf ${MODEL_DOWNLOAD_LINK}
45
+ CMD ["/app/llama.cpp/build/bin/llama-server", "--host", "0.0.0.0","--port","8080", "-c", "2048","-m","local_model.gguf", "--cache-type-k", "q8_0" ]
helloworld.patch ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/examples/server/public_legacy/index-new.html b/examples/server/public_legacy/index-new.html
2
+ index cbfbbdf2..b291e466 100644
3
+ --- a/examples/server/public_legacy/index-new.html
4
+ +++ b/examples/server/public_legacy/index-new.html
5
+ @@ -1072,7 +1072,7 @@ return html`
6
+ return html`
7
+ <div class="mode-${session.value.type}">
8
+ <header>
9
+ - <h2>llama.cpp</h2>
10
+ + <h2>Hello World!</h2>
11
+ <div class="dropdown">
12
+ <button class="dropbtn"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke-width="2"/></svg></button>
13
+ <div class="dropdown-content" id="theme-selector">
14
+ @@ -1096,7 +1096,7 @@ return html`
15
+ </section>
16
+ <footer>
17
+ <p><${ModelGenerationInfo} /></p>
18
+ - <p>Powered By <a href="https://github.com/ggerganov/llama.cpp#readme" target="_blank">llama.cpp</a> and <a href="https://ggml.ai/" target="_blank">ggml.ai</a></p>
19
+ + <p>Powered By <a href="https://github.com/ggerganov/llama.cpp#readme" target="_blank">Hello World!</a> and <a href="https://ggml.ai/" target="_blank">ggml.ai</a></p>
20
+ </footer>
21
+ </div>
22
+ `;
23
+ diff --git a/examples/server/public_legacy/index.html b/examples/server/public_legacy/index.html
24
+ index 75f39330..7d9cd87c 100644
25
+ --- a/examples/server/public_legacy/index.html
26
+ +++ b/examples/server/public_legacy/index.html
27
+ @@ -1266,7 +1266,7 @@
28
+ <header>
29
+ <div class="grid-container">
30
+ <div class="grid-item"></div>
31
+ - <div class="grid-item"><h1>llama.cpp</h1></div>
32
+ + <div class="grid-item"><h1>Hello World!</h1></div>
33
+ <div class="grid-item"><a class="customlink" href="index-new.html">New UI</a></div>
34
+ </div>
35
+ </header>
36
+ diff --git a/examples/server/themes/buttons-top/index.html b/examples/server/themes/buttons-top/index.html
37
+ index 3fb88fcc..03278cbd 100644
38
+ --- a/examples/server/themes/buttons-top/index.html
39
+ +++ b/examples/server/themes/buttons-top/index.html
40
+ @@ -1019,7 +1019,7 @@
41
+ return html`
42
+ <div class="mode-${session.value.type}">
43
+ <header>
44
+ - <h1>llama.cpp</h1>
45
+ + <h1>Hello World!</h1>
46
+ </header>
47
+
48
+ <section id="write">
49
+ diff --git a/examples/server/webui/src/components/Header.tsx b/examples/server/webui/src/components/Header.tsx
50
+ index cbee394b..1f854250 100644
51
+ --- a/examples/server/webui/src/components/Header.tsx
52
+ +++ b/examples/server/webui/src/components/Header.tsx
53
+ @@ -71,7 +71,7 @@ export default function Header() {
54
+ </svg>
55
+ </label>
56
+
57
+ - <div className="grow text-2xl font-bold ml-2">llama.cpp</div>
58
+ + <div className="grow text-2xl font-bold ml-2">Hello World!</div>
59
+
60
+ {/* action buttons (top right) */}
61
+ <div className="flex items-center">
replace_hw.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # filepath: replace_hello_world.py
3
+
4
+ import os
5
+ import urllib.parse
6
+
7
+ def extract_filename(url):
8
+ parsed = urllib.parse.urlsplit(url)
9
+ return os.path.basename(parsed.path)
10
+
11
+ def replace_in_file(file_path, old_text, new_text):
12
+ with open(file_path, 'r', encoding='utf8') as file:
13
+ content = file.read()
14
+
15
+ if old_text not in content:
16
+ return
17
+
18
+ updated_content = content.replace(old_text, new_text)
19
+ with open(file_path, 'w', encoding='utf8') as file:
20
+ file.write(updated_content)
21
+ print(f"Updated: {file_path}")
22
+
23
+ def main():
24
+ model_link = os.getenv("MODEL_DOWNLOAD_LINK")
25
+ if not model_link:
26
+ print("Error: MODEL_DOWNLOAD_LINK environment variable is not set.")
27
+ return
28
+
29
+ download_filename = extract_filename(model_link)
30
+ print(f"Extracted filename: {download_filename}")
31
+
32
+ # Recursively walk thru current directory
33
+ for dirpath, _, filenames in os.walk(os.getcwd()):
34
+ for filename in filenames:
35
+ # Modify the following tuple to include any file extensions you wish to process
36
+ if filename.endswith(('.html', '.ts', '.patch')):
37
+ full_path = os.path.join(dirpath, filename)
38
+ replace_in_file(full_path, "Hello World!", download_filename)
39
+
40
+ if __name__ == '__main__':
41
+ main()