printf-sourav commited on
Commit
0798864
·
1 Parent(s): bea2be2

Prepare HF deploy with OpenAI token

Browse files
Files changed (3) hide show
  1. .env.example +9 -1
  2. Dockerfile +1 -1
  3. README.md +46 -1
.env.example CHANGED
@@ -1,8 +1,16 @@
 
1
  API_BASE_URL=https://router.huggingface.co/v1
2
  MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
3
- OPENAI_API_KEY=<your_openai_compatible_api_key>
 
 
4
  HF_TOKEN=<optional_fallback_token>
5
 
 
 
 
 
 
6
  # Optional runtime knobs
7
  LOCAL_IMAGE_NAME=
8
  MY_ENV_V4_TASK=easy-command-typo
 
1
+ # Default profile: Hugging Face Router (OpenAI-compatible API)
2
  API_BASE_URL=https://router.huggingface.co/v1
3
  MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
4
+ OPENAI_API_KEY=<your_openai_or_router_api_key>
5
+
6
+ # Optional backward-compatible fallback. Used only when OPENAI_API_KEY is unset.
7
  HF_TOKEN=<optional_fallback_token>
8
 
9
+ # OpenAI direct profile (uncomment for OpenAI access token usage):
10
+ # API_BASE_URL=https://api.openai.com/v1
11
+ # MODEL_NAME=gpt-4o-mini
12
+ # OPENAI_API_KEY=<your_openai_access_token>
13
+
14
  # Optional runtime knobs
15
  LOCAL_IMAGE_NAME=
16
  MY_ENV_V4_TASK=easy-command-typo
Dockerfile CHANGED
@@ -10,4 +10,4 @@ COPY . .
10
  ENV PORT=7860
11
  EXPOSE 7860
12
 
13
- CMD ["python", "-m", "uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
10
  ENV PORT=7860
11
  EXPOSE 7860
12
 
13
+ CMD ["python", "-m", "server.app"]
README.md CHANGED
@@ -220,6 +220,14 @@ export HF_TOKEN="<your_token>"
220
  export LOCAL_IMAGE_NAME="<local_env_image_name>"
221
  ```
222
 
 
 
 
 
 
 
 
 
223
  ## 8. Run Inference
224
 
225
  Offline/local mode:
@@ -330,6 +338,43 @@ Server endpoints used by validators:
330
  - `GET /state`
331
  - `GET /health`
332
 
333
- ## 12. One-line Presentation Summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
  We built an OpenEnv-compliant reinforcement learning environment where AI agents learn to debug real CI/CD pipelines using multi-step reasoning, hybrid grading, anti-hacking safeguards, and robust reward shaping.
 
220
  export LOCAL_IMAGE_NAME="<local_env_image_name>"
221
  ```
222
 
223
+ If you want to use an OpenAI access token directly:
224
+
225
+ ```bash
226
+ export API_BASE_URL="https://api.openai.com/v1"
227
+ export MODEL_NAME="gpt-4o-mini"
228
+ export OPENAI_API_KEY="<your_openai_access_token>"
229
+ ```
230
+
231
  ## 8. Run Inference
232
 
233
  Offline/local mode:
 
338
  - `GET /state`
339
  - `GET /health`
340
 
341
+ ## 12. Deploy to Hugging Face Space (OpenAI Token)
342
+
343
+ This repository is already configured for Docker Spaces (`sdk: docker` in this README front matter).
344
+
345
+ 1. Create a new Hugging Face Space with SDK set to `Docker`.
346
+ 2. Push this repository to the Space git remote.
347
+ 3. In Space Settings -> Variables and secrets, add these Secrets:
348
+
349
+ ```text
350
+ OPENAI_API_KEY=<your_openai_access_token>
351
+ API_BASE_URL=https://api.openai.com/v1
352
+ MODEL_NAME=gpt-4o-mini
353
+ ```
354
+
355
+ 4. Optional Secrets:
356
+
357
+ ```text
358
+ HF_TOKEN=<optional_fallback_token>
359
+ OFFLINE_INFERENCE=0
360
+ MAX_STEPS=8
361
+ TEMPERATURE=0.2
362
+ MAX_TOKENS=120
363
+ ```
364
+
365
+ 5. Keep the app port as `7860` (already configured).
366
+ 6. Wait for build completion, then verify:
367
+
368
+ ```bash
369
+ curl -sS https://<your-space-name>.hf.space/health
370
+ curl -sS -X POST https://<your-space-name>.hf.space/reset -H 'Content-Type: application/json' -d '{}'
371
+ ```
372
+
373
+ Notes:
374
+
375
+ - `.env.example` is for local development reference only. Hugging Face Spaces use Secrets/Variables from Space Settings.
376
+ - Runtime code reads `OPENAI_API_KEY` first and falls back to `HF_TOKEN` when `OPENAI_API_KEY` is not provided.
377
+
378
+ ## 13. One-line Presentation Summary
379
 
380
  We built an OpenEnv-compliant reinforcement learning environment where AI agents learn to debug real CI/CD pipelines using multi-step reasoning, hybrid grading, anti-hacking safeguards, and robust reward shaping.