mirror of
https://github.com/thomasnordquist/MQTT-Explorer.git
synced 2026-09-11 09:03:33 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8c702441c | ||
|
|
c0ec2c1bd4 | ||
|
|
cf39599a16 | ||
|
|
76b0a42a19 |
@@ -180,6 +180,35 @@ The LLM service supports:
|
||||
- Try asking a simpler question
|
||||
- Verify OpenAI's service status
|
||||
|
||||
### Response Not Showing in App
|
||||
|
||||
If you see LLM logs showing a query and response but the response doesn't appear in the app:
|
||||
|
||||
**Debugging Steps**:
|
||||
|
||||
1. **Enable Debug Logging**: Open your browser's Developer Console (F12 or Ctrl+Shift+I) and look for `[LLM]` prefixed messages
|
||||
2. **Check Query Logs**: Look for `[LLM] Query with context:` to see the full query including topic context
|
||||
3. **Check Response Logs**: Look for `[LLM] OpenAI API response:` or `[LLM] Gemini API response:` to see the full API response
|
||||
4. **Check Extraction Logs**: Look for `[LLM] Extracted assistant message:` to see what message was extracted from the response
|
||||
5. **Verify Response Structure**:
|
||||
- For OpenAI: Check that `response.data.choices[0].message.content` exists
|
||||
- For Gemini: Check that `response.data.candidates[0].content.parts[0].text` exists
|
||||
|
||||
**Common Issues**:
|
||||
- If you see a response but no extracted message, the API response structure may have changed
|
||||
- If you see error logs like `[LLM] No choices in OpenAI response:`, the API may be returning an unexpected format
|
||||
- Empty or null responses from the API will trigger error messages in the console
|
||||
|
||||
**Debug Example**:
|
||||
```javascript
|
||||
// Expected in browser console:
|
||||
[LLM] Query with context: { topicContext: "...", userMessage: "...", fullMessage: "..." }
|
||||
[LLM] OpenAI API response: { choices: [...], ... }
|
||||
[LLM] Extracted assistant message: "This is the AI's response..."
|
||||
```
|
||||
|
||||
If the extracted message appears in logs but not in the UI, there may be an issue with the React component state management in `AIAssistant.tsx`.
|
||||
|
||||
## Limitations
|
||||
|
||||
- Requires active internet connection
|
||||
|
||||
@@ -370,6 +370,17 @@ Help users understand their MQTT data, troubleshoot issues, optimize their autom
|
||||
let messageContent = userMessage
|
||||
if (topicContext) {
|
||||
messageContent = `Context:\n${topicContext}\n\nUser Question: ${userMessage}`
|
||||
// Debug: Log the query with context
|
||||
console.debug('[LLM] Query with context:', {
|
||||
topicContext,
|
||||
userMessage,
|
||||
fullMessage: messageContent
|
||||
})
|
||||
} else {
|
||||
// Debug: Log query without context
|
||||
console.debug('[LLM] Query without context:', {
|
||||
userMessage
|
||||
})
|
||||
}
|
||||
|
||||
// Add user message to history
|
||||
@@ -407,11 +418,16 @@ Help users understand their MQTT data, troubleshoot issues, optimize their autom
|
||||
}
|
||||
)
|
||||
|
||||
// Debug: Log the full response (console.debug is only visible in DevTools, not in production)
|
||||
console.debug('[LLM] Gemini API response:', response.data)
|
||||
|
||||
if (!response.data.candidates || response.data.candidates.length === 0) {
|
||||
console.error('[LLM] No candidates in Gemini response:', response.data)
|
||||
throw new Error('No response from AI assistant')
|
||||
}
|
||||
|
||||
assistantMessage = response.data.candidates[0].content.parts[0].text
|
||||
console.debug('[LLM] Extracted assistant message:', assistantMessage)
|
||||
} else {
|
||||
// OpenAI API format
|
||||
const response = await this.axiosInstance.post('/chat/completions', {
|
||||
@@ -421,11 +437,16 @@ Help users understand their MQTT data, troubleshoot issues, optimize their autom
|
||||
max_tokens: 500,
|
||||
})
|
||||
|
||||
// Debug: Log the full response (console.debug is only visible in DevTools, not in production)
|
||||
console.debug('[LLM] OpenAI API response:', response.data)
|
||||
|
||||
if (!response.data.choices || response.data.choices.length === 0) {
|
||||
console.error('[LLM] No choices in OpenAI response:', response.data)
|
||||
throw new Error('No response from AI assistant')
|
||||
}
|
||||
|
||||
assistantMessage = response.data.choices[0].message.content
|
||||
console.debug('[LLM] Extracted assistant message:', assistantMessage)
|
||||
}
|
||||
|
||||
// Add assistant response to history
|
||||
|
||||
Reference in New Issue
Block a user