Spaces:
Sleeping
Sleeping
Update api.py
Browse filesAdded dynamic support for new models
api.py
CHANGED
|
@@ -8,6 +8,7 @@ class PromptRequest(BaseModel):
|
|
| 8 |
text: str
|
| 9 |
persona: str = "You are a knowledgable and helpful assistant."
|
| 10 |
max_tokens: int = 500
|
|
|
|
| 11 |
|
| 12 |
# --- NEW: Add a Root Route (The Health Check) ---
|
| 13 |
@app.get("/")
|
|
@@ -20,7 +21,7 @@ def generate(req: PromptRequest):
|
|
| 20 |
res = requests.post(
|
| 21 |
"http://localhost:11434/api/generate",
|
| 22 |
json={
|
| 23 |
-
"model":
|
| 24 |
"prompt": f"{req.persona}\n\n{req.text}",
|
| 25 |
"stream": False,
|
| 26 |
"options": {
|
|
|
|
| 8 |
text: str
|
| 9 |
persona: str = "You are a knowledgable and helpful assistant."
|
| 10 |
max_tokens: int = 500
|
| 11 |
+
model: str = "granite4:latest"
|
| 12 |
|
| 13 |
# --- NEW: Add a Root Route (The Health Check) ---
|
| 14 |
@app.get("/")
|
|
|
|
| 21 |
res = requests.post(
|
| 22 |
"http://localhost:11434/api/generate",
|
| 23 |
json={
|
| 24 |
+
"model": req_model,
|
| 25 |
"prompt": f"{req.persona}\n\n{req.text}",
|
| 26 |
"stream": False,
|
| 27 |
"options": {
|