j-js commited on
Commit
5b99214
·
verified ·
1 Parent(s): e9462cd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -120
README.md CHANGED
@@ -1,120 +1,13 @@
1
- # Trading Game Study AI — Hugging Face Space Rebuild v2
2
-
3
- This is a publish-ready FastAPI Docker Space for your Unity trading-game study.
4
-
5
- ## What this version adds
6
-
7
- - **Quant support**: rule-based GMAT-style solver with SymPy support
8
- - **Non-quant conversation**: lightweight Hugging Face **transformers** generator for natural chat
9
- - **Retrieval**: local or remote **datasets** loading from your GMAT corpus with embedding search + reranking
10
- - **Researcher-facing logging endpoints** for Unity WebGL studies
11
- - **Optional Hugging Face dataset persistence** for uploaded logs
12
-
13
- ## Main endpoints
14
-
15
- - `GET /` browser test page
16
- - `GET /health`
17
- - `POST /chat`
18
- - `POST /log/session/start`
19
- - `POST /log/event`
20
- - `POST /log/session/finalize`
21
- - `GET /research/sessions`
22
- - `GET /research/session/{session_id}`
23
-
24
- ## Chat behaviour
25
-
26
- ### Quant messages
27
- Quant-style messages are routed into the deterministic solver layer.
28
- The response is designed to help the participant without directly exposing the final answer.
29
-
30
- ### Non-quant messages
31
- General chat, AI-usage questions, gameplay questions, and non-math messages are routed into a lightweight generative model.
32
-
33
- Default model:
34
- - `google/flan-t5-small`
35
-
36
- You can swap it through environment variables:
37
- - `GENERATOR_MODEL`
38
- - `GENERATOR_TASK`
39
-
40
- ## Logging architecture
41
-
42
- This Space now supports researcher-facing logging so Unity WebGL does not have to rely on browser-local files alone.
43
-
44
- ### Flow
45
- 1. Unity calls `/log/session/start`
46
- 2. Unity sends repeated `/log/event` payloads
47
- 3. Unity calls `/log/session/finalize`
48
- 4. Researcher reads session bundles from `/research/...`
49
-
50
- ### Local persistence
51
- Logs are written into:
52
- - `logs/sessions/`
53
- - `logs/events/`
54
-
55
- ### Hugging Face Hub persistence
56
- If you set these variables, the Space will also push each log file to a dataset repo:
57
-
58
- - `PUSH_LOGS_TO_HUB=1`
59
- - `HF_TOKEN=...`
60
- - `LOG_DATASET_REPO_ID=your-username/your-study-logs`
61
-
62
- This is the recommended option if you want the logs to persist beyond the container lifecycle.
63
-
64
- ## Recommended Space secrets
65
-
66
- - `HF_TOKEN`
67
- - `INGEST_API_KEY`
68
- - `RESEARCH_API_KEY`
69
-
70
- ## Example Unity payloads
71
-
72
- ### Start session
73
- ```json
74
- {
75
- "participant_id": "P001",
76
- "condition": "high_transparency",
77
- "study_id": "trading_ai_study",
78
- "game_version": "1.0.0",
79
- "metadata": {
80
- "platform": "WebGL"
81
- }
82
- }
83
- ```
84
-
85
- ### Event
86
- ```json
87
- {
88
- "participant_id": "P001",
89
- "session_id": "SESSION_ID_HERE",
90
- "event_type": "AIMessageSent",
91
- "question_index": 8,
92
- "turn_index": 2,
93
- "payload": {
94
- "tone": 0.8,
95
- "verbosity": 0.6,
96
- "transparency": 0.4,
97
- "promptLengthChars": 122,
98
- "tokensDisplayedBeforeSend": 32
99
- }
100
- }
101
- ```
102
-
103
- ### Finalize
104
- ```json
105
- {
106
- "participant_id": "P001",
107
- "session_id": "SESSION_ID_HERE",
108
- "summary": {
109
- "totalAiInteractions": 11,
110
- "totalTokensSpent": 216,
111
- "questionsWithAiUse": 7
112
- }
113
- }
114
- ```
115
-
116
- ## Notes
117
-
118
- - This build is ready to publish as a Hugging Face **Docker Space**.
119
- - For a real study, I strongly recommend enabling Hub log persistence or wiring an external database later.
120
- - The local container filesystem alone should not be treated as the final durable storage layer for participant data.
 
1
+ ---
2
+ title: Trading Game AI V2
3
+ emoji: 🤖
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # Trading Game AI V2
12
+
13
+ Docker Space for the Unity trading-game AI backend.