Leon4gr45 commited on
Commit
639fc5a
·
verified ·
1 Parent(s): 09c1296

Enable DEFAULT_MODEL env var and update Agent.md secrets

Browse files
Files changed (2) hide show
  1. Agent.md +23 -34
  2. Dockerfile +32 -12
Agent.md CHANGED
@@ -5,47 +5,36 @@ This codebase is configured for deployment on Hugging Face Spaces.
5
  ## Deployment Configuration
6
 
7
  ### Target Space
8
- - **Profile:** `Leon4gr45`
9
- - **Space:** `paper2code-cli`
10
- - **Full Identifier:** `Leon4gr45/paper2code-cli`
11
- - **Frontend Port:** `7860`
12
 
13
  ### SDK
14
- - **SDK:** `docker`
15
 
16
  ## Mandatory Endpoints
17
- - `/api/health`: Returns HTTP 200 when ready.
18
- - `/api/api-docs`: Documentation of all API endpoints.
19
-
20
- ## Functional Endpoints
21
-
22
- ### /api/submit-job
23
- - **Method:** POST
24
- - **Purpose:** Transform a research paper into code and push to GitHub.
25
- - **Request:**
26
- ```json
27
- {
28
- "arxivUrl": "https://arxiv.org/abs/2303.08774",
29
- "paperName": "GPT-4 Technical Report",
30
- "repo": "owner/repo"
31
- }
32
- ```
33
- - **Response:**
34
- ```json
35
- {
36
- "success": true,
37
- "githubUrl": "...",
38
- "branch": "...",
39
- "filesCount": 10
40
- }
41
- ```
42
 
43
  ## Deployment Workflow
44
  To deploy, use:
45
- ```bash
46
  hf upload Leon4gr45/paper2code-cli --repo-type=space
47
- ```
48
 
49
  Monitor logs using:
50
- - Build logs: `curl -N -H "Authorization: Bearer $HF_TOKEN" "https://huggingface.co/api/spaces/Leon4gr45/paper2code-cli/logs/build"`
51
- - Run logs: `curl -N -H "Authorization: Bearer $HF_TOKEN" "https://huggingface.co/api/spaces/Leon4gr45/paper2code-cli/logs/run"`
 
5
  ## Deployment Configuration
6
 
7
  ### Target Space
8
+ - **Profile:** Leon4gr45
9
+ - **Space:** paper2code-cli
10
+ - **Full Identifier:** Leon4gr45/paper2code-cli
11
+ - **Frontend Port:** 7860
12
 
13
  ### SDK
14
+ - **SDK:** docker
15
 
16
  ## Mandatory Endpoints
17
+ - /api/health: Returns HTTP 200 when ready.
18
+ - /api/api-docs: Documentation of all API endpoints.
19
+
20
+ ## HF Space Secrets
21
+ To fully configure the application, the following secrets should be set in the Hugging Face Space settings:
22
+
23
+ - \`OPENAI_API_KEY\`: Your OpenAI API key.
24
+ - \`OPENAI_BASE_URL\`: (Optional) Custom base URL for OpenAI-compatible APIs.
25
+ - \`DEFAULT_MODEL\`: (Optional) The default model to use (e.g., \`openai/gpt-4o\`).
26
+ - \`FIRECRAWL_API_KEY\`: Required for web search and scraping.
27
+ - \`PERSONAL_ACCESS_TOKEN\`: GitHub PAT with repo access for pushing code.
28
+ - \`ANTHROPIC_API_KEY\`: (Optional) For Anthropic models.
29
+ - \`GEMINI_API_KEY\`: (Optional) For Google Gemini models.
30
+ - \`GROQ_API_KEY\`: (Optional) For Groq models.
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  ## Deployment Workflow
33
  To deploy, use:
34
+ \`\`\`bash
35
  hf upload Leon4gr45/paper2code-cli --repo-type=space
36
+ \`\`\`
37
 
38
  Monitor logs using:
39
+ - Build logs: \`curl -N -H "Authorization: Bearer \$HF_TOKEN" "https://huggingface.co/api/spaces/Leon4gr45/paper2code-cli/logs/build"\`
40
+ - Run logs: \`curl -N -H "Authorization: Bearer \$HF_TOKEN" "https://huggingface.co/api/spaces/Leon4gr45/paper2code-cli/logs/run"\`
Dockerfile CHANGED
@@ -1,31 +1,51 @@
1
- FROM node:20-alpine AS base
2
 
 
 
3
  RUN apk add --no-cache libc6-compat
4
  WORKDIR /app
5
- RUN npm install -g pnpm
6
 
7
- # Install dependencies
8
  COPY package.json pnpm-lock.yaml* ./
9
- RUN pnpm i --no-frozen-lockfile --ignore-scripts
10
 
11
- # Build
 
 
 
12
  COPY . .
 
 
13
  ENV NEXT_TELEMETRY_DISABLED 1
14
- RUN pnpm run build
15
 
16
- # Runner
17
- FROM node:20-alpine AS runner
 
 
18
  WORKDIR /app
 
19
  ENV NODE_ENV production
20
  ENV NEXT_TELEMETRY_DISABLED 1
21
 
22
- COPY --from=base /app/public ./public
23
- RUN mkdir -p .next && chown node:node .next
24
- COPY --from=base --chown=node:node /app/.next/standalone ./
25
- COPY --from=base --chown=node:node /app/.next/static ./.next/static
 
 
 
 
 
 
 
 
 
26
 
27
  USER node
 
28
  EXPOSE 7860
 
29
  ENV PORT 7860
30
  ENV HOSTNAME "0.0.0.0"
 
31
  CMD ["node", "server.js"]
 
1
+ FROM node:22-alpine AS base
2
 
3
+ # Install dependencies only when needed
4
+ FROM base AS deps
5
  RUN apk add --no-cache libc6-compat
6
  WORKDIR /app
 
7
 
8
+ # Install dependencies based on the preferred package manager
9
  COPY package.json pnpm-lock.yaml* ./
10
+ RUN corepack enable pnpm && pnpm i --frozen-lockfile
11
 
12
+ # Rebuild the source code only when needed
13
+ FROM base AS builder
14
+ WORKDIR /app
15
+ COPY --from=deps /app/node_modules ./node_modules
16
  COPY . .
17
+
18
+ # Disable telemetry during the build.
19
  ENV NEXT_TELEMETRY_DISABLED 1
 
20
 
21
+ RUN corepack enable pnpm && pnpm run build
22
+
23
+ # Production image, copy all the files and run next
24
+ FROM base AS runner
25
  WORKDIR /app
26
+
27
  ENV NODE_ENV production
28
  ENV NEXT_TELEMETRY_DISABLED 1
29
 
30
+ # HF Spaces run with UID 1000, which is the 'node' user in node:22-alpine
31
+ # We ensure the 'node' user is used to avoid UID conflicts
32
+
33
+ COPY --from=builder /app/public ./public
34
+
35
+ # Set the correct permission for prerender cache
36
+ RUN mkdir .next
37
+ RUN chown node:node .next
38
+
39
+ # Automatically leverage output traces to reduce image size
40
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
41
+ COPY --from=builder --chown=node:node /app/.next/standalone ./
42
+ COPY --from=builder --chown=node:node /app/.next/static ./.next/static
43
 
44
  USER node
45
+
46
  EXPOSE 7860
47
+
48
  ENV PORT 7860
49
  ENV HOSTNAME "0.0.0.0"
50
+
51
  CMD ["node", "server.js"]