Skip to content
Open
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
10 changes: 5 additions & 5 deletions backend/openedx_ai_extensions/workflows/orchestrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def run(self, input_data):
# --- 7. Return Structured Non-Streaming Result ---
# If execution reaches this point, we have a successful, non-streaming result (Dict).
response_data = {
'response': llm_result.get('response', 'No response available'),
'response': llm_result.get('response') or 'No response available',
'status': 'completed',
'metadata': {
'tokens_used': llm_result.get('tokens_used'),
Expand Down Expand Up @@ -451,7 +451,7 @@ def lazy_load_chat_history(self, input_data):
}

return {
"response": result.get("response", "{}"),
"response": result.get("response") or "{}",
"status": "completed",
}

Expand Down Expand Up @@ -521,7 +521,7 @@ def run(self, input_data):
"status": "SubmissionProcessor error",
}
return {
"response": history_result.get("response", "No response available"),
"response": history_result.get("response") or "No response available",
"status": "completed",
}

Expand Down Expand Up @@ -568,7 +568,7 @@ def run(self, input_data):

# --- BRANCH C: Handle Non-Streaming (Standard) ---
messages = [
{"role": "assistant", "content": llm_result.get("response", "")},
{"role": "assistant", "content": llm_result.get("response") or ""},
]
if input_data:
messages.insert(0, {"role": "user", "content": input_data})
Expand All @@ -591,7 +591,7 @@ def run(self, input_data):

# 4. Return result
return {
"response": llm_result.get("response", "No response available"),
"response": llm_result.get("response") or "No response available",
"status": "completed",
"metadata": {
"tokens_used": llm_result.get("tokens_used"),
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/ConfigurableAIAssistance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
AIEducatorLibraryAssistComponent,
AIEducatorLibraryResponseComponent,
} from './components';
import { NO_RESPONSE_MSG } from './services/constants';

/**
* Component Registry
Expand Down Expand Up @@ -177,7 +178,7 @@ const ConfigurableAIAssistance = ({
} else if (data.error) {
throw new Error(data.error);
} else {
setResponse(JSON.stringify(data, null, 2));
setResponse(NO_RESPONSE_MSG);
setHasAsked(true);
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/GetAIAssistanceButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AIRequestComponent,
AIResponseComponent,
} from './components';
import { NO_RESPONSE_MSG } from './services/constants';

/**
* Main AI Assistant Plugin Component
Expand Down Expand Up @@ -81,7 +82,7 @@ const GetAIAssistanceButton = ({
throw new Error(data.error);
} else {
// If API returns something but in unexpected format, try to use it
setResponse(JSON.stringify(data, null, 2));
setResponse(NO_RESPONSE_MSG);
setHasAsked(true);
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/AIEducatorLibraryAssistComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AutoAwesome, Close } from '@openedx/paragon/icons';
import { getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { callWorkflowService, prepareContextData } from '../services';
import { NO_RESPONSE_MSG } from '../services/constants';

/**
* AI Educator Library Assist Component
Expand Down Expand Up @@ -207,7 +208,7 @@ const AIEducatorLibraryAssistComponent = ({
} else {
// Immediate response
const immediateResponse = data.response || data.message || data.content
|| data.result || JSON.stringify(data, null, 2);
|| data.result || NO_RESPONSE_MSG;
setResponse(immediateResponse);
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/AISidebarResponse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
prepareContextData,
formatErrorMessage,
} from '../services';
import { NO_RESPONSE_MSG } from '../services/constants';

/**
* AI Sidebar Response Component
Expand Down Expand Up @@ -414,7 +415,7 @@ const AISidebarResponse = ({
} else if (data.result) {
aiResponse = data.result;
} else {
aiResponse = JSON.stringify(data, null, 2);
aiResponse = NO_RESPONSE_MSG;
}

// Update the AI placeholder with the final response
Expand Down
1 change: 1 addition & 0 deletions frontend/src/services/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const NO_RESPONSE_MSG = 'No response available';