Spaces:
Runtime error
Runtime error
Upload minimal_app.py with huggingface_hub
Browse files- minimal_app.py +90 -0
minimal_app.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
Minimal version of AutoStartup.ai for debugging HuggingFace deployment
|
4 |
+
"""
|
5 |
+
import gradio as gr
|
6 |
+
import os
|
7 |
+
|
8 |
+
def test_environment():
|
9 |
+
"""Test if environment variables are properly set"""
|
10 |
+
api_key = os.getenv("OPENAI_API_KEY")
|
11 |
+
endpoint = os.getenv("OPENAI_API_ENDPOINT")
|
12 |
+
model = os.getenv("OPENAI_MODEL")
|
13 |
+
|
14 |
+
if not api_key:
|
15 |
+
return "❌ OPENAI_API_KEY not found"
|
16 |
+
if not endpoint:
|
17 |
+
return "❌ OPENAI_API_ENDPOINT not found"
|
18 |
+
if not model:
|
19 |
+
return "❌ OPENAI_MODEL not found"
|
20 |
+
|
21 |
+
return f"✅ Environment OK\n- API Key: {api_key[:10]}...\n- Endpoint: {endpoint}\n- Model: {model}"
|
22 |
+
|
23 |
+
def simple_generate(query):
|
24 |
+
"""Simple test function"""
|
25 |
+
if not query.strip():
|
26 |
+
return "Please enter a query"
|
27 |
+
|
28 |
+
try:
|
29 |
+
from openai import OpenAI
|
30 |
+
|
31 |
+
client = OpenAI(
|
32 |
+
api_key=os.getenv("OPENAI_API_KEY"),
|
33 |
+
base_url=os.getenv("OPENAI_API_ENDPOINT")
|
34 |
+
)
|
35 |
+
|
36 |
+
response = client.chat.completions.create(
|
37 |
+
model=os.getenv("OPENAI_MODEL"),
|
38 |
+
messages=[
|
39 |
+
{"role": "system", "content": "You are a helpful startup idea generator."},
|
40 |
+
{"role": "user", "content": f"Generate a simple startup idea for: {query}"}
|
41 |
+
],
|
42 |
+
max_tokens=200
|
43 |
+
)
|
44 |
+
|
45 |
+
return f"✅ API Working!\n\nIdea: {response.choices[0].message.content}"
|
46 |
+
|
47 |
+
except Exception as e:
|
48 |
+
return f"❌ Error: {str(e)}"
|
49 |
+
|
50 |
+
# Simple Gradio interface for testing
|
51 |
+
with gr.Blocks(title="AutoStartup.ai - Debug Mode") as demo:
|
52 |
+
gr.Markdown(
|
53 |
+
"""
|
54 |
+
# 🔧 AutoStartup.ai - Debug Mode
|
55 |
+
This is a minimal version to test the deployment and API connectivity.
|
56 |
+
"""
|
57 |
+
)
|
58 |
+
|
59 |
+
with gr.Row():
|
60 |
+
with gr.Column():
|
61 |
+
env_status = gr.Textbox(
|
62 |
+
label="Environment Status",
|
63 |
+
value=test_environment(),
|
64 |
+
interactive=False,
|
65 |
+
lines=5
|
66 |
+
)
|
67 |
+
|
68 |
+
query_input = gr.Textbox(
|
69 |
+
label="Test Query",
|
70 |
+
placeholder="Enter a market problem or industry focus...",
|
71 |
+
lines=3
|
72 |
+
)
|
73 |
+
|
74 |
+
test_button = gr.Button("🧪 Test API Connection", variant="primary")
|
75 |
+
|
76 |
+
with gr.Column():
|
77 |
+
result_output = gr.Textbox(
|
78 |
+
label="Test Result",
|
79 |
+
interactive=False,
|
80 |
+
lines=10
|
81 |
+
)
|
82 |
+
|
83 |
+
test_button.click(
|
84 |
+
fn=simple_generate,
|
85 |
+
inputs=[query_input],
|
86 |
+
outputs=[result_output]
|
87 |
+
)
|
88 |
+
|
89 |
+
if __name__ == "__main__":
|
90 |
+
demo.launch()
|