GitHub Actions commited on
Commit
652136d
·
0 Parent(s):

Deploy divination-ai from b75ed1c

Browse files
README.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Divination AI
3
+ emoji: 🔮
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: "6.17.3"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # Divination AI
13
+
14
+ An AI oracle that holds a brief conversation about your life situation, grounds its insights in real-world trends, and reveals 3 differentiated paths forward — always empowering, never deterministic.
15
+
16
+ ## How it works
17
+
18
+ 1. The Oracle asks 5 questions about your situation, goals, and strengths
19
+ 2. It searches the web for real-world context relevant to your domain
20
+ 3. MiniCPM4-8B generates exactly 3 scenarios (Momentum / Pivot / Leap)
21
+ 4. Each scenario includes a concrete first step, signals to watch for, and tradeoffs
22
+
23
+ ## Models
24
+
25
+ | Role | Model | Params |
26
+ |------|-------|--------|
27
+ | Oracle (conversation + generation) | openbmb/MiniCPM4-8B | 8B |
28
+
29
+ ## Architecture
30
+
31
+ - **Frontend**: Gradio 6.x on HuggingFace Spaces
32
+ - **Backend**: Modal.com GPU services (A10G)
33
+ - **Grounding**: Tavily web search API
34
+ - **Structured output**: vLLM + xgrammar constrained decoding
35
+ # Dark-themed scroll UI
app.py ADDED
The diff for this file is too large to render. See raw diff
 
model_runtime.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Divination AI — runtime client for the Modal backend."""
2
+ from __future__ import annotations
3
+
4
+ import os
5
+
6
+ import httpx
7
+
8
+ API_URL = os.environ.get(
9
+ "DIVINATION_AI_API_URL",
10
+ "https://rafalbogusdxc--divination-ai-api.modal.run",
11
+ ).rstrip("/")
12
+
13
+ TIMEOUT_S = 900
14
+
15
+
16
+ class BackendError(RuntimeError):
17
+ pass
18
+
19
+
20
+ def health() -> dict:
21
+ try:
22
+ resp = httpx.get(f"{API_URL}/health", timeout=10, follow_redirects=True)
23
+ resp.raise_for_status()
24
+ return resp.json()
25
+ except Exception:
26
+ return {"status": "unreachable"}
27
+
28
+
29
+ def intake(messages: list[dict]) -> dict:
30
+ try:
31
+ resp = httpx.post(
32
+ f"{API_URL}/intake",
33
+ json={"messages": messages},
34
+ timeout=TIMEOUT_S,
35
+ follow_redirects=True,
36
+ )
37
+ resp.raise_for_status()
38
+ return resp.json()
39
+ except httpx.ConnectError as e:
40
+ raise BackendError("Cannot reach the Oracle backend — is the Modal app deployed?") from e
41
+ except httpx.ReadTimeout as e:
42
+ raise BackendError("The Oracle is taking too long to respond (cold start). Try again in ~1 minute.") from e
43
+ except httpx.HTTPStatusError as e:
44
+ raise BackendError(f"Backend error {e.response.status_code}: {e.response.text[:300]}") from e
45
+
46
+
47
+ def generate(messages: list[dict]) -> dict:
48
+ try:
49
+ resp = httpx.post(
50
+ f"{API_URL}/generate",
51
+ json={"messages": messages},
52
+ timeout=TIMEOUT_S,
53
+ follow_redirects=True,
54
+ )
55
+ resp.raise_for_status()
56
+ return resp.json()
57
+ except httpx.ConnectError as e:
58
+ raise BackendError("Cannot reach the Oracle backend — is the Modal app deployed?") from e
59
+ except httpx.ReadTimeout as e:
60
+ raise BackendError("The Oracle is taking too long (generation in progress). Please wait...") from e
61
+ except httpx.HTTPStatusError as e:
62
+ raise BackendError(f"Backend error {e.response.status_code}: {e.response.text[:300]}") from e
63
+
64
+
65
+ def share_trace(messages: list[dict]) -> dict:
66
+ try:
67
+ resp = httpx.post(
68
+ f"{API_URL}/share",
69
+ json={"messages": messages},
70
+ timeout=30,
71
+ follow_redirects=True,
72
+ )
73
+ resp.raise_for_status()
74
+ return resp.json()
75
+ except Exception:
76
+ return {"shared": False, "reason": "Network error"}
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ httpx>=0.27
static/scrolls_v2/bg.jpg ADDED
static/scrolls_v2/card_leap.jpg ADDED
static/scrolls_v2/card_momentum.jpg ADDED
static/scrolls_v2/card_pivot.jpg ADDED
static/scrolls_v2/input_bg.jpg ADDED
static/scrolls_v2/monument_left.jpg ADDED
static/scrolls_v2/monument_right.jpg ADDED
static/scrolls_v2/scroll_closed.jpg ADDED
static/scrolls_v2/scroll_dark.jpg ADDED
static/scrolls_v2/scroll_fully_open.jpg ADDED
static/scrolls_v2/scroll_opening_1.jpg ADDED
static/scrolls_v2/scroll_opening_2.jpg ADDED
static/scrolls_v2/scroll_opening_3.jpg ADDED
static/scrolls_v2/scroll_oracle.jpg ADDED
static/scrolls_v2/wax_seal_gold.jpg ADDED
static/scrolls_v2/wax_seal_purple.jpg ADDED