-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_context_schema.py
More file actions
161 lines (154 loc) · 5.87 KB
/
Copy pathuser_context_schema.py
File metadata and controls
161 lines (154 loc) · 5.87 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""Canonical JSON Schema for the transient mood-discovery user context."""
from __future__ import annotations
from copy import deepcopy
from typing import Any
# Keep this separate from FastAPI's flattened request model. Clients can use this
# document to collect a complete, portable description of a person's current
# context without creating a persistent user profile.
USER_CONTEXT_SCHEMA: dict[str, Any] = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://amdhackathon.local/schemas/user_context.schema.json",
"title": "User context",
"description": (
"One transient nearby-discovery request: current location, current mood, "
"local time context, and availability preferences. This document does not "
"describe or require a persisted user profile."
),
"type": "object",
"required": ["location", "feeling", "time_context"],
"properties": {
"location": {
"type": "object",
"required": ["latitude", "longitude"],
"properties": {
"latitude": {
"type": "number",
"minimum": -90,
"maximum": 90,
"description": "Current latitude in WGS84 decimal degrees.",
},
"longitude": {
"type": "number",
"minimum": -180,
"maximum": 180,
"description": "Current longitude in WGS84 decimal degrees.",
},
"radius_m": {
"type": "integer",
"minimum": 100,
"maximum": 40000,
"default": 3000,
"description": "Fixed search radius in metres around the current location.",
},
},
},
"feeling": {
"type": "object",
"required": ["mood_query"],
"properties": {
"mood_query": {
"type": "string",
"minLength": 1,
"maxLength": 500,
"description": "Free-text current mood or intent, such as 'hungry for ramen'.",
},
"resolved_mood_label": {
"type": "string",
"description": "Optional normalized label selected by the mood resolver.",
},
"mood_similarity": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Optional confidence score for the normalized mood label.",
},
},
},
"time_context": {
"type": "object",
"required": ["local_time_iso", "timezone_name"],
"properties": {
"local_time_iso": {
"type": "string",
"format": "date-time",
"description": "Current local time in ISO 8601 format.",
},
"timezone_name": {
"type": "string",
"description": "IANA timezone name, for example America/Los_Angeles.",
},
"time_bucket": {
"type": "string",
"enum": ["morning", "afternoon", "evening", "night"],
},
},
},
"preferences": {
"type": "object",
"properties": {
"top_k": {
"type": "integer",
"minimum": 1,
"maximum": 50,
"default": 8,
"description": "Compatibility name for the number of ranked POIs to return.",
},
"max_results": {
"type": "integer",
"minimum": 1,
"maximum": 20,
"default": 8,
"description": "Number of ranked POIs the current API returns.",
},
"hero_limit": {
"type": "integer",
"minimum": 0,
"maximum": 20,
"default": 8,
"description": "Compatibility name for the number of representative hero images.",
},
"image_limit": {
"type": "integer",
"minimum": 0,
"maximum": 20,
"default": 8,
"description": "Number of PixArt representative images to generate; defaults to one per returned POI.",
},
"open_now_only": {
"type": "boolean",
"default": True,
"description": "Prefer businesses currently reported open by the provider.",
},
"generate_images": {
"type": "boolean",
"default": True,
},
"inference_steps": {
"type": "integer",
"minimum": 1,
"maximum": 50,
"default": 20,
},
"guidance_scale": {
"type": "number",
"minimum": 1,
"maximum": 20,
"default": 4.5,
},
"seed": {
"type": "integer",
"minimum": 0,
"maximum": 2147483647,
"default": 42,
},
"compile_transformer": {
"type": "boolean",
"default": False,
},
},
},
},
}
def schema_document() -> dict[str, Any]:
"""Return a copy so callers cannot mutate the canonical schema in memory."""
return deepcopy(USER_CONTEXT_SCHEMA)