Commit
·
bca9aeb
1
Parent(s):
062433d
fgfhdhd
Browse files
app.py
CHANGED
|
@@ -7,8 +7,8 @@ import requests
|
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
# === Constants ===
|
| 10 |
-
MODEL_REPO
|
| 11 |
-
MODEL_FILE
|
| 12 |
MODEL_URL = f"https://huggingface.co/{MODEL_REPO}/resolve/main/{MODEL_FILE}"
|
| 13 |
MODEL_DIR = "./models"
|
| 14 |
MODEL_PATH = os.path.join(MODEL_DIR, MODEL_FILE)
|
|
@@ -32,7 +32,7 @@ if not os.path.exists(MODEL_PATH):
|
|
| 32 |
|
| 33 |
# === Load model ===
|
| 34 |
print("🔧 Loading GGUF model...")
|
| 35 |
-
llm = Llama(model_path=MODEL_PATH, n_ctx=512)
|
| 36 |
|
| 37 |
# === Inference ===
|
| 38 |
class PromptRequest(BaseModel):
|
|
|
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
# === Constants ===
|
| 10 |
+
MODEL_REPO="nilbot/gemma-2b-it-Q4_K"
|
| 11 |
+
MODEL_FILE="gemma-2b-it-Q4_K.gguf"
|
| 12 |
MODEL_URL = f"https://huggingface.co/{MODEL_REPO}/resolve/main/{MODEL_FILE}"
|
| 13 |
MODEL_DIR = "./models"
|
| 14 |
MODEL_PATH = os.path.join(MODEL_DIR, MODEL_FILE)
|
|
|
|
| 32 |
|
| 33 |
# === Load model ===
|
| 34 |
print("🔧 Loading GGUF model...")
|
| 35 |
+
llm = Llama(model_path=MODEL_PATH, n_ctx=512, n_threads=os.cpu_count())
|
| 36 |
|
| 37 |
# === Inference ===
|
| 38 |
class PromptRequest(BaseModel):
|
tester.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
import requests
|
| 2 |
|
| 3 |
-
url = "
|
| 4 |
-
|
| 5 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
}
|
| 7 |
-
data = {
|
| 8 |
-
"prompt": "Design a small medieval gate using stone bricks and oak wood."
|
| 9 |
-
}
|
| 10 |
-
|
| 11 |
-
response = requests.post(url, headers=headers, json=data)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
print(
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
|
| 3 |
+
url = "https://thongcoder-minecraft-ai-builder-backend.hf.space/prompt"
|
| 4 |
+
payload = {
|
| 5 |
+
"prompt": "You could only use these blocks for building a Floating Island, including:\n"
|
| 6 |
+
"Animated blocks: water, lava\n"
|
| 7 |
+
"Non-animated blocks: dirt, grass_block, stone, oak_log, oak_leaves\n\n"
|
| 8 |
+
"Now generate the full layout in this format:\nlayout[y][z][x]: ...",
|
| 9 |
+
"max_tokens": 512,
|
| 10 |
+
"temperature": 0.7
|
| 11 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
response = requests.post(url, json=payload)
|
| 14 |
+
print(response.status_code)
|
| 15 |
+
print(response.json())
|