Commit Graph
17 Commits
Author SHA1 Message Date
Mustafa YildizandClaude Sonnet 5 5fe4b0b8bc feat: WhatsApp AI hattı (n8n + Evolution API) için yeni uç nokta
chat.controller.ts'teki dosya-bağlamı toplama mantığı (belgeler + analiz
özeti + geçmiş mesajlar) buildCaseChatContext() olarak paylaşılan hale
getirildi — mevcut SSE sohbeti (chatMessage) davranış değişmeden bunu
kullanıyor, yeni POST /api/whatsapp/message uç noktası da aynı motoru
tek-seferlik (non-streaming) çağırıyor.

Kimlik doğrulama farklı: bu uç nokta bir Supabase oturumu taşımıyor
(n8n'den gelen anonim WhatsApp mesajı), X-Webhook-Secret ile korunuyor.
Telefon → hesap eşleştirmesi profiles.phone üzerinden, hangi dava
dosyasıyla konuşulduğu whatsapp_sessions'ta tutuluyor (bkz. laawos
sql/20_whatsapp_integration.sql).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-18 13:08:02 +03:00
mstfyldz ee83ea648d feat: complete targetPersona opponent attorney cross examination simulator prompts 2026-08-14 11:56:28 +03:00
mstfyldz f1457b02ca fix(chat): allow AI to finish and save responses even if client disconnects 2026-08-12 13:02:40 +03:00
mstfyldz d10ea1b0fd fix(chat): add SSE padding to bypass proxy buffering 2026-08-12 12:48:04 +03:00
mstfyldz f7daa3d4c7 feat(chat): add digital intern (live search) mode 2026-08-11 23:49:33 +03:00
mstfyldz f87b595ccd feat(simulator): add opponent/judge simulator feature endpoints 2026-08-11 22:54:42 +03:00
mstfyldzandClaude Sonnet 5 9618ff4513 feat: file attachments in chat + document-select for case chat
- Yeni POST /api/documents/extract-text: dosyayı hiçbir yere
  kaydetmeden sadece metnini çıkarıp döner (chat ataç özelliği için)
- chatMessage ve sendThreadMessage artık body'de attachments
  ({filename,text}[]) kabul ediyor; AI bağlamına ekleniyor, kayıtlı
  mesaja da "[Ek dosya(lar): ...]" notu düşülüyor
- chatMessage ayrıca document_ids kabul ediyor — dosya sohbetinde
  kullanıcının bu mesajda özellikle işaret ettiği mevcut belge(ler)
  AI'ye vurgulanıyor

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 01:03:13 +03:00
mstfyldzandClaude Sonnet 5 029402a620 fix: raise num_predict for interactive chat to stop mid-sentence cutoffs
800 token sınırı çok düşüktü — çok bölümlü hukuki cevaplar (kira feshi,
tazminat hesabı gibi) bu sınıra çarpıp cümlenin ortasında kesiliyordu.
Varsayılan ve chatMessage/sendThreadMessage'ın kullandığı num_predict
2048'e çıkarıldı. Ayrıca Ollama done_reason:"length" döndürdüğünde
(yanıt sınıra çarpıp kesildiğinde) sunucu loglarına uyarı yazılıyor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 00:35:00 +03:00
mstfyldzandClaude Sonnet 5 ea5211e05d revert: always send full document text in case chat context
Özet-önce yaklaşımı, kullanıcı uzun bir mesaj/belge verdiğinde sohbet
ekranında soruna yol açtığı için geri alındı — chatMessage yine her
zaman belgelerin tam extracted_text'ini sistem promptuna gömüyor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 00:26:22 +03:00
mstfyldzandClaude Sonnet 5 bcc78ce304 perf: switch all AI calls to native Ollama endpoint, add streaming + keep_alive
Tüm AI çağrıları artık ortak lib/aiClient.ts üzerinden gidiyor:
- /v1/chat/completions yerine native /api/chat (think:false burada
  güvenilir çalışıyor)
- keep_alive:30m ile model her istekte bellekten atılıp soğuk
  başlamıyor
- num_predict ile öngörülemez uzunlukta üretime üst sınır
- İnteraktif sohbet uç noktaları (chatMessage, sendThreadMessage)
  artık SSE ile token token akıtıyor
- Dosya sohbetinde varsayılan olarak belgenin tam metni değil analiz
  özeti gönderiliyor; tam metin sadece kullanıcı açıkça isterse
  eklenir

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 00:21:49 +03:00
mstfyldzandClaude Sonnet 5 0318f2ac77 feat: persist general chat as chat_threads, decoupled from cases
Sohbet/Asistan sayfasındaki genel sohbetler artık kalıcı: yeni
chat_threads/thread_messages tabloları (cases ile ilişkisiz) ile
sendThreadMessage endpoint'i eklendi. Eski caseId==='general'
(kalıcı olmayan) dalı kaldırıldı, AI çağrısı ortak callAiChat
yardımcısına taşındı.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 00:07:44 +03:00
mstfyldzandClaude Sonnet 5 79b2bad396 fix: never auto-rename real case files from chat's first-message title
chatMessage() was auto-generating and overwriting cases.title from the
first chat message for ANY case_id, including real UYAP-imported dava
dosyaları (kind='case') — not just the chat-only "Yeni Sohbet" threads
(kind='chat') this was built for. Asking a real case a single question
in Sohbet silently destroyed its court-derived title. Now gated on
kind === 'chat'.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:25:35 +03:00
mstfyldzandClaude Sonnet 5 c939dcf564 feat: iddianame-first case summary + remove hardcoded AI endpoint
- summarizeCase: if an iddianame is among the case's documents, run a
  narrow first-pass analysis on it alone (isnatEdilenSuc, iddiaOzeti,
  onemliTarihler), then feed that as context into the general
  case-wide evaluation instead of treating every document equally.
- ANALYSIS_SYSTEM_PROMPT no longer asks the AI to guess "taraflar" -
  that now comes from real UYAP data (cases.parties) instead.
- Removed the hardcoded RunPod proxy URL fallback from every call
  site (document/chat/precedent controllers + lib/openai.ts) - it was
  a real infra endpoint checked into source. New lib/aiConfig.ts
  throws if RUNPOD_API_BASE_URL isn't set rather than silently
  falling back to it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-09 20:00:06 +03:00
mstfyldz 0e40aaef96 feat: add case creation endpoint and auto-title from first message
POST /api/cases lets the frontend actually create a new dava dosyası
(no working "Yeni Dosya" flow existed before). chatMessage now
generates a short title from a case's first message (like Claude/
ChatGPT auto-titling) and renames the case, returned as `newTitle`.
2026-08-09 10:34:55 +03:00
mstfyldz 0831ebb25b feat: add DELETE /api/chat/:caseId to clear a case's chat history
Frontend's chat history trash icon was calling this endpoint but it
didn't exist yet, causing a JSON-parse error on the default 404 page.

Also renames the LegalOS health-check message to AyrisLegal.
2026-08-09 10:09:15 +03:00
mstfyldz b030bdaa60 fix: allow case-less ("general") chat without ownership check
requireAuth treated every chat caseId as a real cases row and rejected
"general" (the no-file chat sentinel) with 403. general chat now skips
the ownership check and is answered without touching chat_messages,
since that table's case_id is a NOT NULL FK to cases.
2026-08-09 01:52:53 +03:00
mstfyldz df70520ede Initial commit 2026-08-08 17:19:28 +03:00