Enhance error handling and user experience in AI-related features
Some checks failed
Deploy / deploy (push) Failing after 38m47s

- Introduced a mechanism to save partially generated responses in case of errors, ensuring users do not lose their input.
- Updated the RevizyonKutusu component to utilize a persistent request ID for retrying failed requests without double charging credits.
- Improved the Sayfalama component to support client-side pagination without changing the URL, enhancing user navigation.
- Added a timeout for AI generation requests to ensure credits are refunded in case of prolonged processing.
- Refactored various components for better clarity and responsiveness, including updates to the BolumProgramListesi and ListePaneli components.
This commit is contained in:
bilalgursen
2026-08-03 14:12:06 +03:00
parent c2aba25814
commit a5c2bcbc4d
13 changed files with 384 additions and 180 deletions

View File

@@ -247,9 +247,9 @@ export async function POST(request: NextRequest) {
const readable = new ReadableStream({
async start(controller) {
let tamamlandi = false;
let metin = "";
try {
// Sağlayıcıya bağlanma hatası da ilk parçada burada yakalanır
let metin = "";
for await (const parca of sohbetAkisi({
system,
mesajlar,
@@ -269,7 +269,20 @@ export async function POST(request: NextRequest) {
controller.close();
} catch (err) {
if (!tamamlandi) {
// Hiç çıktı üretilmeden hata olduysa krediyi iade et
// Cevap tamamlanmadı: kredi iade edilir. Yarıda kalan metin varsa
// yine de kaydedilir ki kullanıcı ekranda gördüğü kısmı sayfa
// yenilenince kaybetmesin.
if (metin) {
try {
await appDb.insert(schema.chatMessages).values({
id: crypto.randomUUID(),
userId,
role: "assistant",
content: metin,
createdAt: new Date(),
});
} catch {}
}
await grantCredits({
userId,
delta: 1,