Spaces:
Building
Building
Upload 2 files
Browse files- flare-tasarim.md +398 -466
- flare-ui-tasarim.md +546 -573
flare-tasarim.md
CHANGED
@@ -1,512 +1,444 @@
|
|
1 |
-
#
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
✅ Spark ile, kullanıcı mesajından intent ve parametre extraction akışını yönetmek,
|
7 |
-
✅ Eksik parametre değerleri için system prompt oluşturup, Spark ile insani mesaja dönüştürerek bu parametrelerin değerlerini kullanıcıya tamamlatmak,
|
8 |
-
✅ Doğru parameter değerleri ile API çağrıları yapmak,
|
9 |
-
✅ API cevabını Spark üzerinden insanileştirilmiş metne dönüştürmek ve kullanıcıya iletmek,
|
10 |
-
✅ Her şeyi session bazında, state machine mantığında takip etmek.
|
11 |
-
✅ TTS (Text-to-Speech) desteği ile bot yanıtlarını sesli olarak sunmak.
|
12 |
-
✅ STT (Speech-to-Text) desteği ile kullanıcıdan sesli girdi almak (gelecek özellik).
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
- **GPT-4o (OpenAI)**: OpenAI API üzerinden GPT-4o modeli kullanımı için
|
22 |
-
- **GPT-4o-mini (OpenAI)**: Düşük maliyetli alternatif için GPT-4o-mini modeli
|
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 |
-
- `tts_engine`: Kullanılacak motor ("no_tts", "elevenlabs", "blaze")
|
58 |
-
- `tts_engine_api_key`: Motor API anahtarı (şifrelenmiş)
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
-
|
63 |
-
-
|
64 |
-
- **No STT**: STT devre dışı
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
##
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
-
|
82 |
-
-
|
83 |
-
-
|
84 |
-
- Selamlama ve small talk davranışları
|
85 |
-
- Güvenlik kuralları
|
86 |
|
87 |
-
|
88 |
-
-
|
89 |
-
-
|
90 |
-
-
|
91 |
|
92 |
-
|
|
|
|
|
|
|
93 |
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
Spark servisine /startup request'i gönderir:
|
98 |
```json
|
99 |
{
|
100 |
-
"
|
101 |
-
"
|
102 |
-
"
|
103 |
-
"
|
104 |
-
"
|
105 |
-
"
|
106 |
-
"
|
107 |
-
"fine_tune_zip": "<project.version.llm.fine_tune_zip>"
|
108 |
}
|
109 |
```
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
|
115 |
|
116 |
-
|
|
|
|
|
|
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
"context": [
|
125 |
-
{ "role": "user", "content": "Merhaba!" },
|
126 |
-
{ "role": "assistant", "content": "Merhaba, nasıl yardımcı olabilirim?" }
|
127 |
-
]
|
128 |
-
}
|
129 |
-
```
|
130 |
|
131 |
-
|
132 |
```json
|
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 |
-
4. LLM eğer intent belirlerse, parametreleri bu aşamada extract etmez. Bulduğu intent'in adını özel bir formatta döndürür. Örnek: `#DETECTED_INTENT:search_flight_intent`
|
162 |
-
|
163 |
-
## 2️⃣ Parametre Extraction
|
164 |
-
1. Belirlenen intent'e göre beklenen parametre listesi çıkarılır.
|
165 |
-
2. LLM'e, user_input ile birlikte parametre extraction_prompt'ları birleştirilip tek bir system prompt olarak gönderilir. LLM buradan parametre değerlerini extract eder ve özel bir formatta döndürür. Örnek:
|
166 |
-
`#PARAMETERS:{ "extracted": [ { "to_city": "İstanbul" } ], "missing": [ "to_city", "date"] }`
|
167 |
-
3. Döndürülen parametreler tanımdaki variable_name key'i ile session'a eklenir. Eğer birden fazla intent'te aynı variable_name'e sahip parametreler varsa, aynı değişken değerini paylaşırlar.
|
168 |
-
|
169 |
-
## 3️⃣ Eksik Parametre Tamamlama
|
170 |
-
1. Zorunlu parametrelerden eksik olanlar varsa, Flare bunları kullanıcıdan istemek için uygun prompt'u hazırlar ve LLM'e gönderir. Bunun için, eksik parametrelerin tanımlarındaki name ve intent.parameters.extraction_prompt'lar birleştirilerek tek bir system prompt haline getirilir.
|
171 |
-
2. LLM, kullanıcı cevabını işleyip tekrar extraction yapar ve yukarıdaki #PARAMETERS formatında Flare'e dönüş yapar. Eksik parametre değeri kalmayan kadar Flare-LLM iletişimi bu şekilde döner.
|
172 |
-
3. Sohbette bir intent tespit edildiğinde, bu intent'in zorunlu bir parametresinin variable_name'i session'da zaten mevcutsa ve değer içeriyorsa, bu parametre tekrar extract edilmeye çalışılmaz, session'daki ilgili variable'dan alınıp kullanılır.
|
173 |
-
|
174 |
-
## 4️⃣ Parametre Validation
|
175 |
-
1. Alınan her parameter değeri, parameter tanımındaki tip ve regex (min/max uzunluk gibi) kurallarla doğrulanır.
|
176 |
-
2. Hatalı değerler varsa, bu parametrelerin invalid_prompt'ları birleştirilip LLM'e tek bir system prompt olarak gönderilir ve LLM kullanıcıya doğrudan döndürülecek insani hata mesajını oluşturup döndürür. Örnek: "Söylediğiniz uçuş numarası hatalı. Uçuş numaranız 6 haneli bir numara olmalıdır."
|
177 |
-
|
178 |
-
## 5️⃣ API Çağrısı
|
179 |
-
Tüm parametreler tamamlanınca Flare, intent'e bağlı API çağrısını yapar.
|
180 |
-
Intent'e bağlı API adı, service_config.json'da ilgili intent nesnesinin action alanında tanımlıdır. Bu adı kullanarak apis altındaki ilgili api tanımına ulaşılabilir.
|
181 |
-
|
182 |
-
Bu aşamada kritik bir detay:
|
183 |
-
|
184 |
-
🔑 **Eğer API tanımında auth bölümü varsa:**
|
185 |
-
- Api çağırılmadan önce, session içinde auth_tokens[api_name] var mı control edilir. Varsa bu token kullanılır.
|
186 |
-
- Eğer yoksa, token alma işlemi yapılır.
|
187 |
-
- Token almak için, token_endpoint ve body_template kullanılarak token api servisine request gönderilir, dönen json response içinden response_token_path json path'i kullanılarak token değeri alınır.
|
188 |
-
- Alınan token session içinde auth_tokens[api_name] olarak saklanır.
|
189 |
-
- Token expire ederse, token_refresh_endpoint ve token_refresh_body kullanılarak mevcut token refresh edilir.
|
190 |
-
- Header ve body'lerdeki {auth_tokens.api_name.token} placeholder'ları bu token ile doldurulur.
|
191 |
-
|
192 |
-
Eğer auth tanımı yoksa, API çağrısı doğrudan yapılır.
|
193 |
-
Bu mekanizma API erişiminde güvenlik ve süreklilik sağlar.
|
194 |
-
|
195 |
-
## 6️⃣ Response Mapping
|
196 |
-
API'den dönen JSON response'tan belirli değerleri session değişkenlerine aktarma mekanizmasıdır. Her API tanımında response_mappings array'i ile tanımlanır:
|
197 |
-
```json
|
198 |
-
"response_mappings": [
|
199 |
-
{
|
200 |
-
"variable_name": "booking_id",
|
201 |
-
"type": "str",
|
202 |
-
"json_path": "booking.confirmation_number"
|
203 |
-
},
|
204 |
-
{
|
205 |
-
"variable_name": "departure_time",
|
206 |
-
"type": "date",
|
207 |
-
"json_path": "flight_details.departure.time"
|
208 |
-
}
|
209 |
-
]
|
210 |
```
|
211 |
-
Bu mapping'ler API başarılı response döndüğünde (status 200) otomatik olarak işlenir. Belirtilen json_path'teki değerler, tanımlanan type'a göre dönüştürülüp session.variables içine variable_name ile kaydedilir.
|
212 |
-
|
213 |
-
Desteklenen type'lar: str, int, float, bool, date
|
214 |
-
|
215 |
-
Bu mekanizma sayesinde API response'larından alınan değerler, sonraki intent'lerde veya API çağrılarında kullanılabilir hale gelir.
|
216 |
-
|
217 |
-
## 7️⃣ API Cevabını İnsanileştirme
|
218 |
-
Api'den dönen ham json, api tanımı altındaki response_prompt ile birlikte LLM'e gönderilir ve akıcı, insani bir cevap üretilir.
|
219 |
-
|
220 |
-
Not: Api tanımındaki response_prompt içindeki {{api_response}} değeri, api'den dönen json string ile replace edilir.
|
221 |
-
|
222 |
-
Örnek: `"response_prompt": "Aşağıdaki JSON döviz kuru bilgilerini içeriyor. Kullanıcıya anlaşılır bir Türkçe özet hazırla:\n\n{{api_response}}"`
|
223 |
-
|
224 |
-
## 8️⃣ Session ve State Takibi
|
225 |
-
Her kullanıcı sohbeti bir session ID ile takip edilir.
|
226 |
-
Session üzerinde:
|
227 |
-
- Son 10 adet konuşma tarihçesi,
|
228 |
-
- Son intent,
|
229 |
-
- Toplanan parametreler,
|
230 |
-
- Eksik parametreler,
|
231 |
-
- Akışın neresinde olduğumuz (intent detection, parameter extraction, api call, response humanization)
|
232 |
-
- Api token'ları
|
233 |
-
|
234 |
-
tutulur. Bu, çok adımlı akışlarda state kaybını engeller.
|
235 |
-
|
236 |
-
# Date Type Desteği
|
237 |
-
|
238 |
-
Parametre tanımlarında "date" type'ı desteklenmektedir. Date parametreleri:
|
239 |
-
- ISO format (YYYY-MM-DD) olarak saklanır
|
240 |
-
- Türkçe tarih ifadeleri otomatik olarak parse edilir (bugün, yarın, 15 Temmuz, vb.)
|
241 |
-
- Extraction prompt'larında güncel tarih context'i sağlanır
|
242 |
-
- Validation sırasında geçerli tarih formatı kontrolü yapılır
|
243 |
-
|
244 |
-
# 🏗 Mimari Bileşenler
|
245 |
-
|
246 |
-
| Bileşen | Görev |
|
247 |
-
|---------|-------|
|
248 |
-
| LLM Interface | Farklı LLM provider'larını abstract eden katman |
|
249 |
-
| Spark LLM | HuggingFace Spark servisi ile iletişim |
|
250 |
-
| GPT-4o LLM | OpenAI API ile iletişim |
|
251 |
-
| TTS Interface | Farklı TTS provider'larını abstract eden katman |
|
252 |
-
| ElevenLabs TTS | ElevenLabs TTS servisi ile iletişim |
|
253 |
-
| Flare Session Manager | Her kullanıcı için session ve state takibi |
|
254 |
-
| Flare Prompt Engine | Her aşamada LLM'e gönderilecek uygun system prompt'u dinamik hazırlayan yapı |
|
255 |
-
| API Connector | Tanımlı API'lere parametrelerle çağrı yapan, auth/refresh yöneten katman |
|
256 |
-
| Validation Engine | Parametre değerlerini tip ve format bazlı doğrulayan yapı |
|
257 |
-
| UI ve Config Katmanı | Flare işleyiş konfigürasyonu ve api tanımları; version bazlı project tanımlamaları; project tanımı altında intent tanımları; intent tanımı altında parametre tanımlarını yöneten arayüz |
|
258 |
-
|
259 |
-
# 📋 Yapılacaklar
|
260 |
-
|
261 |
-
✅ LLM abstraction layer geliştirilmesi
|
262 |
-
✅ Spark ile intent tespiti için system prompt tasarımı → Örnek cümlelerle zenginleştirme
|
263 |
-
✅ GPT-4o için prompt optimization
|
264 |
-
✅ Parametre extraction için intent bazlı prompt şablonları hazırlanması
|
265 |
-
✅ Eksik parametre tamamlama için eksik parametre bazlı prompt oluşturma
|
266 |
-
✅ Parametre tip tanımları ve validation engine geliştirilmesi
|
267 |
-
✅ API connector modülü → auth, refresh, token yönetimi, timeout, retry mantığı ile geliştirme
|
268 |
-
✅ Humanization prompt'larının API cevabına göre dinamik hazırlanması
|
269 |
-
✅ Session ve state machine geliştirme
|
270 |
-
✅ Response mapping mekanizması
|
271 |
-
✅ Internal prompt sistemi
|
272 |
-
✅ Date type desteği
|
273 |
-
✅ Multi-provider support
|
274 |
-
✅ TTS (Text-to-Speech) entegrasyonu
|
275 |
-
✅ ElevenLabs TTS provider
|
276 |
-
⏳ STT (Speech-to-Text) entegrasyonu
|
277 |
-
⏳ Blaze TTS provider
|
278 |
-
⏳ Flicker STT provider
|
279 |
-
|
280 |
-
# 🔑 Önemli Notlar (Unutulmaması Gerekenler)
|
281 |
-
|
282 |
-
1. LLM prompt'ları tek seferde şişirilmemeli; sohbetin her aşamasında sadece gereken system prompt dinamik oluşturulup gönderilmeli.
|
283 |
-
2. Parametre extraction'da ek bir model (BERT vb.) yerine sadece seçilen LLM kullanılacak.
|
284 |
-
3. Intent başına (proje başına max ~8-10 intent), her bir intent için max ~5-6 örnek cümle şeklinde bir kapasite planlaması düşünülebilir.
|
285 |
-
4. Parametre tip ve regex validation başarısızsa, LLM üzerinden insani bir hata mesajı oluşturulup kullanıcıya döndürülmeli.
|
286 |
-
5. API response'larının insanileştirilmesi, kullanıcıya daha iyi bir deneyim sunmak için LLM'den geçmeli.
|
287 |
-
6. API token yönetimi ve refresh mekanizması, Flare içinde güvenli ve izlenebilir şekilde tutulmalı.
|
288 |
-
7. GPT-4o kullanımında token maliyetleri göz önünde bulundurulmalı, conversation history sınırlandırılmalı.
|
289 |
-
8. Farklı LLM'lerin response formatları normalize edilmeli (#DETECTED_INTENT ve #PARAMETERS formatları korunmalı).
|
290 |
-
9. TTS kullanımında API key güvenliği ve maliyet kontrolü sağlanmalı.
|
291 |
-
10. Tüm API key'ler (OpenAI, ElevenLabs, vb.) şifrelenmiş olarak saklanmalı.
|
292 |
-
|
293 |
-
# Servis Konfigürasyonu
|
294 |
-
|
295 |
-
Flare'in tanımlarını tutan bir document database gibi kullanacağımız service_config.jsonc dosyasının yapısı, örnek data ve alan açıklamaları ile birlikte aşağıdadır.
|
296 |
-
|
297 |
-
```jsonc
|
298 |
-
{
|
299 |
-
// =====================================================
|
300 |
-
// FLARE GLOBAL CONFIGURATION
|
301 |
-
// =====================================================
|
302 |
-
"config": {
|
303 |
-
"work_mode": "hfcloud", // "hfcloud" | "cloud" | "on-premise" | "gpt4o" | "gpt4o-mini"
|
304 |
-
"cloud_token": "<your cloud token or OpenAI API key>", // work_mode'a göre Spark token veya OpenAI API key (şifrelenmiş)
|
305 |
-
"spark_endpoint": "https://ucsturkey-spark.hf.space", // Spark servisi URL (GPT mode'da kullanılmaz)
|
306 |
-
"internal_prompt": "⚠️ **NEVER output \"#DETECTED_INTENT:\"...", // Merkezi LLM kuralları
|
307 |
-
"project_id_counter": 1, // Yeni proje ID'leri için counter
|
308 |
-
"last_update_date": "2025-06-08T12:00:00.000Z", // Race condition kontrolü için
|
309 |
-
"last_update_user": "admin",
|
310 |
-
|
311 |
-
// === TTS/STT Configuration ==============
|
312 |
-
"tts_engine": "no_tts", // "no_tts" | "elevenlabs" | "blaze"
|
313 |
-
"tts_engine_api_key": "enc:...", // Şifrelenmiş TTS API key
|
314 |
-
"stt_engine": "no_stt", // "no_stt" | "elevenlabs" | "flicker"
|
315 |
-
"stt_engine_api_key": "enc:...", // Şifrelenmiş STT API key
|
316 |
-
|
317 |
-
// === Login Users (bcrypt hash + salt): Flare UI kullanılabilecek user'lar ==============
|
318 |
-
"users": [
|
319 |
-
{
|
320 |
-
"username": "admin",
|
321 |
-
"password_hash": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
|
322 |
-
"salt": "random_salt_string"
|
323 |
-
}
|
324 |
-
]
|
325 |
-
},
|
326 |
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
{
|
332 |
-
"id": 1,
|
333 |
-
"name": "coronos_assistant", // Virtual agent adı
|
334 |
-
"caption": "Coronos Sanal Asistan",
|
335 |
-
"icon": "folder", // Material icon adı
|
336 |
-
"description": "Coronos müşteri hizmetleri asistanı", // Proje açıklaması
|
337 |
-
"enabled": true, // Kullanımda olma durumu
|
338 |
-
"default_language": "tr", // Varsayılan dil kodu
|
339 |
-
"supported_languages": ["tr", "en"], // Desteklenen diller
|
340 |
-
"timezone": "Europe/Istanbul", // Saat dilimi
|
341 |
-
"region": "tr-TR", // Bölge kodu
|
342 |
-
"last_version_number": 1, // Projelerin version_number için versiyon counter. Artarak ilerler.
|
343 |
-
"last_update_date": "2025-06-08T12:00:00.000Z",
|
344 |
-
"last_update_user": "admin",
|
345 |
-
"deleted": false,
|
346 |
-
"created_date": "2025-06-08T12:00:00.000Z",
|
347 |
-
"created_by": "admin",
|
348 |
-
|
349 |
-
// --------------------------------------------------------
|
350 |
-
// VERSIONS: Proje revizyonları ayrı bir version_number ile takip edilir.
|
351 |
-
// Yayınlanmış versiyonlar üzerinde düzenleme yapılamaz.
|
352 |
-
// Yeni versiyon oluşturumak için published versiyonlardan biri seçilir ve kopyası oluştulur, bu kopya üzerinde düzenleme yapılabilir.
|
353 |
-
// --------------------------------------------------------
|
354 |
-
"versions": [
|
355 |
-
{
|
356 |
-
"id": 1, // Proje versiyonu
|
357 |
-
"caption": "v1",
|
358 |
-
"published": true, // Versiyonun yayınlanma durumu.
|
359 |
-
|
360 |
-
// === Virtual agent'ın yapabileceği işleri tarifler =========
|
361 |
-
"general_prompt": "You are an airline assistant. You can book tickets, give information about booked tickets ...",
|
362 |
-
|
363 |
-
// === LLM configuration =======================
|
364 |
-
"llm": {
|
365 |
-
// Spark mode için:
|
366 |
-
"repo_id": "ytu-ce-cosmos/Turkish-Llama-8b-DPO-v0.1", // HuggingFace model repo ID
|
367 |
-
"generation_config": { // LLM generation parametreleri
|
368 |
-
"max_new_tokens": 128,
|
369 |
-
"temperature": 0.3,
|
370 |
-
"top_p": 0.7,
|
371 |
-
"repetition_penalty": 1.1
|
372 |
-
},
|
373 |
-
"use_fine_tune": false, // LoRA fine-tune model kullanılma durumu
|
374 |
-
"fine_tune_zip": "", // use_fine_tune: true ise, kullanılacak LoRA adapter zip'in URL'i
|
375 |
-
|
376 |
-
// GPT-4o mode için (work_mode = "gpt4o" veya "gpt4o-mini" olduğunda kullanılır):
|
377 |
-
"gpt_model": "gpt-4o", // "gpt-4o" | "gpt-4o-mini"
|
378 |
-
"gpt_temperature": 0.3, // 0-2 arası
|
379 |
-
"gpt_max_tokens": 512 // Maximum response token sayısı
|
380 |
-
},
|
381 |
-
|
382 |
-
// === INTENTS =================================
|
383 |
-
"intents": [
|
384 |
-
{
|
385 |
-
"name": "currency_rate_intent", // alt çizgi, tire yok
|
386 |
-
"caption": "Kur sorgulama",
|
387 |
-
"locale": "tr-TR",
|
388 |
-
"dependencies": [], // intent bağımlılıkları.
|
389 |
-
|
390 |
-
// Intent detection
|
391 |
-
"examples": [
|
392 |
-
"What is the dollar rate?",
|
393 |
-
"How much is the euro?"
|
394 |
-
],
|
395 |
-
"detection_prompt": "Identify if user is asking for currency rate information.", // Intent detection için kullanılacak system prompt.
|
396 |
-
|
397 |
-
// Parameters: Intent tespit edildiğinde, kullanıcının ifadesinden extract edilecek parametreler
|
398 |
-
"parameters": [
|
399 |
-
{
|
400 |
-
"name": "currency",
|
401 |
-
"caption": "Döviz cinsi", // Eksik parametreyi tamamlarken kullanıcıya söylenebilecek parametre adı
|
402 |
-
"type": "str", // "str" | "int" | "float" | "bool" | "date"
|
403 |
-
"required": true,
|
404 |
-
"variable_name": "currency", // Parametre değerini set edeceğimiz session değişkeni adı
|
405 |
-
"extraction_prompt": "Extract the currency code (USD, EUR, TRY) from the user message.", // Parametre extraction için kullanılacak system prompt
|
406 |
-
"validation_regex": "^(USD|EUR|TRY)$", // kullanıcıdan alınan parametre değerini validate etmek için kullanılacak regex. Opsiyonel.
|
407 |
-
"invalid_prompt": "Geçersiz para birimi girdiniz. USD, EUR veya TRY şeklinde giriniz.", // Parametre değeri invalid ise kullanıcıya söylenecek mesajı oluşturacak system prompt
|
408 |
-
"type_error_prompt": "Para birimi metin olmalıdır (ör: USD)." // Eğer parametre tipi hatalıysa kullanıcıya söylenecek mesajı oluşturacak system prompt
|
409 |
-
}
|
410 |
-
],
|
411 |
-
|
412 |
-
// API to call
|
413 |
-
"action": "currency_api", // Bu intent tespit edilip, parametreleri tamamlandığında çağırılacak api'nin adı.
|
414 |
-
|
415 |
-
// Fallbacks
|
416 |
-
"fallback_timeout_prompt": "Kur servisinde gecikme yaşanıyor. Lütfen biraz sonra tekrar deneyin.", // Api timeout durumunda kullanıcıya söylenecek mesajı oluşturacak system prompt
|
417 |
-
"fallback_error_prompt": "Kur bilgileri alınırken bir hata oluştu, daha sonra tekrar deneyebilir misiniz?" // Api hatası durumunda kullanıcıya söylenecek mesajı oluşturacak system prompt
|
418 |
-
}
|
419 |
-
// ... başka intent'ler
|
420 |
-
],
|
421 |
-
|
422 |
-
"last_update_date": "2025-06-08T12:00:00.000Z",
|
423 |
-
"last_update_user": "admin",
|
424 |
-
"deleted": false,
|
425 |
-
"created_date": "2025-06-08T12:00:00.000Z",
|
426 |
-
"created_by": "admin",
|
427 |
-
"publish_date": "2025-06-08T12:00:00.000Z",
|
428 |
-
"published_by": "admin"
|
429 |
-
}
|
430 |
-
// ... yeni versiyonlar
|
431 |
-
]
|
432 |
-
}
|
433 |
-
// ... başka projeler
|
434 |
-
],
|
435 |
|
436 |
-
|
437 |
-
|
438 |
-
// =====================================================
|
439 |
-
"apis": [
|
440 |
-
{
|
441 |
-
"name": "currency_api",
|
442 |
-
"url": "https://mock.api/currency",
|
443 |
-
"method": "POST",
|
444 |
-
|
445 |
-
// Headers as dict; placeholders destekler
|
446 |
-
"headers": {
|
447 |
-
"Content-Type": "application/json",
|
448 |
-
"Authorization": "Bearer {{auth_tokens.currency_api.token}}"
|
449 |
-
},
|
450 |
-
|
451 |
-
// Body template
|
452 |
-
"body_template": {
|
453 |
-
"currency": "{{variables.currency}}"
|
454 |
-
},
|
455 |
-
|
456 |
-
// Timeout & retry
|
457 |
-
"timeout_seconds": 5,
|
458 |
-
"retry": {
|
459 |
-
"retry_count": 3,
|
460 |
-
"backoff_seconds": 2,
|
461 |
-
"strategy": "static" // "static" | "exponential"
|
462 |
-
},
|
463 |
-
|
464 |
-
// Auth (optional)
|
465 |
-
"auth": {
|
466 |
-
"enabled": false,
|
467 |
-
"token_endpoint": "https://mock.api/auth",
|
468 |
-
"token_request_body": {},
|
469 |
-
"response_token_path": "token", // json-path style. Ex: xx.yy.z
|
470 |
-
"token_refresh_endpoint": null, // opsiyonel
|
471 |
-
"token_refresh_body": {} // token_refresh_endpoint varsa zorunlu, yoksa opsiyonel.
|
472 |
-
},
|
473 |
-
|
474 |
-
"proxy": "", // Proxy (optional)
|
475 |
-
|
476 |
-
// API response → human-friendly answer
|
477 |
-
"response_prompt": "Aşağıdaki JSON döviz kuru bilgilerini içeriyor. Kullanıcıya anlaşılır bir Türkçe özet hazırla:\n\n{{api_response}}",
|
478 |
-
|
479 |
-
// Response mapping
|
480 |
-
"response_mappings": [
|
481 |
-
{
|
482 |
-
"variable_name": "exchange_rate",
|
483 |
-
"type": "float",
|
484 |
-
"json_path": "data.rate"
|
485 |
-
}
|
486 |
-
],
|
487 |
-
|
488 |
-
"last_update_date": "2025-06-08T12:00:00.000Z",
|
489 |
-
"last_update_user": "admin",
|
490 |
-
"deleted": false,
|
491 |
-
"created_date": "2025-06-08T12:00:00.000Z",
|
492 |
-
"created_by": "admin"
|
493 |
-
}
|
494 |
-
],
|
495 |
-
|
496 |
-
// =====================================================
|
497 |
-
// ACTIVITY LOG
|
498 |
-
// =====================================================
|
499 |
-
"activity_log": [
|
500 |
-
{
|
501 |
-
"id": 1,
|
502 |
-
"timestamp": "2025-06-08T12:00:00.000Z",
|
503 |
-
"user": "admin",
|
504 |
-
"action": "CREATE_PROJECT",
|
505 |
-
"entity_type": "project",
|
506 |
-
"entity_id": 1,
|
507 |
-
"entity_name": "airline_agent",
|
508 |
-
"details": "Created new project"
|
509 |
-
}
|
510 |
-
]
|
511 |
-
}
|
512 |
```
|
|
|
1 |
+
# Flare Platform - Güncel Tasarım Dokümanı
|
2 |
|
3 |
+
## 🏗 Genel Mimari
|
4 |
|
5 |
+
Flare, modüler LLM provider desteği ile çalışan çok adımlı ve akıllı bir orchestration katmanıdır. Provider-agnostic tasarımı sayesinde farklı LLM, TTS ve STT motorları ile çalışabilir.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
### Temel Özellikler
|
8 |
+
- ✅ Provider-based mimari (LLM, TTS, STT)
|
9 |
+
- ✅ Intent detection ve parameter extraction
|
10 |
+
- ✅ Akıllı parametre toplama (smart grouping)
|
11 |
+
- ✅ Onay mekanizması (requiresApproval)
|
12 |
+
- ✅ Multi-language destek (LocalizedExample, LocalizedCaption)
|
13 |
+
- ✅ Session-based state machine
|
14 |
+
- ✅ API orchestration ve response mapping
|
15 |
+
- ✅ Activity logging ve audit trail
|
16 |
|
17 |
+
## 📋 Konfigürasyon Yapısı
|
18 |
|
19 |
+
### service_config.jsonc - Ana Yapı
|
20 |
+
```json
|
21 |
+
{
|
22 |
+
"config": {
|
23 |
+
// Provider tanımları
|
24 |
+
"llm_provider": {
|
25 |
+
"name": "spark|gpt4o|gpt4o-mini",
|
26 |
+
"api_key": "enc:...", // Şifrelenmiş
|
27 |
+
"endpoint": "https://...",
|
28 |
+
"settings": {
|
29 |
+
"internal_prompt": "Global LLM yönergesi",
|
30 |
+
"parameter_collection_config": {
|
31 |
+
"max_params_per_question": 2,
|
32 |
+
"smart_grouping": true,
|
33 |
+
"retry_unanswered": true,
|
34 |
+
"collection_prompt": "..."
|
35 |
+
}
|
36 |
+
}
|
37 |
+
},
|
38 |
+
"tts_provider": {
|
39 |
+
"name": "no_tts|elevenlabs|blaze",
|
40 |
+
"api_key": "enc:...",
|
41 |
+
"endpoint": null,
|
42 |
+
"settings": {}
|
43 |
+
},
|
44 |
+
"stt_provider": {
|
45 |
+
"name": "no_stt|google|azure|flicker",
|
46 |
+
"api_key": "/path/to/credentials.json",
|
47 |
+
"endpoint": null,
|
48 |
+
"settings": {
|
49 |
+
"language": "tr-TR",
|
50 |
+
"model": "latest_long"
|
51 |
+
}
|
52 |
+
},
|
53 |
+
"providers": [
|
54 |
+
// Kullanılabilir provider tanımları
|
55 |
+
],
|
56 |
+
"users": [...]
|
57 |
+
},
|
58 |
+
"projects": [...],
|
59 |
+
"apis": [...],
|
60 |
+
"activity_log": [...],
|
61 |
+
"project_id_counter": 1,
|
62 |
+
"last_update_date": null,
|
63 |
+
"last_update_user": null
|
64 |
+
}
|
65 |
+
```
|
66 |
|
67 |
+
### Provider Sistemi
|
|
|
|
|
68 |
|
69 |
+
#### Provider Config
|
70 |
+
```json
|
71 |
+
{
|
72 |
+
"type": "llm|tts|stt",
|
73 |
+
"name": "spark",
|
74 |
+
"display_name": "Spark LLM",
|
75 |
+
"requires_endpoint": true,
|
76 |
+
"requires_api_key": true,
|
77 |
+
"requires_repo_info": false,
|
78 |
+
"description": "YTU Cosmos Spark LLM"
|
79 |
+
}
|
80 |
+
```
|
81 |
|
82 |
+
#### Provider Settings
|
83 |
+
```json
|
84 |
+
{
|
85 |
+
"name": "provider_name",
|
86 |
+
"api_key": "enc:encrypted_key",
|
87 |
+
"endpoint": "https://endpoint",
|
88 |
+
"settings": {
|
89 |
+
// Provider-specific ayarlar
|
90 |
+
}
|
91 |
+
}
|
92 |
+
```
|
93 |
|
94 |
+
### Project Yapısı
|
95 |
+
```json
|
96 |
+
{
|
97 |
+
"id": 1,
|
98 |
+
"name": "project_name",
|
99 |
+
"caption": "Proje Başlığı",
|
100 |
+
"icon": "folder",
|
101 |
+
"description": "Açıklama",
|
102 |
+
"enabled": true,
|
103 |
+
"default_locale": "tr",
|
104 |
+
"supported_locales": ["tr", "en"],
|
105 |
+
"timezone": "Europe/Istanbul",
|
106 |
+
"region": "tr-TR",
|
107 |
+
"versions": [...],
|
108 |
+
"version_id_counter": 1,
|
109 |
+
"deleted": false,
|
110 |
+
"created_date": "2024-01-01T00:00:00Z",
|
111 |
+
"created_by": "username",
|
112 |
+
"last_update_date": null,
|
113 |
+
"last_update_user": null
|
114 |
+
}
|
115 |
+
```
|
116 |
|
117 |
+
### Version Yapısı
|
118 |
+
```json
|
119 |
+
{
|
120 |
+
"id": 1,
|
121 |
+
"no": 1,
|
122 |
+
"caption": "v1",
|
123 |
+
"description": "Version açıklaması",
|
124 |
+
"published": true,
|
125 |
+
"deleted": false,
|
126 |
+
"general_prompt": "Asistan için genel yönerge",
|
127 |
+
"welcome_prompt": "Hoşgeldin mesajı yönergesi",
|
128 |
+
"llm": {
|
129 |
+
"repo_id": "model-id",
|
130 |
+
"generation_config": {},
|
131 |
+
"use_fine_tune": false,
|
132 |
+
"fine_tune_zip": ""
|
133 |
+
},
|
134 |
+
"intents": [...],
|
135 |
+
"created_date": "2024-01-01T00:00:00Z",
|
136 |
+
"created_by": "username",
|
137 |
+
"publish_date": null,
|
138 |
+
"published_by": null
|
139 |
+
}
|
140 |
+
```
|
141 |
+
|
142 |
+
### Intent Yapısı
|
143 |
+
```json
|
144 |
+
{
|
145 |
+
"name": "intent_name",
|
146 |
+
"caption": "Intent Başlığı",
|
147 |
+
"requiresApproval": false,
|
148 |
+
"dependencies": [],
|
149 |
+
"examples": [
|
150 |
+
{
|
151 |
+
"locale_code": "tr",
|
152 |
+
"example": "Örnek cümle"
|
153 |
+
}
|
154 |
+
],
|
155 |
+
"detection_prompt": "Intent algılama yönergesi",
|
156 |
+
"parameters": [...],
|
157 |
+
"action": "api_name",
|
158 |
+
"fallback_timeout_prompt": "Zaman aşımı mesajı",
|
159 |
+
"fallback_error_prompt": "Hata mesajı"
|
160 |
+
}
|
161 |
+
```
|
162 |
|
163 |
+
### Parameter Yapısı
|
164 |
+
```json
|
165 |
+
{
|
166 |
+
"name": "param_name",
|
167 |
+
"caption": [
|
168 |
+
{
|
169 |
+
"locale_code": "tr",
|
170 |
+
"caption": "Parametre Başlığı"
|
171 |
+
}
|
172 |
+
],
|
173 |
+
"type": "str|int|float|bool|date",
|
174 |
+
"required": true,
|
175 |
+
"variable_name": "variable_name",
|
176 |
+
"extraction_prompt": "Parametre çıkarma yönergesi",
|
177 |
+
"validation_regex": "^pattern$",
|
178 |
+
"invalid_prompt": "Geçersiz değer mesajı",
|
179 |
+
"type_error_prompt": "Tip hatası mesajı"
|
180 |
+
}
|
181 |
+
```
|
182 |
+
|
183 |
+
### API Yapısı
|
184 |
+
```json
|
185 |
+
{
|
186 |
+
"name": "api_name",
|
187 |
+
"description": "{{variables.x}} için işlem açıklaması",
|
188 |
+
"url": "https://api-endpoint",
|
189 |
+
"method": "GET|POST|PUT|DELETE",
|
190 |
+
"headers": "{}", // JSON string
|
191 |
+
"body_template": "{}", // JSON string
|
192 |
+
"timeout_seconds": 10,
|
193 |
+
"retry": {
|
194 |
+
"max_attempts": 3,
|
195 |
+
"backoff_seconds": 2,
|
196 |
+
"strategy": "static|exponential"
|
197 |
+
},
|
198 |
+
"auth": {
|
199 |
+
"enabled": true,
|
200 |
+
"token_endpoint": "https://auth-endpoint",
|
201 |
+
"response_token_path": "access_token",
|
202 |
+
"token_request_body": "{}",
|
203 |
+
"token_refresh_endpoint": null,
|
204 |
+
"token_refresh_body": "{}"
|
205 |
+
},
|
206 |
+
"response_mappings": [
|
207 |
+
{
|
208 |
+
"variable_name": "result",
|
209 |
+
"caption": "Sonuç",
|
210 |
+
"type": "str",
|
211 |
+
"json_path": "$.data.result"
|
212 |
+
}
|
213 |
+
],
|
214 |
+
"response_prompt": "Response insanileştirme yönergesi",
|
215 |
+
"deleted": false,
|
216 |
+
"created_date": "2024-01-01T00:00:00Z",
|
217 |
+
"created_by": "username"
|
218 |
+
}
|
219 |
+
```
|
220 |
|
221 |
+
## 🔄 Session ve State Yönetimi
|
222 |
|
223 |
+
### Session Özellikleri
|
224 |
+
```python
|
225 |
+
class Session:
|
226 |
+
session_id: str
|
227 |
+
project_name: str
|
228 |
+
version_number: int
|
229 |
+
version_config: VersionConfig
|
230 |
+
|
231 |
+
# State machine
|
232 |
+
state: str # idle | await_param | call_api | humanize
|
233 |
+
last_intent: str | None
|
234 |
+
awaiting_parameters: List[str]
|
235 |
+
missing_ask_count: int
|
236 |
+
|
237 |
+
# Data storage
|
238 |
+
variables: Dict[str, str]
|
239 |
+
auth_tokens: Dict[str, Dict]
|
240 |
+
chat_history: List[Dict[str, str]]
|
241 |
+
|
242 |
+
# Smart parameter tracking
|
243 |
+
asked_parameters: Dict[str, int]
|
244 |
+
unanswered_parameters: List[str]
|
245 |
+
parameter_ask_rounds: int
|
246 |
+
|
247 |
+
# Real-time support
|
248 |
+
is_realtime_session: bool
|
249 |
+
active_websocket: Any
|
250 |
+
```
|
251 |
|
252 |
+
### State Machine Flow
|
253 |
+
```
|
254 |
+
start_session → welcome_prompt
|
255 |
+
↓
|
256 |
+
idle ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
|
257 |
+
↓ ↑
|
258 |
+
detect_intent → collect_params → approval? → call_api → humanize
|
259 |
+
↑ ↓
|
260 |
+
← await_param ←
|
261 |
+
```
|
262 |
|
263 |
+
## 🔐 Onay Mekanizması
|
264 |
|
265 |
+
Intent'te `requiresApproval: true` olduğunda:
|
266 |
|
267 |
+
1. **Otomatik parametre ekleme**: `is_approved` parametresi dinamik olarak eklenir
|
268 |
+
2. **Onay sorusu oluşturma**: API description'daki placeholder'lar değiştirilir
|
269 |
+
3. **Onay kontrolü**:
|
270 |
+
- Onay verilirse → API çağrısı
|
271 |
+
- Onay verilmezse → İşlem iptali
|
272 |
|
273 |
+
## 🌍 Multi-Language Destek
|
|
|
|
|
274 |
|
275 |
+
### Locale Yönetimi
|
276 |
+
- Project seviyesinde `default_locale` ve `supported_locales`
|
277 |
+
- LocalizedExample ve LocalizedCaption yapıları
|
278 |
+
- Locale JSON dosyaları (`tr.json`, `en.json`, vb.)
|
|
|
279 |
|
280 |
+
### LocaleManager
|
281 |
+
```python
|
282 |
+
# Locale bilgilerini yönetir
|
283 |
+
LocaleManager.get_locale("tr")
|
284 |
+
LocaleManager.format_date(date, "tr")
|
285 |
+
LocaleManager.parse_date_expression("yarın", "tr")
|
286 |
+
LocaleManager.format_number(1234.56, "tr")
|
287 |
+
```
|
288 |
|
289 |
+
## 🎤 TTS/STT Entegrasyonu
|
290 |
+
|
291 |
+
### TTS Providers
|
292 |
+
- **ElevenLabs**: Yüksek kaliteli, çok dilli
|
293 |
+
- **Blaze**: Alternatif TTS
|
294 |
+
- **No TTS**: Devre dışı
|
295 |
+
|
296 |
+
### STT Providers
|
297 |
+
- **Google**: Cloud Speech-to-Text
|
298 |
+
- **Azure**: Azure Speech Services
|
299 |
+
- **Flicker**: Alternatif STT
|
300 |
+
- **No STT**: Devre dışı
|
301 |
+
|
302 |
+
### Real-time Features
|
303 |
+
- WebSocket-based audio streaming
|
304 |
+
- Voice Activity Detection (VAD)
|
305 |
+
- Noise reduction
|
306 |
+
- Interim results
|
307 |
+
|
308 |
+
## 🚀 LLM Provider Desteği
|
309 |
+
|
310 |
+
### Spark
|
311 |
+
- YTU Cosmos modelleri
|
312 |
+
- HuggingFace Cloud veya on-premise
|
313 |
+
- Custom fine-tuning desteği
|
314 |
+
|
315 |
+
### GPT-4o / GPT-4o-mini
|
316 |
+
- OpenAI API entegrasyonu
|
317 |
+
- Temperature ve max_tokens kontrolü
|
318 |
+
- Maliyet optimizasyonu
|
319 |
+
|
320 |
+
### Provider Seçimi
|
321 |
+
```python
|
322 |
+
# chat_handler.py
|
323 |
+
if llm_provider.name == "spark":
|
324 |
+
llm = SparkLLM(endpoint, token)
|
325 |
+
elif llm_provider.name.startswith("gpt4o"):
|
326 |
+
llm = GPT4oLLM(api_key, model)
|
327 |
+
```
|
328 |
|
329 |
+
## 📡 API Yönetimi
|
330 |
+
|
331 |
+
### API Çağrı Süreci
|
332 |
+
1. **Variable substitution**: `{{variables.xxx}}` → gerçek değerler
|
333 |
+
2. **Auth token yönetimi**: Otomatik token alma ve yenileme
|
334 |
+
3. **Retry logic**: Configurable retry stratejisi
|
335 |
+
4. **Response mapping**: JSON path ile veri çıkarma
|
336 |
+
5. **Response humanization**: LLM ile insanileştirme
|
337 |
+
|
338 |
+
### Auth Mekanizması
|
339 |
+
```python
|
340 |
+
# Token alma ve cache'leme
|
341 |
+
if api.auth.enabled:
|
342 |
+
token = get_or_refresh_token(api, session)
|
343 |
+
headers["Authorization"] = f"Bearer {token}"
|
344 |
+
```
|
345 |
|
346 |
+
## 🔒 Güvenlik
|
347 |
|
348 |
+
### Encryption
|
349 |
+
- API key'ler `enc:` prefix ile şifrelenmiş saklanır
|
350 |
+
- Fernet encryption (symmetric)
|
351 |
+
- Environment variable: `FERNET_KEY`
|
|
|
|
|
352 |
|
353 |
+
### Authentication
|
354 |
+
- JWT-based session yönetimi
|
355 |
+
- Bcrypt password hashing
|
356 |
+
- Session timeout kontrolü
|
357 |
|
358 |
+
### Race Condition Koruması
|
359 |
+
- `last_update_date` ile optimistic locking
|
360 |
+
- Thread-safe session store
|
361 |
+
- Concurrent update kontrolü
|
362 |
|
363 |
+
## 📊 Monitoring ve Logging
|
364 |
|
365 |
+
### Activity Log
|
|
|
366 |
```json
|
367 |
{
|
368 |
+
"timestamp": "2024-01-01T00:00:00Z",
|
369 |
+
"username": "admin",
|
370 |
+
"action": "CREATE_PROJECT",
|
371 |
+
"entity_type": "project",
|
372 |
+
"entity_id": 1,
|
373 |
+
"entity_name": "project_name",
|
374 |
+
"details": "Additional info"
|
|
|
375 |
}
|
376 |
```
|
377 |
|
378 |
+
### Log Actions
|
379 |
+
- Project CRUD: CREATE, UPDATE, DELETE, ENABLE, DISABLE
|
380 |
+
- Version: CREATE, UPDATE, PUBLISH, DELETE
|
381 |
+
- API: CREATE, UPDATE, DELETE
|
382 |
+
- Environment: UPDATE_ENVIRONMENT
|
383 |
+
- Import/Export: IMPORT_PROJECT, EXPORT_PROJECT
|
384 |
|
385 |
+
## 🧪 Test ve Development
|
386 |
|
387 |
+
### Mock Backend
|
388 |
+
- Scenario-based testing
|
389 |
+
- Configurable responses
|
390 |
+
- Error simulation
|
391 |
|
392 |
+
### Debug Features
|
393 |
+
- Detailed timestamped logging
|
394 |
+
- Request/Response tracking
|
395 |
+
- Performance metrics
|
396 |
+
|
397 |
+
## 🔄 Import/Export
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
|
399 |
+
### Project Export Format
|
400 |
```json
|
401 |
{
|
402 |
+
"name": "project_name",
|
403 |
+
"caption": "Project Caption",
|
404 |
+
"icon": "folder",
|
405 |
+
"description": "Description",
|
406 |
+
"default_locale": "tr",
|
407 |
+
"supported_locales": ["tr", "en"],
|
408 |
+
"versions": [
|
409 |
+
{
|
410 |
+
"caption": "v1",
|
411 |
+
"general_prompt": "...",
|
412 |
+
"llm": {...},
|
413 |
+
"intents": [...]
|
414 |
+
}
|
415 |
+
]
|
416 |
}
|
417 |
```
|
418 |
|
419 |
+
## 🚦 Production Deployment
|
420 |
+
|
421 |
+
### Docker Support
|
422 |
+
- HuggingFace Spaces uyumlu
|
423 |
+
- Health check endpoint
|
424 |
+
- Environment-based configuration
|
425 |
+
- Volume mount için permission handling
|
426 |
+
|
427 |
+
### Environment Variables
|
428 |
+
```bash
|
429 |
+
FERNET_KEY=... # Encryption key
|
430 |
+
SPARK_TOKEN=... # Spark API token
|
431 |
+
OPENAI_API_KEY=... # GPT-4o key
|
432 |
+
GOOGLE_APPLICATION_CREDENTIALS=... # STT credentials
|
433 |
+
HF_HOME=/app/.cache # HuggingFace cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
|
436 |
+
### Health Check
|
437 |
+
```python
|
438 |
+
@app.get("/")
|
439 |
+
def health():
|
440 |
+
return {"status": "ok"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
|
442 |
+
# Hugging Face için daemon thread
|
443 |
+
threading.Thread(target=run_health_server, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
```
|
flare-ui-tasarim.md
CHANGED
@@ -1,632 +1,605 @@
|
|
1 |
-
# Flare Administration UI - Tasarım Dokümanı
|
2 |
|
3 |
-
## 📌
|
4 |
|
5 |
-
Flare Administration UI
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
Flare Admin, Flare backend servisi üzerinden Spark veya GPT-4o ile entegre çalışır. Ayrıca TTS (Text-to-Speech) ve STT (Speech-to-Text) motorları ile sesli etkileşim desteği sunar.
|
12 |
-
|
13 |
-
## Genel Kurallar
|
14 |
-
|
15 |
-
Flare Admin, login ekranıyla başlar. Kullanıcı login olduktan sonra tanım ekranları görüntülenir.
|
16 |
-
|
17 |
-
Tanım ekranları, tab window'lar şeklinde gruplandırılmıştır. Her tab'da birbiriyle alakalı işlemler yapılır.
|
18 |
-
|
19 |
-
Tüm hatalı işlemler, işlemin yapıldığı ekranın alt kısmında kırmızı font ile uyarı şeklinde görüntülenir ve uyarı 5 sn sonra kaybolur.
|
20 |
-
|
21 |
-
Boolean alanlar ekranda (hem input olarak, hem de tablo üzerinde) checkbox olarak görüntülenir.
|
22 |
-
|
23 |
-
Silme işlemleri öncesinde, silinecek nesnenin diğer nesneler altında kullanımda olup olmadığı kontrol edilir. Eğer kullanımdaysa, silinmesine izin verilmez ve hangi nesneler tarafından kullanıldığını içeren bir mesaj ve hata kodu ile döndürülür. Kullanımda olmayan nesneyi silme öncesinde açılacak bir dialog'da kullanıcıdan onay alınır. Onayın ardından silme işlemi yapılır.
|
24 |
-
|
25 |
-
Nesnenin **deleted** alanı varsa silme işlemi fiziksel olarak yapılmaz, deleted=true olarak değiştirilir.
|
26 |
-
|
27 |
-
Ortam çok kullanıcılı olduğundan kayıt düzenleme işlemlerinde race condition kontrolü yapılır. Bunun için service_config.jsonc içinde config, project, version ve api nesnelerine **last_update_date** alanı eklenir.
|
28 |
-
|
29 |
-
Kullanıcı, düzenlemek için nesneyi ekrana yüklediğinde nesne içindeki bu değeri de yükler. Save butonuna bastığında backend'e bu değeri de gönderir ve backend kayıt öncesi bu değerin service_config.jsonc'deki ilgili nesnedeki değerle aynı olup olmadığını kontrol eder, aynı ise kaydı yapar ve kaydederken bu değeri o andaki tarih-saat-dakika-saniye-milisaniye değeri ile günceller.
|
30 |
-
|
31 |
-
Eğer bir başka kullanıcı aynı kaydı düzenliyorsa ve ilk kullanıcıdan sonra save'e bastıysa dosyadaki bu değer değişmiş olacağından backend kayda izin vermez ve "Kayıt başka kullanıcı tarafından düzenlendi. Lütfen tekrar yükleyin." tarzı bir uyarı ile birlikte bir hata kodu döndürür.
|
32 |
-
|
33 |
-
Bir diğer durum da, kullanıcı tarafından düzenlenen kaydın, bu kullanıcı kaydetmeden önce başka bir kullanıcı tarafından silinmiş olması durumudur. Backend kayıt öncesi dosyada bu nesneyi bulamazsa "Kayıt başka kullanıcı tarafından silindi." gibi bir uyarı ve bir hata kodu döndürür, kayda izin vermez.
|
34 |
-
|
35 |
-
## Auto-save ve Undo/Redo Mekanizması
|
36 |
-
|
37 |
-
- Published olmayan version'lar üzerinde çalışırken her 30 saniyede bir otomatik draft kayıt yapılır
|
38 |
-
- Son 10 işlem için undo/redo desteği (Ctrl+Z / Ctrl+Y)
|
39 |
-
- Draft kayıtlar drafts/ klasöründe tutulur ve UI açıldığında "Recover unsaved changes?" dialog'u gösterilir
|
40 |
-
|
41 |
-
## Klavye Kısayolları
|
42 |
-
|
43 |
-
- Ctrl+S: Save
|
44 |
-
- Ctrl+N: New (context'e göre project/version/intent)
|
45 |
-
- Ctrl+F: Search/Filter
|
46 |
-
- Ctrl+D: Duplicate
|
47 |
-
- Esc: Cancel/Close dialog
|
48 |
-
|
49 |
-
## Flare Backend Düzenlemeleri
|
50 |
-
|
51 |
-
Flare backend'de Flare Admin UI işleyişi için bazı eklemeler yapılması gerekiyor.
|
52 |
-
|
53 |
-
### Eklenecek endpoint'ler:
|
54 |
-
|
55 |
-
#### Temel CRUD Endpoint'leri
|
56 |
-
|
57 |
-
- POST /api/login - Kullanıcı girişi ve token üretimi
|
58 |
-
- GET /api/environment - Environment bilgileri alma
|
59 |
-
- PUT /api/environment - Environment bilgilerini kaydetme
|
60 |
-
- GET /api/projects - Proje listeleme (pagination, filter, sort destekli)
|
61 |
-
- POST /api/projects - Yeni proje oluşturma: Yeni proje oluşturulduğunda backend, version_id_counter alanını **1**'e ayarlar ve otomatik **Version 1** kaydını ekler. Frontend ekstra çağrı yapmaz.
|
62 |
-
- PUT /api/projects/{id} - Mevcut projeyi düzenleme
|
63 |
-
- DELETE /api/projects/{id} - Mevcut projeyi silme
|
64 |
-
- PATCH /api/projects/{id}/toggle - Proje enable/disable
|
65 |
-
- POST /api/projects/{id}/versions - Proje versiyonu oluşturma
|
66 |
-
- DELETE /api/projects/{id}/versions/{version_id} - Versiyon silme
|
67 |
-
- PUT /api/projects/{id}/versions/{version_id} - Versiyon düzenleme
|
68 |
-
- POST /api/projects/{id}/versions/{version_id}/publish - Versiyon yayınlama
|
69 |
-
- GET /api/apis - API listeleme
|
70 |
-
- POST /api/apis - Yeni API ekleme
|
71 |
-
- PUT /api/apis/{name} - Mevcut API'yi düzenleme
|
72 |
-
- DELETE /api/apis/{name} - Mevcut API'yi silme
|
73 |
-
|
74 |
-
#### Spark Integration Endpoint'leri
|
75 |
-
|
76 |
-
- POST /api/spark/startup - Projeyi Spark'a yükle
|
77 |
-
- GET /api/spark/projects - Spark proje listesi
|
78 |
-
- POST /api/spark/project/enable - Projeyi aktifleştir
|
79 |
-
- POST /api/spark/project/disable - Projeyi devre dışı bırak
|
80 |
-
- DELETE /api/spark/project/{name} - Projeyi Spark'tan sil
|
81 |
-
|
82 |
-
#### Chat Endpoint'leri
|
83 |
-
|
84 |
-
- GET /api/projects/names - Chat için enabled proje listesi
|
85 |
-
- POST /api/start_session - Chat session başlat
|
86 |
-
- POST /api/chat - Mesaj gönder/al (Header: X-Session-ID)
|
87 |
-
|
88 |
-
#### TTS/STT Endpoint'leri
|
89 |
-
|
90 |
-
- POST /api/tts/generate - Text'ten ses üret
|
91 |
-
- GET /api/tts/voices - Desteklenen ses listesi
|
92 |
-
- POST /api/stt/transcribe - Sesten text'e dönüştür (gelecek özellik)
|
93 |
-
|
94 |
-
#### Ek Yardımcı Endpoint'ler
|
95 |
-
|
96 |
-
- POST /api/validate/regex - Regex pattern validasyonu
|
97 |
-
- POST /api/apis/test - API endpoint test etme
|
98 |
-
- GET /api/projects/{id}/versions/diff - Version karşılaştırma
|
99 |
-
- POST /api/projects/{id}/intents/bulk-delete - Toplu intent silme
|
100 |
-
- GET /api/activity-log - Aktivite logları
|
101 |
-
- POST /api/projects/import - Proje import
|
102 |
-
- GET /api/projects/{id}/export - Proje export
|
103 |
-
- POST /api/test/run-all - Tüm testleri çalıştır
|
104 |
-
- GET /api/test/status - Test durumu sorgula
|
105 |
-
|
106 |
-
### Service_config.jsonc düzenlemeleri:
|
107 |
-
|
108 |
-
```jsonc
|
109 |
{
|
110 |
-
"
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
// TTS/STT Configuration - Yeni
|
120 |
-
"tts_engine": "no_tts", // "no_tts" | "elevenlabs" | "blaze"
|
121 |
-
"tts_engine_api_key": "enc:...", // Şifrelenmiş TTS API key
|
122 |
-
"stt_engine": "no_stt", // "no_stt" | "elevenlabs" | "flicker"
|
123 |
-
"stt_engine_api_key": "enc:..." // Şifrelenmiş STT API key
|
124 |
-
},
|
125 |
-
|
126 |
-
"projects": [{
|
127 |
-
// Mevcut alanlar...
|
128 |
-
"icon": "folder", // Yeni
|
129 |
-
"description": "", // Yeni
|
130 |
-
"default_language": "tr", // Yeni
|
131 |
-
"supported_languages": ["tr"], // Yeni
|
132 |
-
"timezone": "Europe/Istanbul", // Yeni
|
133 |
-
"region": "tr-TR", // Yeni
|
134 |
-
"version_id_counter": 1, // Yeni
|
135 |
-
"last_update_date": "2025-06-08T12:00:00.000Z", // Yeni
|
136 |
-
"last_update_user": "admin", // Yeni
|
137 |
-
"deleted": false, // Yeni
|
138 |
-
"created_date": "2025-06-08T12:00:00.000Z", // Yeni
|
139 |
-
"created_by": "admin", // Yeni
|
140 |
-
|
141 |
-
"versions": [{
|
142 |
-
// Mevcut alanlar...
|
143 |
-
"llm": {
|
144 |
-
// Spark mode için:
|
145 |
-
"repo_id": "model-repo/id",
|
146 |
-
"generation_config": {},
|
147 |
-
"use_fine_tune": false,
|
148 |
-
"fine_tune_zip": "",
|
149 |
-
|
150 |
-
// GPT-4o mode için (work_mode = "gpt4o" veya "gpt4o-mini" olduğunda kullanılır):
|
151 |
-
"gpt_model": "gpt-4o", // "gpt-4o" | "gpt-4o-mini"
|
152 |
-
"gpt_temperature": 0.3, // 0-2 arası
|
153 |
-
"gpt_max_tokens": 512 // Maximum response token sayısı
|
154 |
-
},
|
155 |
-
"last_update_date": "2025-06-08T12:00:00.000Z", // Yeni
|
156 |
-
"last_update_user": "admin", // Yeni
|
157 |
-
"deleted": false, // Yeni
|
158 |
-
"created_date": "2025-06-08T12:00:00.000Z", // Yeni
|
159 |
-
"created_by": "admin", // Yeni
|
160 |
-
"publish_date": null, // Yeni
|
161 |
-
"published_by": null // Yeni
|
162 |
-
}]
|
163 |
-
}],
|
164 |
-
|
165 |
-
"apis": [{
|
166 |
-
// Mevcut alanlar...
|
167 |
-
"response_mappings": [ // Yeni
|
168 |
-
{
|
169 |
-
"variable_name": "booking_id",
|
170 |
-
"type": "str",
|
171 |
-
"json_path": "confirmation.id"
|
172 |
-
}
|
173 |
-
],
|
174 |
-
"last_update_date": "2025-06-08T12:00:00.000Z", // Yeni
|
175 |
-
"last_update_user": "admin", // Yeni
|
176 |
-
"deleted": false, // Yeni
|
177 |
-
"created_date": "2025-06-08T12:00:00.000Z", // Yeni
|
178 |
-
"created_by": "admin" // Yeni
|
179 |
-
}],
|
180 |
-
|
181 |
-
// Yeni: Activity log
|
182 |
-
"activity_log": [{
|
183 |
-
"id": 1,
|
184 |
-
"timestamp": "2025-06-08T12:00:00.000Z",
|
185 |
-
"user": "admin",
|
186 |
-
"action": "CREATE_PROJECT",
|
187 |
-
"entity_type": "project",
|
188 |
-
"entity_id": 1,
|
189 |
-
"entity_name": "airline_agent",
|
190 |
-
"details": "Created new project"
|
191 |
-
}]
|
192 |
}
|
193 |
```
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
- New Password (maskeli)
|
203 |
-
- New Password (tekrar, maskeli)
|
204 |
-
- Password Strength Indicator: Şifre girilirken güvenlik seviyesini gösterir (Weak/Medium/Strong)
|
205 |
-
- Save butonu
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
### 2. Environment Tab'ı
|
210 |
-
|
211 |
-
Bu tab'da aşağıdaki alanlar bulunur:
|
212 |
-
|
213 |
-
- **Work Mode**: Seçenekleri **hfcloud**, **cloud**, **on-premise**, **gpt4o** ve **gpt4o-mini** olan bir combo. Zorunlu.
|
214 |
-
- **Cloud Token / OpenAI API Key** (maskeli):
|
215 |
-
- Work Mode **on-premise** seçildiğinde disable olur.
|
216 |
-
- Work Mode **gpt4o** veya **gpt4o-mini** seçildiğinde label "OpenAI API Key" olarak değişir
|
217 |
-
- Diğer modlarda "Cloud Token" olarak görünür
|
218 |
-
- **Spark Endpoint**: URL formatında. GPT-4o mode hariç zorunlu. Yanında "Test Connection" butonu. GPT-4o seçildiğinde disable olur.
|
219 |
-
- **TTS Engine**: Seçenekleri **no_tts**, **elevenlabs**, **blaze** olan combo.
|
220 |
-
- **TTS API Key** (maskeli): TTS Engine **no_tts** dışında bir değer seçildiğinde zorunlu olur.
|
221 |
-
- **STT Engine**: Seçenekleri **no_stt**, **elevenlabs**, **flicker** olan combo.
|
222 |
-
- **STT API Key** (maskeli): STT Engine **no_stt** dışında bir değer seçildiğinde zorunlu olur.
|
223 |
-
- **Internal System Prompt**: Expansion panel içinde multi-line textarea. LLM'in tüm projeler için kullanacağı temel kuralları içerir. Placeholder'lar:
|
224 |
-
- <intent names>: Runtime'da intent listesiyle değiştirilir
|
225 |
-
- <intent captions>: Intent caption'larıyla değiştirilir
|
226 |
-
- <project language>: Proje diline göre değiştirilir
|
227 |
-
- Save butonu
|
228 |
-
- Reload from Spark butonu: Spark'tan güncel config'i çeker (GPT mode'da disable)
|
229 |
-
|
230 |
-
**GPT-4o Mode Uyarısı**: Work mode GPT-4o veya GPT-4o-mini seçildiğinde bir info alert gösterilir:
|
231 |
```
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
236 |
```
|
237 |
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
256 |
|
257 |
-
**
|
258 |
-
-
|
259 |
-
-
|
260 |
-
-
|
261 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
-
**
|
268 |
-
-
|
269 |
-
-
|
270 |
-
-
|
271 |
-
-
|
272 |
-
- View: List/Card view toggle
|
273 |
|
274 |
-
|
275 |
-
```
|
276 |
-
┌─────────────────────────────────────┐
|
277 |
-
│ 🛩️ airline_agent │
|
278 |
-
│ Havayolu Müşteri Temsilcisi │
|
279 |
-
│ Language: Turkish (tr) │
|
280 |
-
│ Versions: 3 (1 published) │
|
281 |
-
│ Status: ✓ Enabled │
|
282 |
-
│ Last update: 2 hours ago │
|
283 |
-
│ [Edit] [Versions] [Export] [⚙️] │
|
284 |
-
└────────────────────────────────────┘
|
285 |
-
```
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
Flare chat sistemini test etmek için kullanılır.
|
290 |
-
|
291 |
-
**İşleyiş:**
|
292 |
-
1. **Project Selection**: Enabled ve published version'u olan projeler listelenir
|
293 |
-
2. **TTS Option**: "Use TTS" checkbox'ı ile sesli yanıt özelliği aktifleştirilebilir (TTS konfigüre edilmişse)
|
294 |
-
3. **Start Chat**: Session başlatır, session_id alır
|
295 |
-
4. **Chat Interface**:
|
296 |
-
- Mesaj history'si
|
297 |
-
- Input alanı
|
298 |
-
- Send butonu
|
299 |
-
- Session bilgileri (ID, project)
|
300 |
-
- TTS enabled ise her bot mesajı için play butonu
|
301 |
-
- Ses oynatılırken waveform visualizasyon
|
302 |
-
5. **End Session**: Chat'i sonlandırır
|
303 |
-
|
304 |
-
**Özellikler:**
|
305 |
-
- Real-time mesajlaşma
|
306 |
-
- Session takibi
|
307 |
-
- Auto-scroll
|
308 |
-
- Error handling
|
309 |
-
- Loading states
|
310 |
-
- TTS desteği (konfigüre edilmişse)
|
311 |
-
- Audio waveform visualization
|
312 |
-
- Otomatik ses oynatma (opsiyonel)
|
313 |
-
|
314 |
-
### 6. Spark Integration Tab'ı
|
315 |
-
|
316 |
-
Bu tab'da Spark servisi ile doğrudan etkileşim sağlanır. **GPT-4o mode'da bu tab disable olur ve bir bilgi mesajı gösterilir.**
|
317 |
-
|
318 |
-
**GPT-4o Mode'da Görünüm:**
|
319 |
```
|
320 |
-
|
321 |
-
│
|
|
|
|
|
|
|
322 |
│ │
|
323 |
-
│
|
324 |
-
│
|
|
|
|
|
325 |
│ │
|
326 |
-
│
|
327 |
-
│
|
328 |
-
|
|
|
|
|
329 |
```
|
330 |
|
331 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
|
333 |
-
|
334 |
-
-
|
335 |
-
-
|
|
|
|
|
|
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
|
344 |
-
**
|
345 |
-
-
|
346 |
-
-
|
347 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
349 |
-
|
350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
|
352 |
-
**
|
353 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
```
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
│ ✓ Create new project - 340ms │
|
398 |
-
│ ✗ Delete API in use - Expected behavior │
|
399 |
-
│ ⏳ Testing LLM connection... │
|
400 |
-
│ │
|
401 |
-
│ Progress: ████████░░ 80% (48/60) │
|
402 |
-
│ Passed: 45 | Failed: 3 | Running: 5 │
|
403 |
-
└─────────────────────────────────────────────┤
|
404 |
```
|
405 |
|
406 |
-
|
407 |
-
- Test adı ve açıklaması
|
408 |
-
- Çalışma süresi
|
409 |
-
- Hata durumunda detaylı log
|
410 |
-
- "Re-run" butonu
|
411 |
|
412 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
```
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
├─────────────────────────────────────┤
|
422 |
-
│ 15 min ago │
|
423 |
-
│ 👤 user1 updated flight_info_api │
|
424 |
-
├─────────────────────────────────────┤
|
425 |
-
│ 1 hour ago │
|
426 |
-
│ 👤 admin created new project │
|
427 |
-
│ hotel_booking │
|
428 |
-
├─────────────────────────────────────┤
|
429 |
-
│ [View All Activities] │
|
430 |
-
└─────────────────────────────────────┘
|
431 |
```
|
432 |
|
433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
|
435 |
-
|
436 |
|
437 |
-
|
|
|
|
|
|
|
438 |
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
|
446 |
-
|
447 |
-
-
|
448 |
-
-
|
449 |
-
-
|
450 |
-
- Config değişkenleri (work_mode, vb.)
|
451 |
-
- Tıklanabilir chip'ler ile kolay ekleme
|
452 |
|
453 |
-
|
454 |
-
- Numeric değişkenler için akıllı validation
|
455 |
-
- Template variable type checking
|
456 |
-
- Syntax highlighting
|
457 |
|
458 |
-
|
459 |
-
-
|
460 |
-
-
|
461 |
-
-
|
462 |
-
- Response preview
|
463 |
|
464 |
-
###
|
|
|
|
|
|
|
465 |
|
466 |
-
|
467 |
-
- Icon: Material icon seçimi (folder, work, shopping_cart, vb.)
|
468 |
-
- Description: Proje açıklaması
|
469 |
-
- Default Language: Varsayılan dil (tr, en, de, fr, es)
|
470 |
-
- Supported Languages: Desteklenen diller (çoklu seçim)
|
471 |
-
- Timezone: Saat dilimi (Europe/Istanbul, vb.)
|
472 |
-
- Region: Bölge kodu (tr-TR, vb.)
|
473 |
|
474 |
-
###
|
|
|
|
|
|
|
475 |
|
476 |
-
|
|
|
|
|
|
|
477 |
|
478 |
-
|
479 |
|
480 |
-
|
481 |
-
```
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
│ Max Tokens: │
|
492 |
-
│ [512 ] │
|
493 |
-
│ │
|
494 |
-
│ ℹ️ Cost estimate: ~$0.02/request │
|
495 |
-
└─────────────────────────────────────┘
|
496 |
```
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
### Edit Parameter Dialog
|
508 |
-
|
509 |
-
Date type desteği eklendi:
|
510 |
-
- Type combo'suna "date" seçeneği
|
511 |
-
- Date formatı: YYYY-MM-DD (ISO format)
|
512 |
-
- Türkçe tarih ifadeleri için özel extraction prompt'lar
|
513 |
-
|
514 |
-
### Version Comparison Dialog
|
515 |
-
|
516 |
-
[Mevcut içerik korunacak, değişiklik yok]
|
517 |
-
|
518 |
-
## Flare Admin Test Planı
|
519 |
|
520 |
-
|
521 |
-
|
522 |
-
###
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
-
|
532 |
-
-
|
533 |
-
-
|
534 |
-
-
|
535 |
-
|
536 |
-
**3. Spark Tab Behavior:**
|
537 |
-
- GPT-4o mode'da Spark tab'ın disable olduğunu kontrol et
|
538 |
-
- Bilgi mesajının göründüğünü doğrula
|
539 |
-
|
540 |
-
**4. Chat Testing:**
|
541 |
-
- GPT-4o kullanan proje ile chat başlat
|
542 |
-
- Intent detection test et
|
543 |
-
- Parameter extraction test et
|
544 |
-
- Response kalitesini değerlendir
|
545 |
-
|
546 |
-
**5. Cost Tracking:**
|
547 |
-
- Chat sonrası tahmini maliyet gösterimini kontrol et
|
548 |
-
- Token kullanım bilgilerini doğrula
|
549 |
-
|
550 |
-
### TTS/STT Test Senaryoları:
|
551 |
-
|
552 |
-
**1. TTS Configuration:**
|
553 |
-
- TTS Engine'i ElevenLabs'e ayarla
|
554 |
-
- API key gir ve save et
|
555 |
-
- Chat'te TTS özelliğini aktifle
|
556 |
-
|
557 |
-
**2. Audio Generation:**
|
558 |
-
- Bot yanıtlarının seslendirildiğini kontrol et
|
559 |
-
- Play butonu işlevselliği
|
560 |
-
- Waveform visualization
|
561 |
-
- Ses kalitesi kontrolü
|
562 |
-
|
563 |
-
**3. Multi-Engine Support:**
|
564 |
-
- Farklı TTS motorları arasında geçiş
|
565 |
-
- API key güvenliği
|
566 |
-
- Hata durumlarının ele alınması
|
567 |
-
|
568 |
-
### Multi-Provider Switching:
|
569 |
-
|
570 |
-
**1. Mode Değişimi:**
|
571 |
-
- Spark → GPT-4o → Spark geçişleri yap
|
572 |
-
- Her geçişte config'lerin korunduğunu kontrol et
|
573 |
-
- Token/key bilgilerinin şifreli kaldığını doğrula
|
574 |
-
|
575 |
-
**2. Project Compatibility:**
|
576 |
-
- Aynı projeyi farklı modlarda test et
|
577 |
-
- Intent ve parameter mantığının tutarlı çalıştığını doğrula
|
578 |
-
|
579 |
-
## Güvenlik ve Performans
|
580 |
-
|
581 |
-
### Token Yönetimi:
|
582 |
-
- SPARK_TOKEN environment variable'dan alınır
|
583 |
-
- OPENAI_API_KEY cloud_token alanında şifrelenmiş saklanır
|
584 |
-
- TTS/STT API key'ler şifrelenmiş saklanır
|
585 |
-
- Tüm LLM/TTS/STT isteklerinde uygun Authorization header
|
586 |
-
- Token rotation desteği
|
587 |
-
|
588 |
-
### GPT-4o Özel Güvenlik:
|
589 |
-
- API key asla plain text olarak loglanmaz
|
590 |
-
- Rate limit handling
|
591 |
-
- Cost monitoring ve alerting
|
592 |
-
- Quota management
|
593 |
-
|
594 |
-
### TTS Güvenlik:
|
595 |
-
- API key şifreleme
|
596 |
-
- Rate limiting
|
597 |
-
- Concurrent request kontrolü
|
598 |
-
- Audio dosya boyutu limitleri
|
599 |
-
|
600 |
-
### Race Condition Handling:
|
601 |
-
- last_update_date kontrolü tüm CRUD işlemlerinde
|
602 |
-
- Concurrent edit detection
|
603 |
-
- Optimistic locking pattern
|
604 |
-
|
605 |
-
### Session Management:
|
606 |
-
- 30 dakika inactivity timeout
|
607 |
-
- Session cleanup thread
|
608 |
-
- Memory-efficient storage
|
609 |
-
- GPT-4o için token count tracking
|
610 |
-
- TTS için audio cache yönetimi
|
611 |
-
|
612 |
-
## Teknoloji Stack
|
613 |
-
|
614 |
-
- **Frontend**: Angular 17+ (standalone components)
|
615 |
-
- **UI Framework**: Angular Material
|
616 |
-
- **State Management**: RxJS
|
617 |
-
- **Backend**: Python FastAPI
|
618 |
-
- **Authentication**: JWT
|
619 |
-
- **Database**: service_config.jsonc (document database pattern)
|
620 |
-
- **LLM Integration**:
|
621 |
-
- Spark servisi (HuggingFace)
|
622 |
-
- OpenAI API (GPT-4o, GPT-4o-mini)
|
623 |
-
- **TTS Integration**:
|
624 |
-
- ElevenLabs API
|
625 |
-
- Blaze (planned)
|
626 |
-
- **STT Integration**:
|
627 |
-
- ElevenLabs (planned)
|
628 |
-
- Flicker (planned)
|
629 |
-
- **Encryption**: Fernet (cloud_token/API key şifreleme)
|
630 |
-
- **Audio Processing**: Web Audio API (waveform visualization)
|
631 |
-
|
632 |
-
Bu güncellemelerle Flare Administration UI, hem Spark hem de GPT-4o desteği, TTS/STT entegrasyonu ile çok daha esnek ve güçlü bir orchestration platform yönetim arayüzü haline gelmiştir.
|
|
|
1 |
+
# Flare Administration UI - Güncel Tasarım Dokümanı
|
2 |
|
3 |
+
## 📌 Genel Bakış
|
4 |
|
5 |
+
Flare Administration UI, Flare platformunun web tabanlı yönetim arayüzüdür. Angular 16+ ile geliştirilmiş, Material Design prensiplerine uygun, responsive ve modern bir single-page application'dır.
|
6 |
|
7 |
+
## 🏗 Teknik Altyapı
|
8 |
|
9 |
+
### Frontend Stack
|
10 |
+
```json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
{
|
12 |
+
"framework": "Angular 16+",
|
13 |
+
"ui_library": "Angular Material",
|
14 |
+
"styling": "SCSS + Tailwind CSS (utility classes)",
|
15 |
+
"state_management": "RxJS + Services",
|
16 |
+
"http": "HttpClient with Interceptors",
|
17 |
+
"icons": "Material Icons + Lucide",
|
18 |
+
"editor": "CodeMirror (JSON/JSONC)",
|
19 |
+
"charts": "Chart.js",
|
20 |
+
"build": "Standalone Components"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
```
|
23 |
|
24 |
+
### Backend Integration
|
25 |
+
- RESTful API endpoints
|
26 |
+
- JWT Authentication (`X-Auth-Token` header)
|
27 |
+
- Real-time updates (WebSocket - planned)
|
28 |
+
- File upload/download (import/export)
|
29 |
|
30 |
+
## 🎨 UI Yapısı
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
### 1. Layout Structure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
```
|
34 |
+
┌────────────────────────────────────────────────────┐
|
35 |
+
│ Flare Admin [Environment] [User ▼] [Logout] │ <- Header
|
36 |
+
├────────────────────────────────────────────────────┤
|
37 |
+
│ Projects | APIs | Users | Logs | [Config ⚙] │ <- Tab Bar
|
38 |
+
├────────────────────────────────────────────────────┤
|
39 |
+
│ │
|
40 |
+
│ [Tab Content] │ <- Content Area
|
41 |
+
│ │
|
42 |
+
└────────────────────────────────────────────────────┘
|
43 |
```
|
44 |
|
45 |
+
### 2. Login Component
|
46 |
+
- Material card design
|
47 |
+
- Username/Password fields
|
48 |
+
- "Remember Me" checkbox
|
49 |
+
- Error handling with snackbar
|
50 |
+
- Auto-redirect after login
|
51 |
+
|
52 |
+
### 3. Projects Tab
|
53 |
+
|
54 |
+
#### Project List View
|
55 |
+
```typescript
|
56 |
+
interface ProjectDisplay {
|
57 |
+
id: number;
|
58 |
+
name: string;
|
59 |
+
caption: string;
|
60 |
+
icon: string;
|
61 |
+
enabled: boolean;
|
62 |
+
versionCount: number;
|
63 |
+
lastUpdate?: string;
|
64 |
+
}
|
65 |
+
```
|
66 |
|
67 |
+
**Features:**
|
68 |
+
- Grid layout (responsive cards)
|
69 |
+
- Quick actions: Edit, Toggle Enable, Delete
|
70 |
+
- Version count badge
|
71 |
+
- Status indicator (enabled/disabled)
|
72 |
+
- Search/Filter toolbar
|
73 |
+
- "New Project" FAB
|
74 |
+
|
75 |
+
#### Project Edit Dialog
|
76 |
+
**Tabs Structure:**
|
77 |
+
1. **Basic Info**
|
78 |
+
- Name, Caption, Icon selector
|
79 |
+
- Description (textarea)
|
80 |
+
- Locale settings (default + supported)
|
81 |
+
- Timezone and region
|
82 |
+
|
83 |
+
2. **Versions**
|
84 |
+
- Version list with status badges
|
85 |
+
- Actions: Edit, Copy, Publish, Delete
|
86 |
+
- Published versions are read-only
|
87 |
+
- Version comparison (planned)
|
88 |
+
|
89 |
+
3. **Settings**
|
90 |
+
- Advanced project settings
|
91 |
+
- Integration configs
|
92 |
+
|
93 |
+
#### Version Editor
|
94 |
+
**Split-panel Layout:**
|
95 |
+
```
|
96 |
+
┌─────────────────┬────────────────────────┐
|
97 |
+
│ Intent List │ Intent Details │
|
98 |
+
│ ─────────────── │ ─────────────────── │
|
99 |
+
│ ✓ searchFlights │ Name: searchFlights │
|
100 |
+
│ bookFlight │ Caption: Uçuş Arama │
|
101 |
+
│ checkBooking │ [Requires Approval: □] │
|
102 |
+
│ + Add Intent │ Examples: [...] │
|
103 |
+
└─────────────────┴────────────────────────┘
|
104 |
+
```
|
105 |
|
106 |
+
**Version Fields:**
|
107 |
+
- General Prompt (CodeMirror editor)
|
108 |
+
- Welcome Prompt (with LLM preview)
|
109 |
+
- LLM Configuration
|
110 |
+
- Model selection
|
111 |
+
- Generation config (expandable)
|
112 |
+
- Fine-tune settings
|
113 |
+
|
114 |
+
#### Intent Editor
|
115 |
+
**Sections:**
|
116 |
+
1. **Basic Info**
|
117 |
+
- Name (auto-slug)
|
118 |
+
- Caption
|
119 |
+
- requiresApproval toggle
|
120 |
+
- Dependencies (multi-select)
|
121 |
+
|
122 |
+
2. **Examples** (Multilingual)
|
123 |
+
```typescript
|
124 |
+
interface ExampleEditor {
|
125 |
+
locale: string;
|
126 |
+
examples: string[];
|
127 |
+
}
|
128 |
+
```
|
129 |
+
- Tab per locale
|
130 |
+
- Add/Remove examples
|
131 |
+
- Bulk import
|
132 |
+
|
133 |
+
3. **Parameters**
|
134 |
+
- Drag-drop reordering
|
135 |
+
- Inline editing
|
136 |
+
- Type-specific validators
|
137 |
+
- Multi-language captions
|
138 |
+
|
139 |
+
4. **Action**
|
140 |
+
- API selection dropdown
|
141 |
+
- API preview panel
|
142 |
+
- Test action (planned)
|
143 |
+
|
144 |
+
#### Parameter Editor Component
|
145 |
+
```html
|
146 |
+
<app-parameter-editor
|
147 |
+
[parameter]="param"
|
148 |
+
[locales]="['tr', 'en']"
|
149 |
+
[availableVariables]="variables"
|
150 |
+
(change)="onParameterChange($event)">
|
151 |
+
</app-parameter-editor>
|
152 |
+
```
|
153 |
|
154 |
+
**Features:**
|
155 |
+
- Smart variable name generation
|
156 |
+
- Type-specific controls
|
157 |
+
- Regex validator with tester
|
158 |
+
- Multi-language support
|
159 |
+
|
160 |
+
### 4. APIs Tab
|
161 |
+
|
162 |
+
#### API List
|
163 |
+
**DataTable Columns:**
|
164 |
+
- Name | URL | Method | Auth | Response | Actions
|
165 |
+
|
166 |
+
**Features:**
|
167 |
+
- Sorting and filtering
|
168 |
+
- Inline status indicators
|
169 |
+
- Batch operations
|
170 |
+
- Export to CSV
|
171 |
+
|
172 |
+
#### API Edit Dialog
|
173 |
+
**Advanced Tab Structure:**
|
174 |
+
|
175 |
+
1. **Basic Configuration**
|
176 |
+
```typescript
|
177 |
+
interface APIBasic {
|
178 |
+
name: string;
|
179 |
+
description?: string; // For approval messages
|
180 |
+
url: string;
|
181 |
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
182 |
+
}
|
183 |
+
```
|
184 |
+
|
185 |
+
2. **Headers & Body**
|
186 |
+
- JSON editor with syntax highlighting
|
187 |
+
- Variable autocomplete (`{{variables.xxx}}`)
|
188 |
+
- Template validation
|
189 |
+
- Format/Beautify button
|
190 |
+
|
191 |
+
3. **Authentication**
|
192 |
+
- Enable/Disable toggle
|
193 |
+
- Token endpoint configuration
|
194 |
+
- Token path (JSON path)
|
195 |
+
- Refresh mechanism setup
|
196 |
+
|
197 |
+
4. **Response Configuration**
|
198 |
+
- Response prompt editor
|
199 |
+
- Response mappings builder
|
200 |
+
- JSON path tester
|
201 |
+
- Sample response upload
|
202 |
+
|
203 |
+
5. **Advanced Settings**
|
204 |
+
- Timeout configuration
|
205 |
+
- Retry strategy
|
206 |
+
- Proxy settings
|
207 |
+
|
208 |
+
#### Response Mapping Builder
|
209 |
+
```typescript
|
210 |
+
interface ResponseMapping {
|
211 |
+
variable_name: string;
|
212 |
+
caption: string;
|
213 |
+
type: string;
|
214 |
+
json_path: string;
|
215 |
+
}
|
216 |
+
```
|
217 |
|
218 |
+
**Visual JSON Path Builder:**
|
219 |
+
- Upload sample response
|
220 |
+
- Click to build path
|
221 |
+
- Real-time validation
|
222 |
+
- Type inference
|
|
|
223 |
|
224 |
+
### 5. Environment Configuration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
+
#### Provider Management
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
```
|
228 |
+
┌─────────────────────────────────────────┐
|
229 |
+
│ LLM Provider │
|
230 |
+
│ ┌─────────────────────────────────────┐ │
|
231 |
+
│ │ ⚡ Spark LLM [Configure ▼] │ │
|
232 |
+
│ └─────────────────────────────────────┘ │
|
233 |
│ │
|
234 |
+
│ TTS Provider │
|
235 |
+
│ ┌─────────────────────────────────────┐ │
|
236 |
+
│ │ 🔊 ElevenLabs [Configure ▼] │ │
|
237 |
+
│ └─────────────────────────────────────┘ │
|
238 |
│ │
|
239 |
+
│ STT Provider │
|
240 |
+
│ ┌─────────────────────────────────────┐ │
|
241 |
+
│ │ 🎤 Google STT [Configure ▼] │ │
|
242 |
+
│ └─────────────────────────────────────┘ │
|
243 |
+
└─────────────────────────────────────────┘
|
244 |
```
|
245 |
|
246 |
+
**Provider Configuration:**
|
247 |
+
- Dynamic form based on provider requirements
|
248 |
+
- API key encryption indicator
|
249 |
+
- Endpoint validation
|
250 |
+
- Test connection button
|
251 |
+
|
252 |
+
#### Internal Prompt Editor
|
253 |
+
- Full-screen CodeMirror
|
254 |
+
- Placeholder hints
|
255 |
+
- Template variables sidebar
|
256 |
+
- Save with validation
|
257 |
+
|
258 |
+
### 6. Activity Logs
|
259 |
+
|
260 |
+
#### Timeline View
|
261 |
+
```typescript
|
262 |
+
interface ActivityLog {
|
263 |
+
timestamp: string;
|
264 |
+
username: string;
|
265 |
+
action: string;
|
266 |
+
entity_type: string;
|
267 |
+
entity_name?: string;
|
268 |
+
details?: string;
|
269 |
+
}
|
270 |
+
```
|
271 |
|
272 |
+
**Features:**
|
273 |
+
- Infinite scroll
|
274 |
+
- Real-time updates
|
275 |
+
- Filter by action/user/date
|
276 |
+
- Export functionality
|
277 |
+
- Detailed view dialog
|
278 |
|
279 |
+
### 7. Test Console
|
280 |
|
281 |
+
#### Chat Test Interface
|
282 |
+
```
|
283 |
+
┌─────────────────────────────────────────┐
|
284 |
+
│ Project: [pegasus_airlines ▼] v[1 ▼] │
|
285 |
+
├─────────────────────────────────────────┤
|
286 |
+
│ ┌─────────────────────────────────────┐ │
|
287 |
+
│ │ 💬 Chat Messages │ │
|
288 |
+
│ │ ───────────────────── │ │
|
289 |
+
│ │ 🤖 Hoş geldiniz! │ │
|
290 |
+
│ │ 👤 Uçuş aramak istiyorum │ │
|
291 |
+
│ │ 🤖 [Intent: searchFlights] │ │
|
292 |
+
│ │ Nereden nereye? │ │
|
293 |
+
│ └─────────────────────────────────────┘ │
|
294 |
+
│ [Message input] [🎤] [Send] │
|
295 |
+
├─────────────────────────────────────────┤
|
296 |
+
│ Session Info | Variables | API Calls │
|
297 |
+
└─────────────────────────────────────────┘
|
298 |
+
```
|
299 |
|
300 |
+
**Debug Panel Tabs:**
|
301 |
+
- Session state and variables
|
302 |
+
- Intent detection details
|
303 |
+
- API call history
|
304 |
+
- Raw LLM responses
|
305 |
+
|
306 |
+
## 🧩 Reusable Components
|
307 |
+
|
308 |
+
### 1. Multi-Language Input
|
309 |
+
```typescript
|
310 |
+
@Component({
|
311 |
+
selector: 'app-multilang-input',
|
312 |
+
template: `
|
313 |
+
<mat-tab-group>
|
314 |
+
<mat-tab *ngFor="let locale of locales">
|
315 |
+
<ng-template mat-tab-label>
|
316 |
+
{{ getLocaleName(locale) }}
|
317 |
+
</ng-template>
|
318 |
+
<mat-form-field>
|
319 |
+
<input matInput [(ngModel)]="values[locale]">
|
320 |
+
</mat-form-field>
|
321 |
+
</mat-tab>
|
322 |
+
</mat-tab-group>
|
323 |
+
`
|
324 |
+
})
|
325 |
+
export class MultilangInputComponent {
|
326 |
+
@Input() locales: string[];
|
327 |
+
@Input() values: LocalizedValue[];
|
328 |
+
@Output() change = new EventEmitter();
|
329 |
+
}
|
330 |
+
```
|
331 |
|
332 |
+
### 2. Variable Selector
|
333 |
+
```typescript
|
334 |
+
interface Variable {
|
335 |
+
name: string;
|
336 |
+
source: 'intent' | 'api' | 'system';
|
337 |
+
type: string;
|
338 |
+
}
|
339 |
+
```
|
340 |
|
341 |
+
**Features:**
|
342 |
+
- Categorized dropdown
|
343 |
+
- Search functionality
|
344 |
+
- Type indicators
|
345 |
+
- Copy to clipboard
|
346 |
+
|
347 |
+
### 3. JSON Editor Wrapper
|
348 |
+
```typescript
|
349 |
+
@Component({
|
350 |
+
selector: 'app-json-editor',
|
351 |
+
template: `
|
352 |
+
<div class="editor-container">
|
353 |
+
<codemirror
|
354 |
+
[(ngModel)]="value"
|
355 |
+
[options]="editorOptions"
|
356 |
+
(change)="onChange()">
|
357 |
+
</codemirror>
|
358 |
+
<button mat-icon-button (click)="format()">
|
359 |
+
<mat-icon>format_align_left</mat-icon>
|
360 |
+
</button>
|
361 |
+
</div>
|
362 |
+
`
|
363 |
+
})
|
364 |
+
```
|
365 |
|
366 |
+
### 4. Confirmation Dialog
|
367 |
+
```typescript
|
368 |
+
interface ConfirmData {
|
369 |
+
title: string;
|
370 |
+
message: string;
|
371 |
+
confirmText?: string;
|
372 |
+
cancelText?: string;
|
373 |
+
dangerous?: boolean;
|
374 |
+
}
|
375 |
+
```
|
376 |
|
377 |
+
## 🎯 Services Architecture
|
378 |
+
|
379 |
+
### Core Services
|
380 |
+
```typescript
|
381 |
+
// API communication
|
382 |
+
@Injectable()
|
383 |
+
export class ApiService {
|
384 |
+
// Project CRUD
|
385 |
+
getProjects(): Observable<Project[]>
|
386 |
+
createProject(data: ProjectData): Observable<Project>
|
387 |
+
updateProject(id: number, data: ProjectData): Observable<Project>
|
388 |
+
|
389 |
+
// Version management
|
390 |
+
createVersion(projectId: number): Observable<Version>
|
391 |
+
publishVersion(projectId: number, versionId: number): Observable<Version>
|
392 |
+
|
393 |
+
// Environment
|
394 |
+
getEnvironment(): Observable<EnvironmentConfig>
|
395 |
+
updateEnvironment(config: EnvironmentConfig): Observable<void>
|
396 |
+
}
|
397 |
|
398 |
+
// Authentication
|
399 |
+
@Injectable()
|
400 |
+
export class AuthService {
|
401 |
+
login(credentials: LoginData): Observable<AuthResponse>
|
402 |
+
logout(): void
|
403 |
+
getToken(): string | null
|
404 |
+
isAuthenticated(): boolean
|
405 |
+
}
|
406 |
|
407 |
+
// Environment state
|
408 |
+
@Injectable()
|
409 |
+
export class EnvironmentService {
|
410 |
+
ttsEnabled$: BehaviorSubject<boolean>
|
411 |
+
sttEnabled$: BehaviorSubject<boolean>
|
412 |
+
currentProvider$: BehaviorSubject<ProviderInfo>
|
413 |
+
}
|
414 |
+
```
|
415 |
|
416 |
+
### HTTP Interceptor
|
417 |
+
```typescript
|
418 |
+
@Injectable()
|
419 |
+
export class AuthInterceptor implements HttpInterceptor {
|
420 |
+
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
421 |
+
const token = this.authService.getToken();
|
422 |
+
if (token) {
|
423 |
+
req = req.clone({
|
424 |
+
setHeaders: { 'X-Auth-Token': token }
|
425 |
+
});
|
426 |
+
}
|
427 |
+
return next.handle(req);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
```
|
431 |
|
432 |
+
## 🎨 Theming and Styling
|
433 |
+
|
434 |
+
### Material Theme
|
435 |
+
```scss
|
436 |
+
// Custom theme
|
437 |
+
$primary: mat-palette($mat-indigo);
|
438 |
+
$accent: mat-palette($mat-pink, A200);
|
439 |
+
$warn: mat-palette($mat-red);
|
440 |
+
|
441 |
+
$theme: mat-light-theme((
|
442 |
+
color: (
|
443 |
+
primary: $primary,
|
444 |
+
accent: $accent,
|
445 |
+
warn: $warn
|
446 |
+
)
|
447 |
+
));
|
448 |
+
|
449 |
+
// Dark theme
|
450 |
+
$dark-theme: mat-dark-theme((
|
451 |
+
color: (
|
452 |
+
primary: $primary,
|
453 |
+
accent: $accent,
|
454 |
+
warn: $warn
|
455 |
+
)
|
456 |
+
));
|
457 |
```
|
458 |
+
|
459 |
+
### Component Styling Pattern
|
460 |
+
```scss
|
461 |
+
.component-container {
|
462 |
+
@apply p-4 h-full flex flex-col;
|
463 |
+
|
464 |
+
.header {
|
465 |
+
@apply flex justify-between items-center mb-4;
|
466 |
+
}
|
467 |
+
|
468 |
+
.content {
|
469 |
+
@apply flex-1 overflow-auto;
|
470 |
+
}
|
471 |
+
|
472 |
+
.actions {
|
473 |
+
@apply mt-4 flex justify-end gap-2;
|
474 |
+
}
|
475 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
```
|
477 |
|
478 |
+
## 📱 Responsive Design
|
|
|
|
|
|
|
|
|
479 |
|
480 |
+
### Breakpoints
|
481 |
+
```scss
|
482 |
+
$mobile: 640px;
|
483 |
+
$tablet: 768px;
|
484 |
+
$desktop: 1024px;
|
485 |
+
$wide: 1280px;
|
486 |
+
```
|
487 |
|
488 |
+
### Mobile Adaptations
|
489 |
+
- Collapsible sidebar
|
490 |
+
- Bottom sheet dialogs
|
491 |
+
- Touch-optimized controls
|
492 |
+
- Simplified layouts
|
493 |
+
|
494 |
+
## 🚀 Performance Optimizations
|
495 |
+
|
496 |
+
### Lazy Loading
|
497 |
+
```typescript
|
498 |
+
const routes: Routes = [
|
499 |
+
{
|
500 |
+
path: 'projects',
|
501 |
+
loadChildren: () => import('./projects/projects.module')
|
502 |
+
.then(m => m.ProjectsModule)
|
503 |
+
}
|
504 |
+
];
|
505 |
```
|
506 |
+
|
507 |
+
### Change Detection
|
508 |
+
```typescript
|
509 |
+
@Component({
|
510 |
+
changeDetection: ChangeDetectionStrategy.OnPush
|
511 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
```
|
513 |
|
514 |
+
### Virtual Scrolling
|
515 |
+
```html
|
516 |
+
<cdk-virtual-scroll-viewport itemSize="50">
|
517 |
+
<div *cdkVirtualFor="let item of items">
|
518 |
+
{{ item }}
|
519 |
+
</div>
|
520 |
+
</cdk-virtual-scroll-viewport>
|
521 |
+
```
|
522 |
|
523 |
+
## 🔒 Security Considerations
|
524 |
|
525 |
+
### XSS Prevention
|
526 |
+
- Sanitized HTML rendering
|
527 |
+
- Template validation
|
528 |
+
- CSP headers
|
529 |
|
530 |
+
### Authentication Flow
|
531 |
+
```
|
532 |
+
Login → JWT Token → Local Storage → HTTP Header → API Validation
|
533 |
+
↓ ↓
|
534 |
+
Redirect Auto Logout
|
535 |
+
```
|
536 |
|
537 |
+
### Sensitive Data
|
538 |
+
- Encrypted API keys (visual: `•••••••xyz`)
|
539 |
+
- No plaintext passwords
|
540 |
+
- Secure cookie options
|
|
|
|
|
541 |
|
542 |
+
## 🧪 Testing Strategy
|
|
|
|
|
|
|
543 |
|
544 |
+
### Unit Tests
|
545 |
+
- Component logic
|
546 |
+
- Service methods
|
547 |
+
- Pipe transformations
|
|
|
548 |
|
549 |
+
### E2E Tests
|
550 |
+
- User workflows
|
551 |
+
- API integration
|
552 |
+
- Error scenarios
|
553 |
|
554 |
+
## 📊 Analytics and Monitoring
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
+
### User Activity Tracking
|
557 |
+
- Feature usage metrics
|
558 |
+
- Performance timing
|
559 |
+
- Error reporting
|
560 |
|
561 |
+
### Dashboard Metrics
|
562 |
+
- Active projects count
|
563 |
+
- API call statistics
|
564 |
+
- User engagement
|
565 |
|
566 |
+
## 🚦 Deployment
|
567 |
|
568 |
+
### Build Configuration
|
569 |
+
```json
|
570 |
+
{
|
571 |
+
"production": {
|
572 |
+
"optimization": true,
|
573 |
+
"sourceMap": false,
|
574 |
+
"namedChunks": false,
|
575 |
+
"extractLicenses": true,
|
576 |
+
"vendorChunk": false
|
577 |
+
}
|
578 |
+
}
|
|
|
|
|
|
|
|
|
|
|
579 |
```
|
580 |
|
581 |
+
### Environment Files
|
582 |
+
```typescript
|
583 |
+
// environment.prod.ts
|
584 |
+
export const environment = {
|
585 |
+
production: true,
|
586 |
+
apiUrl: '/api',
|
587 |
+
wsUrl: 'wss://flare.example.com'
|
588 |
+
};
|
589 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
|
591 |
+
## 🔄 Future Enhancements
|
592 |
+
|
593 |
+
### Planned Features
|
594 |
+
1. **Visual Flow Builder**: Drag-drop intent flow designer
|
595 |
+
2. **A/B Testing**: Version comparison framework
|
596 |
+
3. **Analytics Dashboard**: Usage statistics and insights
|
597 |
+
4. **Collaboration**: Multi-user editing with presence
|
598 |
+
5. **Plugin System**: Extensible architecture
|
599 |
+
6. **Mobile App**: Native mobile management app
|
600 |
+
|
601 |
+
### Technical Debt
|
602 |
+
- Migrate to signals (Angular 17+)
|
603 |
+
- Implement state management (NgRx)
|
604 |
+
- Add comprehensive error boundaries
|
605 |
+
- Improve test coverage to 80%+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|