Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -65,4 +65,31 @@ class GramBrain:
|
|
| 65 |
if intent == "story":
|
| 66 |
output = random.choice(self.concepts["story"]) + " My latent engine predicts a narrative arc involving " + prompt + "."
|
| 67 |
elif intent == "code":
|
| 68 |
-
output = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
if intent == "story":
|
| 66 |
output = random.choice(self.concepts["story"]) + " My latent engine predicts a narrative arc involving " + prompt + "."
|
| 67 |
elif intent == "code":
|
| 68 |
+
output = "
|
| 69 |
+
else:
|
| 70 |
+
philosophy = random.choice(self.concepts["philosophy"])
|
| 71 |
+
output = f"Indexing '{prompt}' against my latent space. {philosophy}"
|
| 72 |
+
|
| 73 |
+
return output, chain, random.uniform(0.88, 0.99)
|
| 74 |
+
|
| 75 |
+
brain = GramBrain()
|
| 76 |
+
|
| 77 |
+
@app.post("/inference", response_model=InferenceResponse)
|
| 78 |
+
async def run_inference(request: InferenceRequest):
|
| 79 |
+
try:
|
| 80 |
+
output, chain, conf = brain.generate_response(request.prompt)
|
| 81 |
+
return InferenceResponse(
|
| 82 |
+
output=output,
|
| 83 |
+
reasoning_chain=chain,
|
| 84 |
+
confidence=conf
|
| 85 |
+
)
|
| 86 |
+
except Exception as e:
|
| 87 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 88 |
+
|
| 89 |
+
@app.get("/health")
|
| 90 |
+
async def health():
|
| 91 |
+
return {"status": "Latent Space Consolidated"}
|
| 92 |
+
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
# Hugging Face Spaces requires port 7860
|
| 95 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|