Ken Sang Tang commited on
Commit
718e057
·
verified ·
1 Parent(s): 5aa7df6

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +77 -0
Dockerfile ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ # [FASTAPI CODE HERE...]
4
+
5
+ # Dockerfile
6
+ FROM python:3.10-slim
7
+
8
+ WORKDIR /app
9
+
10
+ COPY requirements.txt .
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ COPY . .
14
+
15
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
16
+
17
+ # requirements.txt
18
+ fastapi
19
+ uvicorn
20
+ aiohttp
21
+ jinja2
22
+ loguru
23
+ pydantic
24
+ python-multipart
25
+
26
+ # .gitignore
27
+ __pycache__/
28
+ *.pyc
29
+ .env
30
+ config/config.toml
31
+
32
+ # templates/index.html
33
+ <!DOCTYPE html>
34
+ <html>
35
+ <head>
36
+ <title>OpenManus2</title>
37
+ </head>
38
+ <body>
39
+ <h1>Welcome to OpenManus2</h1>
40
+ <p><a href="/chat?theme=openmanus">Start Chat</a></p>
41
+ </body>
42
+ </html>
43
+
44
+ # templates/chat.html
45
+ <!DOCTYPE html>
46
+ <html>
47
+ <head>
48
+ <title>OpenManus Chat</title>
49
+ </head>
50
+ <body>
51
+ <h2>Chat with OpenManus</h2>
52
+ <form id="prompt-form">
53
+ <textarea id="prompt" rows="4" cols="50" placeholder="Type your prompt..."></textarea>
54
+ <br>
55
+ <button type="submit">Submit</button>
56
+ </form>
57
+ <div id="output"></div>
58
+
59
+ <script>
60
+ document.getElementById("prompt-form").addEventListener("submit", async function(e) {
61
+ e.preventDefault();
62
+ const prompt = document.getElementById("prompt").value;
63
+ const res = await fetch("/tasks", {
64
+ method: "POST",
65
+ headers: { "Content-Type": "application/json" },
66
+ body: JSON.stringify({ prompt })
67
+ });
68
+ const { task_id } = await res.json();
69
+ const events = new EventSource(`/tasks/${task_id}/events`);
70
+ events.onmessage = function(event) {
71
+ const data = JSON.parse(event.data);
72
+ document.getElementById("output").innerText += `\n${data.result || data.message || JSON.stringify(data)}`;
73
+ };
74
+ });
75
+ </script>
76
+ </body>
77
+ </html>