mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-13 13:18:02 -05:00
- **Custom Prompt Templates**: Introduced support for user-modifiable prompt templates using Go's `text/template`. - Added default prompt templates for title and tag generation. - Templates are stored in the `prompts` directory and are loaded at startup. - If the template files do not exist, they are created with default content. - Users can modify the templates by editing the files in the `prompts` directory. - **API Endpoints for Prompts**: - Added `GET /api/prompts` endpoint to retrieve the current prompt templates. - Added `POST /api/prompts` endpoint to update the prompt templates. - These endpoints prepare for future UI support for modifying prompts. - **Thread Safety**: - Implemented a `sync.RWMutex` to ensure thread-safe access to the templates. - **Updated Backend Logic**: - Modified `getSuggestedTitle` and `getSuggestedTags` functions to use the loaded templates. - Templates utilize variables like `{{.Language}}`, `{{.Content}}`, `{{.AvailableTags}}`, and `{{.Title}}`. - **Docker and Documentation**: - Updated the `loadTemplates` function to ensure the `prompts` directory exists and to save default templates if missing. - Updated the README with instructions on how to mount the `prompts` directory in Docker and Docker Compose. - Provided guidance on modifying the prompt templates via file edits.
57 lines
No EOL
1.1 KiB
Docker
57 lines
No EOL
1.1 KiB
Docker
# Stage 1: Build the Go binary
|
|
FROM golang:1.22 AS builder
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /app
|
|
|
|
# Copy go.mod and go.sum files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy the rest of the application code
|
|
COPY . .
|
|
|
|
# Build the Go binary
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o paperless-gpt .
|
|
|
|
# Stage 2: Build Vite frontend
|
|
FROM node:20 AS frontend
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json
|
|
|
|
COPY web-app/package.json web-app/package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy the frontend code
|
|
COPY web-app /app/
|
|
|
|
# Build the frontend
|
|
RUN npm run build
|
|
|
|
# Stage 3: Create a lightweight image with the Go binary
|
|
FROM alpine:latest
|
|
|
|
# Install necessary CA certificates
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /root/
|
|
|
|
# Copy the Go binary from the builder stage
|
|
COPY --from=builder /app/paperless-gpt .
|
|
|
|
# Copy the frontend build
|
|
COPY --from=frontend /app/dist /root/web-app/dist
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 8080
|
|
|
|
# Command to run the binary
|
|
CMD ["./paperless-gpt"] |