Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nilai-api/src/nilai_api/routers/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def stream_response() -> AsyncGenerator[str, None]:
"POST",
f"{model_url}/v1/chat/completions",
json=req.model_dump(),
timeout=60.0,
timeout=None,
) as response:
response.raise_for_status() # Raise an error for invalid status codes

Expand Down Expand Up @@ -192,7 +192,7 @@ async def stream_response() -> AsyncGenerator[str, None]:
try:
async with httpx.AsyncClient() as client:
response = await client.post(
f"{model_url}/v1/chat/completions", json=req.model_dump(), timeout=60.0
f"{model_url}/v1/chat/completions", json=req.model_dump(), timeout=None
)
response.raise_for_status()
model_response = ChatResponse.model_validate_json(response.content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
repo_id="bartowski/Llama-3.2-1B-Instruct-GGUF",
filename="Llama-3.2-1B-Instruct-Q5_K_S.gguf",
n_threads=16,
n_ctx=2048,
n_ctx=128 * 1024,
verbose=False,
),
metadata=ModelMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self):
repo_id="bartowski/Meta-Llama-3-8B-Instruct-GGUF",
filename="Meta-Llama-3-8B-Instruct-Q5_K_M.gguf",
n_threads=16,
n_ctx=2048,
n_ctx=8 * 1024,
verbose=False,
),
metadata=ModelMetadata(
Expand Down
8 changes: 6 additions & 2 deletions nilai-models/src/nilai_models/models/llama_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def generate() -> AsyncGenerator[str, None]:
prompt, # type: ignore
stream=True,
temperature=req.temperature if req.temperature else 0.2,
max_tokens=req.max_tokens,
max_tokens=req.max_tokens if req.max_tokens else 2048,
),
)
for output in output_generator:
Expand Down Expand Up @@ -110,7 +110,11 @@ async def generate() -> AsyncGenerator[str, None]:

# Non-streaming (regular) chat completion
try:
generation: dict = self.model.create_chat_completion(prompt) # type: ignore
generation: dict = self.model.create_chat_completion(
prompt,
temperature=req.temperature if req.temperature else 0.2,
max_tokens=req.max_tokens if req.max_tokens else 2048,
) # type: ignore
except ValueError:
raise HTTPException(
status_code=400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):
repo_id="bartowski/Llama-3.2-1B-Instruct-GGUF",
filename="Llama-3.2-1B-Instruct-Q5_K_S.gguf",
n_threads=16,
n_ctx=2048,
n_ctx=128 * 1024,
verbose=False,
),
metadata=ModelMetadata(
Expand All @@ -40,7 +40,7 @@ def __init__(self):
source="https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF", # Model source
supported_features=["chat_completion"], # Capabilities
),
prefix="d01fe399-8dc2-4c74-acde-ff649802f437",
prefix="nillion/",
)

async def chat_completion(
Expand Down
2 changes: 1 addition & 1 deletion packages/nilai-common/src/nilai_common/api_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ChatRequest(BaseModel):
model: str
messages: List[Message]
temperature: Optional[float] = 0.2
max_tokens: Optional[int] = None
max_tokens: Optional[int] = 2048
stream: Optional[bool] = False


Expand Down
3 changes: 2 additions & 1 deletion tests/nilai_models/models/test_llama_1b_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

from tests import response as RESPONSE

model = Llama1BCpu()


@pytest.fixture
def llama_model(mocker):
"""Fixture to provide a Llama1BCpu instance for testing."""
model = Llama1BCpu()
mocker.patch.object(model, "chat_completion", new_callable=AsyncMock)
return model

Expand Down
Loading