forked from ohmplatform/FreedomGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ohmplatform#51 from ohmplatform/docker-app
Docker app
- Loading branch information
Showing
28 changed files
with
2,709 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Use an official Ubuntu as a parent image | ||
FROM ubuntu:latest | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Update the package list and install necessary packages | ||
RUN apt-get update && \ | ||
apt-get install -y git wget curl build-essential && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# clone one git repo | ||
RUN git clone "https://github.com/antimatter15/alpaca.cpp.git" | ||
|
||
# cd into alpaca.cpp folder and run make command | ||
RUN cd alpaca.cpp && make && cd .. | ||
|
||
RUN wget "https://huggingface.co/sosaka/alpaca-native-4bit-ggml/resolve/main/ggml-alpaca-7b-q4.bin" | ||
|
||
# copy the chat file to /app | ||
RUN cp alpaca.cpp/chat . | ||
|
||
# remove the alpaca.cpp folder | ||
RUN rm -rf alpaca.cpp | ||
|
||
# Copy the package.json and package-lock.json files to the container | ||
COPY package*.json ./ | ||
|
||
# Install the dependencies and Node.js | ||
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - | ||
RUN apt-get install -y nodejs | ||
RUN npm install -g [email protected] && npm install && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the rest of the application files to the container | ||
COPY . . | ||
|
||
# Build the Vite app | ||
RUN npm run build | ||
|
||
# Expose port 8889 for the Express app | ||
EXPOSE 8889 | ||
|
||
# Start the Express app | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="logo.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>FreedomGPT</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "client", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"start": "node server.js" | ||
}, | ||
"dependencies": { | ||
"concurrently": "^8.0.1", | ||
"cors": "^2.8.5", | ||
"express": "^4.18.2", | ||
"global": "^4.4.0", | ||
"http": "^0.0.1-security", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"socket.io": "^4.6.1", | ||
"socket.io-client": "^4.6.1", | ||
"uuid": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"@types/uuid": "^9.0.1", | ||
"@vitejs/plugin-react": "^3.1.0", | ||
"typescript": "^4.9.3", | ||
"vite": "^4.2.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { spawn } from "child_process"; | ||
import express from "express"; | ||
import http from "http"; | ||
import path from "path"; | ||
import { Server } from "socket.io"; | ||
|
||
const expressapp = express(); | ||
const server = http.createServer(expressapp); | ||
const io = new Server(server, { | ||
cors: { | ||
origin: "*", | ||
methods: ["GET", "POST"], | ||
}, | ||
}); | ||
|
||
const EXPRESSPORT = 8889; | ||
|
||
let numClients = 0; | ||
|
||
expressapp.use( | ||
"/assets", | ||
express.static(path.join(process.cwd(), "dist/assets")) | ||
); | ||
|
||
expressapp.get("*", (req, res) => { | ||
res.sendFile(path.join(process.cwd(), "dist/index.html")); | ||
}); | ||
|
||
io.on("connection", (socket) => { | ||
if (numClients === 1) { | ||
console.log("Only one client allowed"); | ||
socket.disconnect(); | ||
return; | ||
} | ||
|
||
numClients++; | ||
|
||
console.log("Client Connected"); | ||
const CHAT_APP_LOCATION = path.join(process.cwd(), "/chat"); | ||
const FILEPATH = path.join(process.cwd(), "/ggml-alpaca-7b-q4.bin"); | ||
|
||
let program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]); | ||
|
||
socket.on("chatstart", () => { | ||
program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]); | ||
}); | ||
|
||
program.on("error", (err) => { | ||
console.error(err); | ||
}); | ||
|
||
socket.on("stopResponding", () => { | ||
program.kill(); | ||
program = null; | ||
socket.emit("chatend"); | ||
}); | ||
|
||
socket.on("message", (message) => { | ||
program.stdin.write(message + "\n"); | ||
|
||
let closing = ""; | ||
program.stdout.on("data", (data) => { | ||
let output = data.toString("utf8"); | ||
|
||
if (output.includes(">")) { | ||
closing = closing.concat(">"); | ||
} | ||
|
||
output = output.replace(">", ""); | ||
|
||
const response = { result: "success", output: output }; | ||
socket.emit("response", response); | ||
|
||
if (closing.includes(">>")) { | ||
program.kill(); | ||
program = null; | ||
socket.emit("chatend"); | ||
} | ||
}); | ||
}); | ||
|
||
socket.on("disconnect", () => { | ||
numClients--; | ||
program.kill(); | ||
program = null; | ||
}); | ||
}); | ||
|
||
server.listen(EXPRESSPORT, () => { | ||
console.log(`Server listening on port ${EXPRESSPORT}`); | ||
}); | ||
|
||
export default expressapp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
import Main from "./app/screens/Main"; | ||
import MessageFetchProvider from "./app/context/MessageFetch"; | ||
|
||
const App = () => { | ||
return ( | ||
<> | ||
<MessageFetchProvider> | ||
<Main /> | ||
</MessageFetchProvider> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
export const thunder = ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth="1.5" | ||
stroke="currentColor" | ||
aria-hidden="true" | ||
className="h-6 w-6" | ||
height="1.5em" | ||
width="1.5em" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z" | ||
></path> | ||
</svg> | ||
); | ||
|
||
export const sun = ( | ||
<svg | ||
stroke="currentColor" | ||
fill="none" | ||
strokeWidth="1.5" | ||
viewBox="0 0 24 24" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="h-6 w-6" | ||
height="1.5em" | ||
width="1.5em" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<circle cx="12" cy="12" r="5"></circle> | ||
<line x1="12" y1="1" x2="12" y2="3"></line> | ||
<line x1="12" y1="21" x2="12" y2="23"></line> | ||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> | ||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> | ||
<line x1="1" y1="12" x2="3" y2="12"></line> | ||
<line x1="21" y1="12" x2="23" y2="12"></line> | ||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> | ||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> | ||
</svg> | ||
); | ||
|
||
export const alert = ( | ||
<svg | ||
stroke="currentColor" | ||
fill="none" | ||
strokeWidth="1.5" | ||
viewBox="0 0 24 24" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="h-6 w-6" | ||
height="1.5em" | ||
width="1.5em" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path> | ||
<line x1="12" y1="9" x2="12" y2="13"></line> | ||
<line x1="12" y1="17" x2="12.01" y2="17"></line> | ||
</svg> | ||
); | ||
|
||
export const send = ( | ||
<svg | ||
stroke="currentColor" | ||
fill="none" | ||
strokeWidth="2" | ||
viewBox="0 0 30 30" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="h-4 w-4 mr-1" | ||
height="4em" | ||
width="4em" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line x1="22" y1="2" x2="11" y2="13"></line> | ||
<polygon points="22 2 15 22 11 13 2 9 22 2"></polygon> | ||
</svg> | ||
); | ||
|
||
export const boticon = ( | ||
<svg | ||
viewBox="0 0 100 200" | ||
xmlns="http://www.w3.org/2000/svg" | ||
stroke="currentColor" | ||
fill="none" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="h-4 w-4 mr-1" | ||
height="4em" | ||
width="4em" | ||
> | ||
<path | ||
fill="#77B5FE" | ||
d="M50,0 L100,50 L60,70 L60,110 L100,120 L100,200 L0,200 L0,120 L40,110 L40,70 L0,50 L50,0z" | ||
/> | ||
<path fill="#3F3D56" d="M60,70 L40,70 L40,90 L60,90z" /> | ||
<path fill="#C4C4C4" d="M47,40 L53,40 L53,70 L47,70z" /> | ||
<circle cx="50" cy="25" r="15" fill="#C4C4C4" /> | ||
</svg> | ||
); |
Oops, something went wrong.