AutoStartup.ai / minimal_app.py
samihalawa's picture
Upload minimal_app.py with huggingface_hub
0f63a8d verified
#!/usr/bin/env python3
"""
Minimal version of AutoStartup.ai for debugging HuggingFace deployment
"""
import gradio as gr
import os
def test_environment():
"""Test if environment variables are properly set"""
api_key = os.getenv("OPENAI_API_KEY")
endpoint = os.getenv("OPENAI_API_ENDPOINT")
model = os.getenv("OPENAI_MODEL")
if not api_key:
return "❌ OPENAI_API_KEY not found"
if not endpoint:
return "❌ OPENAI_API_ENDPOINT not found"
if not model:
return "❌ OPENAI_MODEL not found"
return f"βœ… Environment OK\n- API Key: {api_key[:10]}...\n- Endpoint: {endpoint}\n- Model: {model}"
def simple_generate(query):
"""Simple test function"""
if not query.strip():
return "Please enter a query"
try:
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"),
base_url=os.getenv("OPENAI_API_ENDPOINT")
)
response = client.chat.completions.create(
model=os.getenv("OPENAI_MODEL"),
messages=[
{"role": "system", "content": "You are a helpful startup idea generator."},
{"role": "user", "content": f"Generate a simple startup idea for: {query}"}
],
max_tokens=200
)
return f"βœ… API Working!\n\nIdea: {response.choices[0].message.content}"
except Exception as e:
return f"❌ Error: {str(e)}"
# Simple Gradio interface for testing
with gr.Blocks(title="AutoStartup.ai - Debug Mode") as demo:
gr.Markdown(
"""
# πŸ”§ AutoStartup.ai - Debug Mode
This is a minimal version to test the deployment and API connectivity.
"""
)
with gr.Row():
with gr.Column():
env_status = gr.Textbox(
label="Environment Status",
value=test_environment(),
interactive=False,
lines=5
)
query_input = gr.Textbox(
label="Test Query",
placeholder="Enter a market problem or industry focus...",
lines=3
)
test_button = gr.Button("πŸ§ͺ Test API Connection", variant="primary")
with gr.Column():
result_output = gr.Textbox(
label="Test Result",
interactive=False,
lines=10
)
test_button.click(
fn=simple_generate,
inputs=[query_input],
outputs=[result_output]
)
if __name__ == "__main__":
demo.launch()