-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·79 lines (66 loc) · 1.88 KB
/
setup.sh
File metadata and controls
executable file
·79 lines (66 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# 0) Ensure .env file exists (copy from example.env if missing)
if [ ! -f ".env" ]; then
if [ -f "example.env" ]; then
cp example.env .env
echo ".env created from example.env"
else
echo "example.env not found! Please create .env manually."
exit 1
fi
fi
# 1) Create app structure if it doesn't exist
if [ ! -d "app" ]; then
mkdir -p app/helpers
touch app/__init__.py
touch app/helpers/__init__.py
# Create main.py
cat > app/main.py << 'EOF'
import os
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from dotenv import load_dotenv
load_dotenv()
app = FastAPI(
title="Prototype-Mini",
description="A FastAPI quick-start template with OpenAI integration",
version="1.0.0"
)
@app.get("/")
async def root():
return {
"message": "Welcome to Prototype-Mini!",
"status": "running",
"docs": "/docs"
}
@app.get("/health")
async def health_check():
return {"status": "healthy"}
@app.post("/ask")
async def ask_openai(system_prompt: str, user_prompt: str):
from app.helpers.openai_helper import send_prompt_to_openai
response = send_prompt_to_openai(
system_content=system_prompt,
user_prompt=user_prompt
)
if response:
return JSONResponse(content={"success": True, "response": response})
else:
return JSONResponse(
status_code=500,
content={"success": False, "error": "Failed to get response from OpenAI"}
)
EOF
fi
# 2) Move openai_helper.py into helpers folder
if [ -f "openai_helper.py" ]; then
mv openai_helper.py app/helpers/
fi
# 3) Build & run containers
docker-compose build --no-cache
docker-compose up -d
# 4) Remove the .git folder if it exists
if [ -d ".git" ]; then
rm -rf .git
echo ".git folder removed. You can now initialize your own Git repository."
fi