NavyDevilDoc commited on
Commit
a51b178
·
verified ·
1 Parent(s): d1ed8ab

Update api.py

Browse files

Added dynamic support for new models

Files changed (1) hide show
  1. api.py +2 -1
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": "granite4:latest",
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": {