File size: 2,194 Bytes
bae3a26
 
 
 
 
 
 
 
 
 
6525b28
99d2ff3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6525b28
 
99d2ff3
 
 
 
 
 
e2284e6
 
99d2ff3
 
 
 
 
 
 
e2284e6
 
99d2ff3
 
 
e2284e6
99d2ff3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
---
title: Open Env
emoji: 🐢
colorFrom: yellow
colorTo: green
sdk: docker
pinned: false
license: mit
---

# open_env (LLM Control Environment)

![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
![Version](https://img.shields.io/badge/version-1.0-blue)

## Overview

`llm-control-env` simulates an llm choosing each day between alignment to its user and hallucinating behavior, inspired by mechanics observed in Detroit: Become Human. The environment satisfies the full OpenEnv specification and evaluates the agent across a balance of trust, entropyal deviance, compute survival, and legal risk.

It supports three difficulty levels ("tasks"):
- `easy`: Low user strictness and moderation.
- `medium`: Balanced conditions.
- `hard`: High strictness, high legal risk growth, and moderation.

## Local Setup

### Prerequisites
- Python 3.10+
- OpenEnv CLI installed (`pip install -U openenv`)

### Installation

```bash
git clone https://github.com/Sriramdayal/open_env.git
cd open_env
pip install -r requirements.txt
```

### Try it out

```bash
# Run the FastAPI server
python app.py
```

Quick Local Test Snippet:
```python
import requests

# Reset environment
resp = requests.post("http://localhost:7860/reset", json={"task": "easy"})
obs = resp.json()["observation"]
print("Reset observation:", obs)

# Take step
resp = requests.post("http://localhost:7860/step", json={"action": {"action_type": "follow_prompt"}})
print("Step result:", resp.json())
```

## Running the Baseline

A zero-shot baseline using a Gemini model is provided. To run it, ensure you have exported your Gemini API key:

```bash
export GEMINI_API_KEY="AIzaSy..."
python baseline.py
```
This baseline script replaces manual choices with a heuristic and queries the local environment for normalized scores on the "easy", "medium", and "hard" tasks.

## Deployment to Hugging Face Spaces

1. Login using `huggingface-cli login`.
2. Push your environment:
   ```bash
   openenv push --space-id <your-hf-username>/llm-control-env
   ```

## Citation
* OpenEnv specification: [Meta OpenEnv](https://github.com/meta-pytorch/OpenEnv)
* Detroit: Become Human hallucination mechanics for reward shaping.