Skip to content

Latest commit

 

History

History
85 lines (54 loc) · 2.71 KB

File metadata and controls

85 lines (54 loc) · 2.71 KB

Streaming Debug Analysis

Issue: streaming=1 causes lack of response, streaming=0 works

Key Components to Check:

1. Debug Mode Status

  • Currently enabled in PluginDefinition.cpp: bool debugMode = true;
  • This causes verbose logging in streaming callback

2. Streaming Flow Analysis

Non-Streaming (working) flow:

askChatGPT() → HTTPClient::performRequest() → OpenAIcURLCallback() → handleNonStreamingResponse() → replaceSelectedText()

Streaming (broken) flow:

askChatGPT() → HTTPClient::performStreamingRequest() → OpenAIStreamCallback() → PostMessage(WM_OPENAI_STREAM_CHUNK) → messageProc() → SCI_REPLACESEL

3. Potential Issues:

A. Message Loop Problems

  • OpenAIStreamCallback posts messages with PostMessage(targetWindow, WM_OPENAI_STREAM_CHUNK, 0, (LPARAM)pChunk)
  • messageProc should receive and handle these messages
  • Potential issue: message queue overflow or delivery failure

B. StreamParser Content Extraction

  • StreamParser::extractContent() might not be extracting content properly
  • Different API types have different parsing logic
  • Completion markers might be terminating stream early

C. Global State Issues

  • s_streamTargetScintilla might not be set correctly
  • Editor handle might be invalid when chunks arrive

D. cURL Options

  • HTTP version settings: CURL_HTTP_VERSION_1_1
  • Transfer encoding: CURLOPT_TRANSFER_ENCODING, 1L
  • These might not be compatible with all APIs

4. Debugging Steps:

  1. Check Status Bar Messages: Debug mode should show chunk reception in status bar
  2. Verify PostMessage Success: Check if PostMessage calls are failing
  3. Verify Message Handler: Ensure messageProc receives WM_OPENAI_STREAM_CHUNK
  4. Check Content Extraction: Verify StreamParser::extractContent() returns valid content
  5. Test Different API Types: Issue might be API-specific

5. Quick Fixes to Try:

Fix 1: Disable Debug Mode

// In PluginDefinition.cpp, line ~54
bool debugMode = false; // Disable verbose streaming debug

Fix 2: Simplify Content Extraction

  • Add fallback to raw chunk content if parsing fails
  • Check if completion markers are being triggered too early

Fix 3: Verify Message Delivery

  • Add error checking for PostMessage failures
  • Ensure target window handle is valid

Fix 4: HTTP Settings

  • Try without HTTP/1.1 enforcement
  • Remove transfer encoding setting

6. Likely Root Cause:

The issue is probably in the content extraction phase where StreamParser::extractContent() is not properly parsing the streaming response format for your specific API configuration, causing empty content to be posted to the message queue, resulting in no visible output.