Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dist/textgenhub-1.2.2.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "textgenhub",
"version": "1.2.1",
"version": "1.2.2",
"description": "Text generation hub supporting multiple LLM providers",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "textgenhub"
version = "1.2.1"
version = "1.2.2"
description = "My personal LLM hub to connect to web-based LLMs"
readme = "README.md"
authors = ["Levente Csibi <csibi.levente14@gmail.com>"]
Expand Down
44 changes: 26 additions & 18 deletions src/textgenhub/chatgpt/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,28 +557,36 @@ export async function sendPrompt(page, prompt, debug = false, timeoutSeconds = 1
return !!lastArticle.querySelector('div.result-streaming.pulse.aria-busy');
}, initialArticleCount);

if (pulseIndicator) {
pulseRetryCount += 1;
if (debug) console.log(`[DEBUG] Detected stalled streaming pulse (attempt ${pulseRetryCount}/${maxPulseRetries})`);
if (pulseIndicator && attempts >= 30) {
// Only refresh if we've waited at least 30 seconds and no response text is appearing yet
const currentResponse = await scrapeResponse(page, initialArticleCount, debug);
const hasResponse = currentResponse && currentResponse.trim().length > 0;

if (pulseRetryCount > maxPulseRetries) {
throw new Error('ChatGPT response stalled with pulsing indicator after refresh retries.');
}
if (!hasResponse) {
pulseRetryCount += 1;
if (debug) console.log(`[DEBUG] Detected stalled streaming pulse after 30s (attempt ${pulseRetryCount}/${maxPulseRetries})`);

if (debug) console.log('[DEBUG] Refreshing page and resubmitting prompt due to stalled pulse indicator');
await page.reload({ waitUntil: 'networkidle2' });
await new Promise(resolve => setTimeout(resolve, 2000));
await ensureLoggedIn(page);
initialArticleCount = await getArticleCount(page);
if (debug) console.log(`[DEBUG] Reset article count after refresh: ${initialArticleCount}`);
if (pulseRetryCount > maxPulseRetries) {
throw new Error('ChatGPT response stalled with pulsing indicator after refresh retries.');
}

await prepareComposerAndSubmit(page, prompt, debug, typingSpeed);
if (debug) console.log('[DEBUG] Refreshing page and resubmitting prompt due to stalled pulse indicator');
await page.reload({ waitUntil: 'networkidle2' });
await new Promise(resolve => setTimeout(resolve, 2000));
await ensureLoggedIn(page);
initialArticleCount = await getArticleCount(page);
if (debug) console.log(`[DEBUG] Reset article count after refresh: ${initialArticleCount}`);

attempts = 0;
lastResponseLength = 0;
stableCount = 0;
growingCount = 0;
continue;
await prepareComposerAndSubmit(page, prompt, debug, typingSpeed);

attempts = 0;
lastResponseLength = 0;
stableCount = 0;
growingCount = 0;
continue;
} else {
if (debug) console.log(`[DEBUG] Pulse indicator present but response already started (length: ${currentResponse.length}), not refreshing`);
}
}

if (debug) console.log(`[DEBUG] Calling scrapeResponse...`);
Expand Down
2 changes: 1 addition & 1 deletion src/textgenhub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "textgenhub",
"version": "1.2.1",
"version": "1.2.2",
"type": "module",
"main": "base-provider.js",
"scripts": {
Expand Down
Loading