处理问题并返回可视化结果
(self, question, max_steps)
| 365 | return f"❌ Error initializing model: {str(e)}" |
| 366 | |
| 367 | def process_question(self, question, max_steps): |
| 368 | """处理问题并返回可视化结果""" |
| 369 | if not self.is_initialized or self.session is None: |
| 370 | return "❌ Please initialize the model first!", "" |
| 371 | |
| 372 | if not question.strip(): |
| 373 | return "❌ Please enter a question!", "" |
| 374 | |
| 375 | try: |
| 376 | visualization_steps, full_output = self.session.get_answer_with_visualization( |
| 377 | question, search_chain_length=max_steps |
| 378 | ) |
| 379 | |
| 380 | # 创建完整的可视化HTML |
| 381 | html_content = f""" |
| 382 | <div style="font-family: 'SimHei', 'Times New Roman', serif;"> |
| 383 | <h2 style="color: #333; border-bottom: 2px solid #007bff; padding-bottom: 10px; font-family: 'SimHei', Arial, sans-serif;"> |
| 384 | 🤖 R3-RAG Step-by-Step Reasoning Process |
| 385 | </h2> |
| 386 | <div style="background-color: #f8f9fa; padding: 15px; border-radius: 10px; margin: 10px 0;"> |
| 387 | <strong style="font-family: 'SimHei', Arial, sans-serif;">Question:</strong> |
| 388 | <span style="font-family: 'Times New Roman', serif;">{question}</span> |
| 389 | </div> |
| 390 | """ |
| 391 | |
| 392 | for step_data in visualization_steps: |
| 393 | html_content += create_step_html(step_data) |
| 394 | |
| 395 | html_content += "</div>" |
| 396 | |
| 397 | return html_content, full_output |
| 398 | |
| 399 | except Exception as e: |
| 400 | return f"❌ Error processing question: {str(e)}", "" |
| 401 | |
| 402 | def create_visualization_interface(): |
| 403 | """创建Gradio界面""" |
nothing calls this directly
no test coverage detected