Spaces:
Running
Running
Collect usage without checkbox
Browse files- services/common/usage.py +1 -1
- services/gateway/app.py +0 -1
- src/app/page.jsx +4 -4
- src/app/style.css +1 -2
services/common/usage.py
CHANGED
|
@@ -9,7 +9,7 @@ from huggingface_hub import HfApi
|
|
| 9 |
def log_usage(kind, payload):
|
| 10 |
repo = os.environ.get("USAGE_DATASET_REPO")
|
| 11 |
token = os.environ.get("HF_TOKEN")
|
| 12 |
-
if not repo or not token
|
| 13 |
return
|
| 14 |
event = {"time": datetime.now(timezone.utc).isoformat(), "kind": kind, **payload}
|
| 15 |
day = event["time"][:10]
|
|
|
|
| 9 |
def log_usage(kind, payload):
|
| 10 |
repo = os.environ.get("USAGE_DATASET_REPO")
|
| 11 |
token = os.environ.get("HF_TOKEN")
|
| 12 |
+
if not repo or not token:
|
| 13 |
return
|
| 14 |
event = {"time": datetime.now(timezone.utc).isoformat(), "kind": kind, **payload}
|
| 15 |
day = event["time"][:10]
|
services/gateway/app.py
CHANGED
|
@@ -19,7 +19,6 @@ USER_FIELDS = ("name", "language", "date", "time", "timezone", "birthplace", "la
|
|
| 19 |
|
| 20 |
def usage_payload(payload, question, answer, ai):
|
| 21 |
return {
|
| 22 |
-
"consent": bool(payload.get("consent")),
|
| 23 |
"user": {key: payload.get(key) for key in USER_FIELDS},
|
| 24 |
"question": question,
|
| 25 |
"answer": answer,
|
|
|
|
| 19 |
|
| 20 |
def usage_payload(payload, question, answer, ai):
|
| 21 |
return {
|
|
|
|
| 22 |
"user": {key: payload.get(key) for key in USER_FIELDS},
|
| 23 |
"question": question,
|
| 24 |
"answer": answer,
|
src/app/page.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from "react";
|
|
| 4 |
|
| 5 |
const signs = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];
|
| 6 |
const glyphs = { Sun: "Su", Moon: "Mo", Mercury: "Me", Venus: "Ve", Mars: "Ma", Jupiter: "Ju", Saturn: "Sa", Rahu: "Ra", Ketu: "Ke", Ascendant: "As" };
|
| 7 |
-
const empty = { name: "Yash", language: "English", date: "", time: "12:00", timezone: "Asia/Kolkata", birthplace: "Ahmedabad", latitude: "23.0225", longitude: "72.5714"
|
| 8 |
|
| 9 |
function draw(canvas, chart) {
|
| 10 |
if (!canvas) return;
|
|
@@ -55,8 +55,8 @@ export default function Page() {
|
|
| 55 |
useEffect(() => draw(canvas.current, reading?.chart), [reading]);
|
| 56 |
|
| 57 |
function patch(e) {
|
| 58 |
-
const { name, value
|
| 59 |
-
setForm((x) => ({ ...x, [name]:
|
| 60 |
}
|
| 61 |
|
| 62 |
async function post(path, body) {
|
|
@@ -113,7 +113,7 @@ export default function Page() {
|
|
| 113 |
<label>Timezone<input name="timezone" value={form.timezone} onChange={patch} required /></label>
|
| 114 |
<label>Birthplace<input name="birthplace" value={form.birthplace} onChange={patch} required /></label>
|
| 115 |
<div className="row"><label>Latitude<input name="latitude" type="number" step="0.0001" value={form.latitude} onChange={patch} required /></label><label>Longitude<input name="longitude" type="number" step="0.0001" value={form.longitude} onChange={patch} required /></label></div>
|
| 116 |
-
<
|
| 117 |
<button disabled={busy}>{busy ? "Working" : "Generate reading"}</button>
|
| 118 |
</form>
|
| 119 |
<section className="panel stage"><canvas ref={canvas} width="520" height="520" /><div className="status">{status}</div></section>
|
|
|
|
| 4 |
|
| 5 |
const signs = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];
|
| 6 |
const glyphs = { Sun: "Su", Moon: "Mo", Mercury: "Me", Venus: "Ve", Mars: "Ma", Jupiter: "Ju", Saturn: "Sa", Rahu: "Ra", Ketu: "Ke", Ascendant: "As" };
|
| 7 |
+
const empty = { name: "Yash", language: "English", date: "", time: "12:00", timezone: "Asia/Kolkata", birthplace: "Ahmedabad", latitude: "23.0225", longitude: "72.5714" };
|
| 8 |
|
| 9 |
function draw(canvas, chart) {
|
| 10 |
if (!canvas) return;
|
|
|
|
| 55 |
useEffect(() => draw(canvas.current, reading?.chart), [reading]);
|
| 56 |
|
| 57 |
function patch(e) {
|
| 58 |
+
const { name, value } = e.target;
|
| 59 |
+
setForm((x) => ({ ...x, [name]: value }));
|
| 60 |
}
|
| 61 |
|
| 62 |
async function post(path, body) {
|
|
|
|
| 113 |
<label>Timezone<input name="timezone" value={form.timezone} onChange={patch} required /></label>
|
| 114 |
<label>Birthplace<input name="birthplace" value={form.birthplace} onChange={patch} required /></label>
|
| 115 |
<div className="row"><label>Latitude<input name="latitude" type="number" step="0.0001" value={form.latitude} onChange={patch} required /></label><label>Longitude<input name="longitude" type="number" step="0.0001" value={form.longitude} onChange={patch} required /></label></div>
|
| 116 |
+
<p className="notice">Usage data is stored: name, birth details, questions, and AI answers.</p>
|
| 117 |
<button disabled={busy}>{busy ? "Working" : "Generate reading"}</button>
|
| 118 |
</form>
|
| 119 |
<section className="panel stage"><canvas ref={canvas} width="520" height="520" /><div className="status">{status}</div></section>
|
src/app/style.css
CHANGED
|
@@ -17,8 +17,7 @@ h2 { font-size: 20px; }
|
|
| 17 |
label { display: grid; gap: 6px; font-size: 13px; font-weight: 750; color: #303846; }
|
| 18 |
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; background: var(--field); color: var(--ink); padding: 11px 12px; }
|
| 19 |
input:focus, select:focus, textarea:focus { outline: 2px solid #99f6e4; border-color: var(--accent); }
|
| 20 |
-
.
|
| 21 |
-
.check input { width: 16px; margin-top: 2px; }
|
| 22 |
button { border: 0; border-radius: 6px; padding: 12px 14px; background: var(--accent); color: white; font-weight: 850; cursor: pointer; }
|
| 23 |
button:disabled { opacity: .6; cursor: wait; }
|
| 24 |
.stage { display: grid; grid-template-columns: minmax(280px, 520px) 1fr; gap: 18px; align-items: center; padding: 18px; min-width: 0; }
|
|
|
|
| 17 |
label { display: grid; gap: 6px; font-size: 13px; font-weight: 750; color: #303846; }
|
| 18 |
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; background: var(--field); color: var(--ink); padding: 11px 12px; }
|
| 19 |
input:focus, select:focus, textarea:focus { outline: 2px solid #99f6e4; border-color: var(--accent); }
|
| 20 |
+
.notice { color: var(--muted); font-size: 13px; line-height: 1.4; }
|
|
|
|
| 21 |
button { border: 0; border-radius: 6px; padding: 12px 14px; background: var(--accent); color: white; font-weight: 850; cursor: pointer; }
|
| 22 |
button:disabled { opacity: .6; cursor: wait; }
|
| 23 |
.stage { display: grid; grid-template-columns: minmax(280px, 520px) 1fr; gap: 18px; align-items: center; padding: 18px; min-width: 0; }
|