StevenChen16 commited on
Commit
a08cd01
·
verified ·
1 Parent(s): 5eecf0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -265,11 +265,21 @@ def respond(
265
  print(f"❌ Error in respond: {e}")
266
  yield f"抱歉,处理您的消息时出现错误:{str(e)}"
267
 
 
 
 
 
 
 
 
 
 
 
268
  # 创建Gradio ChatInterface
269
  demo = gr.ChatInterface(
270
  fn=respond,
271
  title="⚖️ Legal RAG Assistant",
272
- description="🤖 AI法律助手,结合向量数据库搜索和大语言模型,为您提供准确的法律信息咨询。",
273
  additional_inputs=[
274
  gr.Textbox(
275
  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.",
@@ -288,13 +298,6 @@ demo = gr.ChatInterface(
288
  ]
289
  )
290
 
291
- # 添加状态显示和示例问题
292
- if chatbot:
293
- demo.description += f"\n\n✅ **Status**: Connected to database with {chatbot.collection_name} collection"
294
- 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"
295
- else:
296
- demo.description += f"\n\n❌ **Status**: Configuration error - please check environment variables"
297
-
298
  if __name__ == "__main__":
299
  demo.launch(
300
  server_name="0.0.0.0",
 
265
  print(f"❌ Error in respond: {e}")
266
  yield f"抱歉,处理您的消息时出现错误:{str(e)}"
267
 
268
+ # 准备描述信息
269
+ base_description = "🤖 AI法律助手,结合向量数据库搜索和大语言模型,为您提供准确的法律信息咨询。"
270
+
271
+ if chatbot:
272
+ status_info = f"\n\n✅ **Status**: Connected to database with {chatbot.collection_name} collection"
273
+ 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"
274
+ full_description = base_description + status_info + examples_info
275
+ else:
276
+ full_description = base_description + "\n\n❌ **Status**: Configuration error - please check environment variables"
277
+
278
  # 创建Gradio ChatInterface
279
  demo = gr.ChatInterface(
280
  fn=respond,
281
  title="⚖️ Legal RAG Assistant",
282
+ description=full_description,
283
  additional_inputs=[
284
  gr.Textbox(
285
  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.",
 
298
  ]
299
  )
300
 
 
 
 
 
 
 
 
301
  if __name__ == "__main__":
302
  demo.launch(
303
  server_name="0.0.0.0",