Spaces:
Sleeping
Sleeping
| """ | |
| Vish AI - Simple Test Server (for local dev container testing) | |
| This is a lightweight version for testing in Python 3.14 | |
| The full AI version will run on Hugging Face Spaces (Python 3.10/3.11) | |
| """ | |
| import gradio as gr | |
| import os | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| SUPABASE_URL = os.getenv("NEXT_PUBLIC_SUPABASE_URL", "https://lyebtceryednzafhyunq.supabase.co") | |
| def simple_chat(message: str, history: list) -> str: | |
| """Simple echo chatbot for testing""" | |
| return f"β Vish AI is running!\n\nYou said: {message}\n\nπ‘ Note: This is a test version. AI models require PyTorch which isn't available in Python 3.14.\n\nπ For the full AI experience, deploy to Hugging Face Spaces (Python 3.10/3.11) using the instructions in DEPLOYMENT.md" | |
| def simple_summarize(text: str) -> str: | |
| """Simple summarizer for testing""" | |
| word_count = len(text.split()) | |
| return f"β Text received: {word_count} words\n\nFirst 100 chars: {text[:100]}...\n\nπ Full summarization available on Hugging Face Spaces" | |
| def simple_sentiment(text: str) -> str: | |
| """Simple sentiment for testing""" | |
| positive_words = ['good', 'great', 'excellent', 'happy', 'love', 'wonderful', 'amazing'] | |
| negative_words = ['bad', 'terrible', 'awful', 'hate', 'sad', 'horrible', 'worst'] | |
| text_lower = text.lower() | |
| pos_count = sum(1 for word in positive_words if word in text_lower) | |
| neg_count = sum(1 for word in negative_words if word in text_lower) | |
| if pos_count > neg_count: | |
| return "π **POSITIVE** (Simple keyword detection)\n\nπ Full sentiment analysis available on Hugging Face Spaces" | |
| elif neg_count > pos_count: | |
| return "π **NEGATIVE** (Simple keyword detection)\n\nπ Full sentiment analysis available on Hugging Face Spaces" | |
| else: | |
| return "π **NEUTRAL** (Simple keyword detection)\n\nπ Full sentiment analysis available on Hugging Face Spaces" | |
| # Create Gradio Interface | |
| with gr.Blocks(theme=gr.themes.Soft(), title="Vish AI - Test Server") as demo: | |
| gr.Markdown(""" | |
| # π Vish AI - Test Server | |
| ### Local Development Environment | |
| β οΈ **This is a simplified test version for Python 3.14 dev container.** | |
| The full AI-powered version with DistilGPT2, DistilBART, and DistilBERT will run on **Hugging Face Spaces**. | |
| π See `DEPLOYMENT.md` for deployment instructions. | |
| """) | |
| gr.Markdown(f""" | |
| ### π Connected to Supabase | |
| - **URL**: {SUPABASE_URL} | |
| - **Status**: β Environment loaded | |
| """) | |
| with gr.Tabs(): | |
| # Chat Tab | |
| with gr.Tab("π¬ Chat Test"): | |
| chatbot = gr.Chatbot(height=400, label="Test Chat") | |
| msg = gr.Textbox( | |
| label="Your Message", | |
| placeholder="Type something to test...", | |
| lines=2 | |
| ) | |
| with gr.Row(): | |
| submit = gr.Button("Send", variant="primary") | |
| clear = gr.Button("Clear") | |
| msg.submit(simple_chat, [msg, chatbot], chatbot) | |
| submit.click(simple_chat, [msg, chatbot], chatbot) | |
| clear.click(lambda: None, None, chatbot, queue=False) | |
| # Summarization Tab | |
| with gr.Tab("π Summarization Test"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| input_text = gr.Textbox( | |
| label="Enter Text", | |
| placeholder="Paste your text here...", | |
| lines=10 | |
| ) | |
| summarize_btn = gr.Button("Test Summarize", variant="primary") | |
| with gr.Column(): | |
| summary_output = gr.Textbox( | |
| label="Summary Result", | |
| lines=10 | |
| ) | |
| summarize_btn.click(simple_summarize, input_text, summary_output) | |
| # Sentiment Analysis Tab | |
| with gr.Tab("π Sentiment Test"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| sentiment_input = gr.Textbox( | |
| label="Enter Text", | |
| placeholder="How do you feel?", | |
| lines=5 | |
| ) | |
| analyze_btn = gr.Button("Test Sentiment", variant="primary") | |
| with gr.Column(): | |
| sentiment_output = gr.Textbox( | |
| label="Sentiment Result", | |
| lines=5 | |
| ) | |
| analyze_btn.click(simple_sentiment, sentiment_input, sentiment_output) | |
| # Info Tab | |
| with gr.Tab("βΉοΈ Info"): | |
| gr.Markdown(""" | |
| ## π οΈ Development Environment | |
| **Current Setup:** | |
| - Python 3.14.0 (dev container) | |
| - Gradio β Installed | |
| - Supabase β Configured | |
| - PyTorch β Not available (Python 3.14) | |
| **For Full AI Features:** | |
| 1. Deploy to Hugging Face Spaces | |
| 2. Hugging Face uses Python 3.10/3.11 | |
| 3. PyTorch and AI models will work there | |
| **Files Ready for Deployment:** | |
| - β `app.py` - Full AI application | |
| - β `requirements.txt` - Dependencies | |
| - β `.env` - Configuration | |
| - β `DEPLOYMENT.md` - Instructions | |
| - β `supabase_setup.sql` - Database schema | |
| ## π Next Steps | |
| 1. Test this interface | |
| 2. Follow `DEPLOYMENT.md` to deploy to HF Spaces | |
| 3. Add secrets in HF Space settings | |
| 4. Run `supabase_setup.sql` in Supabase | |
| 5. Enjoy full AI features! | |
| --- | |
| **VIJ Project** | Powered by Supabase & Hugging Face | |
| """) | |
| gr.Markdown(""" | |
| --- | |
| π **Quick Links:** | |
| - [Hugging Face Space](https://huggingface.co/spaces/Vishwas896/Vish-AI) | |
| - [Supabase Dashboard](https://supabase.com/dashboard/project/lyebtceryednzafhyunq) | |
| - [DEPLOYMENT.md](./DEPLOYMENT.md) | |
| """) | |
| if __name__ == "__main__": | |
| print("π Starting Vish AI Test Server...") | |
| print("π This is a simplified version for local testing") | |
| print("π― Full AI features available on Hugging Face Spaces") | |
| print("") | |
| demo.queue() | |
| demo.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=False | |
| ) | |