- Changes to support SpecialistID being passed iso CatalogID
- Removed error that stopped sync
This commit is contained in:
@@ -133,12 +133,17 @@ def check_task_status(data):
|
||||
elif task_result.state == 'SUCCESS':
|
||||
result = task_result.result
|
||||
current_app.logger.debug(f'SocketIO: Task {task_id} returned: {result}')
|
||||
|
||||
# Access the result structure correctly
|
||||
specialist_result = result['result'] # This contains the SpecialistResult model_dump
|
||||
response = {
|
||||
'status': 'success',
|
||||
'taskId': task_id,
|
||||
'answer': result['answer'],
|
||||
'citations': result['citations'],
|
||||
'algorithm': result['algorithm'],
|
||||
'results': {
|
||||
'answer': specialist_result.get('answer'),
|
||||
'citations': specialist_result.get('citations', []),
|
||||
'insufficient_info': specialist_result.get('insufficient_info', False)
|
||||
},
|
||||
'interaction_id': result['interaction_id'],
|
||||
}
|
||||
emit('task_status', response, room=room)
|
||||
@@ -146,7 +151,6 @@ def check_task_status(data):
|
||||
current_app.logger.error(f'SocketIO: Task {task_id} has failed. Error: {task_result.info}')
|
||||
emit('task_status', {'status': task_result.state, 'message': str(task_result.info)}, room=room)
|
||||
|
||||
|
||||
@socketio.on('feedback')
|
||||
def handle_feedback(data):
|
||||
try:
|
||||
|
||||
@@ -82,7 +82,7 @@ class EveAIChatWidget extends HTMLElement {
|
||||
}
|
||||
|
||||
updateAttributes() {
|
||||
this.tenantId = this.getAttribute('tenant-id');
|
||||
this.tenantId = parseInt(this.getAttribute('tenant-id'));
|
||||
this.apiKey = this.getAttribute('api-key');
|
||||
this.domain = this.getAttribute('domain');
|
||||
this.language = this.getAttribute('language');
|
||||
@@ -163,7 +163,8 @@ class EveAIChatWidget extends HTMLElement {
|
||||
},
|
||||
reconnectionAttempts: Infinity, // Infinite reconnection attempts
|
||||
reconnectionDelay: 5000, // Delay between reconnections
|
||||
timeout: 20000 // Connection timeout
|
||||
timeout: 20000, // Connection timeout
|
||||
debug: true
|
||||
});
|
||||
|
||||
console.log(`Finished initializing socket connection to Evie`);
|
||||
@@ -235,28 +236,19 @@ class EveAIChatWidget extends HTMLElement {
|
||||
});
|
||||
|
||||
this.socket.on('bot_response', (data) => {
|
||||
console.log('Bot response received: ', data);
|
||||
console.log('data tenantId: ', data.tenantId)
|
||||
console.log('this tenantId: ', this.tenantId)
|
||||
if (data.tenantId === this.tenantId) {
|
||||
console.log('Initial response received:', data);
|
||||
console.log('Task ID received:', data.taskId);
|
||||
this.checkTaskStatus(data.taskId);
|
||||
console.log('Starting task status check for:', data.taskId);
|
||||
setTimeout(() => this.startTaskCheck(data.taskId), 1000);
|
||||
this.setStatusMessage('Processing...');
|
||||
}
|
||||
});
|
||||
|
||||
this.socket.on('task_status', (data) => {
|
||||
console.log('Task status received:', data.status);
|
||||
console.log('Task ID received:', data.taskId);
|
||||
console.log('Citations type:', typeof data.results.citations, 'Citations:', data.results.citations);
|
||||
|
||||
if (data.status === 'pending') {
|
||||
this.updateProgress();
|
||||
setTimeout(() => this.checkTaskStatus(data.taskId), 1000); // Poll every second
|
||||
} else if (data.status === 'success') {
|
||||
this.addBotMessage(data.results.answer, data.interaction_id, data.algorithm, data.results.citations || []);
|
||||
this.clearProgress(); // Clear progress indicator when done
|
||||
} else {
|
||||
this.setStatusMessage('Failed to process message.');
|
||||
}
|
||||
console.log('Task status received:', data);
|
||||
this.handleTaskStatus(data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -442,6 +434,39 @@ toggleFeedback(thumbsUp, thumbsDown, feedback, interactionId) {
|
||||
}
|
||||
}
|
||||
|
||||
startTaskCheck(taskId) {
|
||||
console.log('Emitting check_task_status for:', taskId);
|
||||
this.socket.emit('check_task_status', {
|
||||
task_id: taskId,
|
||||
token: this.jwtToken,
|
||||
tenantId: this.tenantId
|
||||
});
|
||||
}
|
||||
|
||||
handleTaskStatus(data) {
|
||||
console.log('Handling task status:', data);
|
||||
|
||||
if (data.status === 'pending') {
|
||||
this.updateProgress();
|
||||
// Continue checking
|
||||
setTimeout(() => this.startTaskCheck(data.taskId), 1000);
|
||||
} else if (data.status === 'success') {
|
||||
if (data.results) {
|
||||
this.addBotMessage(
|
||||
data.results.answer,
|
||||
data.interaction_id,
|
||||
'RAG_TENANT',
|
||||
data.results.citations || []
|
||||
);
|
||||
} else {
|
||||
console.error('Missing results in task status response:', data);
|
||||
}
|
||||
this.clearProgress();
|
||||
} else {
|
||||
console.error('Task error:', data);
|
||||
this.setStatusMessage('Failed to process message.');
|
||||
}
|
||||
}
|
||||
sendMessageToBackend(message) {
|
||||
console.log('sendMessageToBackend called');
|
||||
if (!this.socket) {
|
||||
|
||||
Reference in New Issue
Block a user