Spaces:
Sleeping
Sleeping
Steven Chen commited on
Update app.py
Browse files264 unmodified lines26526626726826927027127227327427527627727827928028127228228328428512 unmodified lines298299300291292293294295296297301302303264 unmodified lines print(f"❌ Error in respond: {e}") yield f"抱歉,处理您的消息时出现错误:{str(e)}"
# 准备描述信息base_description = "🤖 AI法律助手,结合向量数据库搜索和大语言模型,为您提供准确的法律信息咨询。"
if chatbot: status_info = f"\n\n✅ **Status**: Connected to database with {chatbot.collection_name} collection" examples_info = "\n\n💡 **Try asking:**\n• What are the fall protection requirements in Ontario construction?\n• Tell me about employer duties under Canada Labour Code\n• What are my rights under the Charter of Rights and Freedoms?\n• Search for information about workplace safety regulations" full_description = base_description + status_info + examples_infoelse: full_description = base_description + "\n\n❌ **Status**: Configuration error - please check environment variables"
# 创建Gradio ChatInterfacedemo = gr.ChatInterface( fn=respond, title="⚖️ Legal RAG Assistant", description="🤖 AI法律助手,结合向量数据库搜索和大语言模型,为您提供准确的法律信息咨询。", description=full_description, additional_inputs=[ gr.Textbox( value="You are a helpful legal assistant with expertise in Canadian law. You have access to a legal database and should provide accurate, well-sourced legal information. Always cite specific legal sources when possible. Remember to include appropriate disclaimers that this is for informational purposes only and not legal advice.",12 unmodified lines ])
# 添加状态显示和示例问题if chatbot: demo.description += f"\n\n✅ **Status**: Connected to database with {chatbot.collection_name} collection" demo.description += f"\n\n💡 **Try asking:**\n• What are the fall protection requirements in Ontario construction?\n• Tell me about employer duties under Canada Labour Code\n• What are my rights under the Charter of Rights and Freedoms?\n• Search for information about workplace safety regulations"else: demo.description += f"\n\n❌ **Status**: Configuration error - please check environment variables"
if __name__ == "__main__": demo.launch( server_name="0.0.0.0",app.py+11-8