IDAgentsFreshTest / app_simple_test.py
IDAgents Developer
Troubleshoot: Add simplified test app and fix Gradio version mismatch
1a01a01
raw
history blame
3.46 kB
#!/usr/bin/env python3
"""
Simplified ID Agents App for Troubleshooting
This version isolates potential import issues and provides basic functionality
"""
import gradio as gr
import json
import os
# Simple authentication test
def create_simple_app():
"""Create a simplified version of the ID Agents app"""
with gr.Blocks(title="ID Agents - Test Version") as app:
# Custom CSS (minimal)
app.css = """
.main-container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
"""
# Header
gr.Markdown("# 🦠 ID Agents - Test Version")
gr.Markdown("This is a simplified version to test basic functionality and authentication.")
# Simple chat interface
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("### Quick Test Panel")
test_input = gr.Textbox(label="Test Input", placeholder="Type a message...")
test_btn = gr.Button("Send Test")
with gr.Column(scale=2):
gr.Markdown("### Chat Test")
chatbot = gr.Chatbot(label="Test Chat")
# Simple function
def test_response(message):
if not message.strip():
return [["", "Please enter a message to test."]]
response = f"βœ… Test successful! You said: '{message}'"
return [["Test User", message], ["ID Agents Test", response]]
# Connect the function
test_btn.click(
test_response,
inputs=[test_input],
outputs=[chatbot]
)
# Footer
gr.Markdown("---")
gr.Markdown("πŸ§ͺ **Test Status**: If you can see this interface and interact with it, the basic setup is working!")
return app
def main():
"""Main function with authentication"""
print("πŸ§ͺ Starting ID Agents Test Version...")
# Create the app
try:
app = create_simple_app()
print("βœ… App created successfully")
except Exception as e:
print(f"❌ Failed to create app: {e}")
return
# Authentication credentials (simplified)
auth_credentials = [
("test", "test123"),
("admin", "admin123"),
("dr_smith", "idweek2025"),
("guest", "guest123")
]
auth_message = """
πŸ§ͺ **ID Agents Test Version**
Test credentials:
β€’ test / test123
β€’ admin / admin123
β€’ dr_smith / idweek2025
β€’ guest / guest123
"""
# Launch configuration
launch_config = {
"auth": auth_credentials,
"auth_message": auth_message,
"server_name": "0.0.0.0",
"server_port": 7860,
"share": False,
"show_error": True
}
print("πŸ” Authentication enabled")
print("πŸš€ Launching app...")
try:
app.launch(**launch_config)
except Exception as e:
print(f"❌ Failed to launch app: {e}")
# Try without authentication as fallback
print("πŸ”„ Trying without authentication...")
try:
app.launch(
server_name="0.0.0.0",
server_port=7860,
share=False
)
except Exception as e2:
print(f"❌ Complete failure: {e2}")
if __name__ == "__main__":
main()