Spaces:
Sleeping
Sleeping
Commit
·
f96cd6f
1
Parent(s):
3f1fdb5
Updated
Browse files
main.py
CHANGED
|
@@ -148,6 +148,42 @@ def autodoc(req: AutoDocRequest, authorization: str | None = Header(None)):
|
|
| 148 |
docs = autodoc_chain.invoke({"code": req.code})
|
| 149 |
return {"documentation": docs.strip() if isinstance(docs, str) else str(docs)}
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
# ✅ Hugging Face requires port 7860, not 8000
|
| 152 |
if __name__ == "__main__":
|
| 153 |
import uvicorn
|
|
|
|
| 148 |
docs = autodoc_chain.invoke({"code": req.code})
|
| 149 |
return {"documentation": docs.strip() if isinstance(docs, str) else str(docs)}
|
| 150 |
|
| 151 |
+
@app.post("/sme/generate")
|
| 152 |
+
async def sme_generate(payload: dict = Body(...)):
|
| 153 |
+
"""
|
| 154 |
+
Generate SME site boilerplate.
|
| 155 |
+
Expected payload:
|
| 156 |
+
{
|
| 157 |
+
"site_name": "...",
|
| 158 |
+
"stack": "react"|"html-css-js",
|
| 159 |
+
"pages": [{ "name": "home", "content": "..." }],
|
| 160 |
+
"language": "en"
|
| 161 |
+
}
|
| 162 |
+
"""
|
| 163 |
+
prompt = f"""
|
| 164 |
+
You are an SME builder. Generate project code.
|
| 165 |
+
Site name: {payload.get('site_name')}
|
| 166 |
+
Stack: {payload.get('stack')}
|
| 167 |
+
Pages: {payload.get('pages')}
|
| 168 |
+
Language: {payload.get('language')}
|
| 169 |
+
|
| 170 |
+
Return ONLY JSON:
|
| 171 |
+
{{
|
| 172 |
+
"files": {{
|
| 173 |
+
"index.html": "<html>...</html>",
|
| 174 |
+
"style.css": "body {{}}",
|
| 175 |
+
"script.js": "..."
|
| 176 |
+
}},
|
| 177 |
+
"README.md": "# Instructions ..."
|
| 178 |
+
}}
|
| 179 |
+
"""
|
| 180 |
+
|
| 181 |
+
# Call your LLM (LangChain Runnable, HF endpoint, etc.)
|
| 182 |
+
response = chain.invoke({"question": prompt})
|
| 183 |
+
|
| 184 |
+
return { "success": True, "data": response }
|
| 185 |
+
|
| 186 |
+
|
| 187 |
# ✅ Hugging Face requires port 7860, not 8000
|
| 188 |
if __name__ == "__main__":
|
| 189 |
import uvicorn
|