aigencydev commited on
Commit
48933e4
·
verified ·
1 Parent(s): a351fd1

Initial release — interactive AIGENCY V4 demo (Gradio)

Browse files
Files changed (3) hide show
  1. README.md +40 -6
  2. app.py +234 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,46 @@
1
  ---
2
  title: AIGENCY V4 Demo
3
- emoji: 🐨
4
- colorFrom: yellow
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 6.13.0
8
  app_file: app.py
9
- pinned: false
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: AIGENCY V4 Demo
3
+ emoji: 🦅
4
+ colorFrom: indigo
5
+ colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 4.44.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: other
11
+ short_description: Sovereign 128B Turkish-first multimodal AI · live API demo
12
+ tags:
13
+ - aigency
14
+ - turkish
15
+ - multimodal
16
+ - sovereign
17
+ - ecloud
18
+ - frontier-adjacent
19
  ---
20
 
21
+ # AIGENCY V4 Live Demo Space
22
+
23
+ Interactive Gradio demo for **AIGENCY V4**, the 128B-parameter sovereign,
24
+ multimodal Turkish-first AI model from eCloud Yazılım Teknolojileri.
25
+
26
+ This Space proxies prompts to the production API at
27
+ [aigency.dev](https://aigency.dev).
28
+
29
+ ## Resources
30
+
31
+ - 🤗 [Model card](https://huggingface.co/aigencydev/AIGENCY-V4)
32
+ - 📊 [Evaluation dataset (reproducibility capsule)](https://huggingface.co/datasets/aigencydev/aigency-v4-evaluation)
33
+ - 📄 [Whitepaper EN](https://github.com/ecloud-bh/aigency-v4-whitepaper/blob/main/AIGENCY-V4-Whitepaper-EN.pdf) ·
34
+ [Whitepaper TR](https://github.com/ecloud-bh/aigency-v4-whitepaper/blob/main/AIGENCY-V4-Whitepaper-TR.pdf)
35
+ - 🔧 [Benchmark code](https://github.com/ecloud-bh/aigency-benchmarks)
36
+
37
+ ## Configuration
38
+
39
+ Required Space secret:
40
+ - `AIGENCY_API_TOKEN` — eCloud production API bearer token
41
+
42
+ Optional Space variables:
43
+ - `AIGENCY_API_BASE` (default: `https://aigency.dev/api/v2`)
44
+ - `AIGENCY_ASSISTANT` (default: `alparslan-v4`)
45
+
46
+ © 2026 eCloud Yazılım Teknolojileri · info@e-cloud.web.tr · ai@aigency.dev
app.py ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """AIGENCY V4 — Interactive demo Space.
2
+
3
+ This Gradio app proxies user prompts to the eCloud production AIGENCY V4 API.
4
+
5
+ Setup (when deploying to HuggingFace Spaces):
6
+ 1. Add `AIGENCY_API_TOKEN` as a Space secret (Space settings → Secrets).
7
+ 2. Optionally add `AIGENCY_API_BASE` (default https://aigency.dev/api/v2)
8
+ and `AIGENCY_ASSISTANT` (default alparslan-v4).
9
+
10
+ The Space supports text and image-with-text input (one image per request,
11
+ ≤ 30 MB, image/* MIME).
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import io
16
+ import os
17
+ import time
18
+ import json
19
+ import base64
20
+ import mimetypes
21
+
22
+ import gradio as gr
23
+ import requests
24
+ from PIL import Image
25
+
26
+ # ── Config ─────────────────────────────────────────────────────────
27
+ API_BASE = os.environ.get("AIGENCY_API_BASE", "https://aigency.dev/api/v2")
28
+ API_TOKEN = os.environ.get("AIGENCY_API_TOKEN", "") # set via Space secret
29
+ ASSISTANT = os.environ.get("AIGENCY_ASSISTANT", "alparslan-v4")
30
+ TIMEOUT = 60 # seconds
31
+ DEMO_BANNER = (
32
+ "AIGENCY V4 — sovereign, multimodal, Turkish-first AI · "
33
+ "128B parameters · 278K context · KVKK-resident"
34
+ )
35
+
36
+
37
+ # ── Bench numbers (static, mirrored from the model card) ───────────
38
+ BENCH = [
39
+ ("Belebele-TR (TR reading)", 0.8733, "Turkish · #1 globally"),
40
+ ("ARC-Challenge", 0.9488, "Frontier-tied"),
41
+ ("GSM8K", 0.9462, "Frontier-tied"),
42
+ ("HellaSwag", 0.8860, "≈6pp behind frontier"),
43
+ ("MBPP", 0.8482, "Upper-mid frontier"),
44
+ ("HumanEval", 0.8415, "Upper-mid frontier"),
45
+ ("TQuAD (TR QA)", 0.8240, "Turkish · #1 globally"),
46
+ ("IFEval (strict)", 0.8022, "Frontier lower-mid"),
47
+ ("MMLU", 0.8010, "Frontier lower-mid"),
48
+ ("HumanEval+", 0.7988, "Upper-mid frontier"),
49
+ ("DocVQA (≥0.5 ANLS)", 0.7917, "Multimodal (first-gen)"),
50
+ ("TR Grammar", 0.7900, "Turkish · #1 globally"),
51
+ ("MBPP+", 0.7804, "Upper-mid frontier"),
52
+ ("TruthfulQA MC1", 0.7638, "Frontier-tied"),
53
+ ("WinoGrande", 0.7466, "≈11pp behind frontier"),
54
+ ("XNLI-TR", 0.7340, "Turkish · #1 globally"),
55
+ ("TR-MMLU", 0.7080, "Turkish · #1 globally"),
56
+ ("ChartQA (relaxed)", 0.6768, "Multimodal (first-gen)"),
57
+ ("MMMU (val)", 0.5333, "Multimodal (first-gen)"),
58
+ ("MMLU-Pro", 0.5020, "Development area"),
59
+ ("GPQA Diamond", 0.3788, "Development area"),
60
+ ("MathVista (testmini)", 0.3413, "Multimodal (first-gen)"),
61
+ ]
62
+
63
+
64
+ def headers():
65
+ return {"Authorization": f"Bearer {API_TOKEN}"}
66
+
67
+
68
+ PLACEHOLDER_MSG = (
69
+ "🔒 The interactive chat is being activated.\n\n"
70
+ "While the demo is finalised, you can already:\n"
71
+ " · Browse the **Benchmark Leaderboard** tab — 22 benchmarks, 13,344 calls\n"
72
+ " · Read the [model card](https://huggingface.co/aigencydev/AIGENCY-V4)\n"
73
+ " · Inspect the [evaluation dataset](https://huggingface.co/datasets/aigencydev/aigency-v4-evaluation)\n"
74
+ " · Read the whitepaper (32 pages, EN/TR) on [GitHub](https://github.com/ecloud-bh/aigency-v4-whitepaper)\n\n"
75
+ "For production access: **info@e-cloud.web.tr · ai@aigency.dev**"
76
+ )
77
+
78
+
79
+ # ── Two-step API protocol ─────────────────────────────────────────
80
+ def new_chat() -> str:
81
+ r = requests.post(
82
+ f"{API_BASE}/chat/newChat",
83
+ headers=headers(),
84
+ json={"assistant_slug": ASSISTANT},
85
+ timeout=TIMEOUT,
86
+ )
87
+ r.raise_for_status()
88
+ return r.json()["chat_id"]
89
+
90
+
91
+ def send_text(chat_id: str, prompt: str) -> str:
92
+ r = requests.post(
93
+ f"{API_BASE}/chat/sendMessage",
94
+ headers=headers(),
95
+ json={"chat_id": chat_id, "message": prompt},
96
+ timeout=TIMEOUT,
97
+ )
98
+ r.raise_for_status()
99
+ return r.json().get("message", "")
100
+
101
+
102
+ def send_with_image(chat_id: str, prompt: str, image: Image.Image) -> str:
103
+ buf = io.BytesIO()
104
+ image.save(buf, format="PNG")
105
+ buf.seek(0)
106
+ files = {
107
+ "attachements": ("image.png", buf, "image/png"), # canonical typo
108
+ }
109
+ data = {"chat_id": chat_id, "message": prompt}
110
+ r = requests.post(
111
+ f"{API_BASE}/chat/sendMessage",
112
+ headers=headers(),
113
+ files=files,
114
+ data=data,
115
+ timeout=TIMEOUT,
116
+ )
117
+ r.raise_for_status()
118
+ return r.json().get("message", "")
119
+
120
+
121
+ # ── Gradio handlers ────────────────────────────────────────────────
122
+ def chat(prompt, image, history):
123
+ history = history or []
124
+ if not prompt.strip():
125
+ return history, ""
126
+ if not API_TOKEN:
127
+ history.append((prompt, PLACEHOLDER_MSG))
128
+ return history, ""
129
+ try:
130
+ chat_id = new_chat()
131
+ if image is not None:
132
+ answer = send_with_image(chat_id, prompt, image)
133
+ else:
134
+ answer = send_text(chat_id, prompt)
135
+ except Exception as e:
136
+ answer = f"Error: {e}"
137
+ history.append((prompt, answer))
138
+ return history, ""
139
+
140
+
141
+ def make_leaderboard():
142
+ rows = [(name, f"{val:.2%}", note) for name, val, note in BENCH]
143
+ return rows
144
+
145
+
146
+ # ── UI ─────────────────────────────────────────────────────────────
147
+ TR_INTRO = """
148
+ ### 🇹🇷 AIGENCY V4 Demo
149
+
150
+ **128 milyar parametreli yerli yapay zekâ.** Türkçe okuma anlamada dünya
151
+ lideri, fen muhakemesi ve grade-school matematikte frontier seviyesinde.
152
+ KVKK-yerel, tam-bağımsız mimari.
153
+
154
+ Aşağıdaki sohbet kutusuna Türkçe veya İngilizce bir istem yazın; isteğe
155
+ bağlı olarak bir görsel ekleyin. Sonuçlar canlı API'den gelir.
156
+ """
157
+
158
+ EN_INTRO = """
159
+ ### 🇬🇧 AIGENCY V4 Demo
160
+
161
+ **128B-parameter sovereign AI**, world-leader on Turkish reading
162
+ comprehension and frontier-level on grade-school math and scientific
163
+ reasoning. KVKK-resident, fully sovereign architecture.
164
+
165
+ Enter a Turkish or English prompt below, optionally attach an image.
166
+ Responses are served live by the production API.
167
+ """
168
+
169
+ with gr.Blocks(title="AIGENCY V4 Demo", theme=gr.themes.Soft()) as demo:
170
+ gr.Markdown(f"# AIGENCY V4\n\n*{DEMO_BANNER}*")
171
+
172
+ with gr.Tab("Chat"):
173
+ with gr.Row():
174
+ with gr.Column(scale=1):
175
+ gr.Markdown(EN_INTRO)
176
+ with gr.Column(scale=1):
177
+ gr.Markdown(TR_INTRO)
178
+ chatbot = gr.Chatbot(height=420, label="Conversation")
179
+ with gr.Row():
180
+ with gr.Column(scale=4):
181
+ msg = gr.Textbox(
182
+ label="Prompt",
183
+ placeholder="Type a question in Turkish or English…",
184
+ lines=2,
185
+ )
186
+ with gr.Column(scale=1):
187
+ img = gr.Image(label="Optional image", type="pil", height=200)
188
+ send = gr.Button("Send", variant="primary")
189
+ send.click(chat, [msg, img, chatbot], [chatbot, msg])
190
+ msg.submit(chat, [msg, img, chatbot], [chatbot, msg])
191
+
192
+ with gr.Tab("Benchmark Leaderboard"):
193
+ gr.Markdown(
194
+ "## 22 benchmarks · 13,344 real API calls · Wilson 95% CI\n"
195
+ "Methodology: temperature 0.0, deterministic seed=42, single "
196
+ "session 27 April 2026.\n\n"
197
+ "*See [the dataset](https://huggingface.co/datasets/aigencydev/aigency-v4-evaluation) "
198
+ "for the full reproducibility capsule.*"
199
+ )
200
+ gr.Dataframe(
201
+ headers=["Benchmark", "AIGENCY V4", "Position vs frontier"],
202
+ value=make_leaderboard(),
203
+ interactive=False,
204
+ wrap=True,
205
+ )
206
+
207
+ with gr.Tab("About"):
208
+ gr.Markdown("""
209
+ ### About AIGENCY V4
210
+
211
+ AIGENCY V4 is the multimodal successor to AIGENCY V3, developed by
212
+ **eCloud Yazılım Teknolojileri**. Released to production in Q2 2026.
213
+
214
+ - **Architecture**: 120B sovereign decoder transformer + 8B vision encoder
215
+ - **Context**: 278K tokens (HBM 3-tier with TG-Decay)
216
+ - **Languages**: Turkish (primary), English
217
+ - **Licence**: API-only commercial — see https://aigency.dev/license
218
+
219
+ **Resources**
220
+
221
+ - 📄 Whitepaper (EN): https://github.com/ecloud-bh/aigency-v4-whitepaper/blob/main/AIGENCY-V4-Whitepaper-EN.pdf
222
+ - 📄 Whitepaper (TR): https://github.com/ecloud-bh/aigency-v4-whitepaper/blob/main/AIGENCY-V4-Whitepaper-TR.pdf
223
+ - 🤗 Model card: https://huggingface.co/aigencydev/AIGENCY-V4
224
+ - 📊 Evaluation dataset: https://huggingface.co/datasets/aigencydev/aigency-v4-evaluation
225
+ - 🔧 Benchmark code: https://github.com/ecloud-bh/aigency-benchmarks
226
+ - 🔗 Production API: https://aigency.dev
227
+
228
+ **Contact**
229
+
230
+ info@e-cloud.web.tr · ai@aigency.dev · © 2026 eCloud Yazılım Teknolojileri
231
+ """)
232
+
233
+ if __name__ == "__main__":
234
+ demo.queue(max_size=8).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.40
2
+ requests>=2.32
3
+ Pillow>=10.0