Spaces:
Sleeping
Sleeping
File size: 6,556 Bytes
467cc9d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | """
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
)
|