diff --git a/.dockerignore b/.dockerignore index 4583becf..8d959dcc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,4 @@ db/* caddy/caddy_config caddy/caddy_data tests/ -grafana/* \ No newline at end of file +grafana/* diff --git a/.github/scripts/wait_for_ci_services.sh b/.github/scripts/wait_for_ci_services.sh index 71d05ee2..cdd3093b 100755 --- a/.github/scripts/wait_for_ci_services.sh +++ b/.github/scripts/wait_for_ci_services.sh @@ -9,12 +9,12 @@ ATTEMPT=1 while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do echo "Waiting for nilai to become healthy... API:[$API_HEALTH_STATUS] MODEL:[$MODEL_HEALTH_STATUS] NUC_API:[$NUC_API_HEALTH_STATUS] (Attempt $ATTEMPT/$MAX_ATTEMPTS)" - + echo "===== Model Container Logs (last 50 lines) =====" docker logs --tail 50 nilai_gpt_20b_gpu_1 2>&1 docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" echo "=================================================" - + sleep 30 API_HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' nilai-api 2>/dev/null) MODEL_HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' nilai_gpt_20b_gpu_1 2>/dev/null) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 702a2062..c9e3bdac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,20 +15,12 @@ repos: - id: ruff # Runs Ruff's linter exclude: "packages/verifier/" # Excludes the "packages/verifier/" directory from linting - # Second repository: Pyright for static type checking - - repo: local - hooks: - - id: pyright - name: pyright - entry: pyright - language: system - types: [python] # Third repository: Local hooks (custom pre-commit checks) - repo: local hooks: - id: pytest # Defines a local hook for running pytest name: pytest # A human-readable name for the hook - entry: pytest # The command to execute + entry: uv run pytest # The command to execute language: system # Uses the system-installed pytest instead of a virtual environment types: [python] # Applies only to Python files pass_filenames: false # Run pytest on the entire test suite rather than just changed files diff --git a/caddy/.gitignore b/caddy/.gitignore index fbc7f1cd..cc929ca9 100644 --- a/caddy/.gitignore +++ b/caddy/.gitignore @@ -1,2 +1,2 @@ caddy_config/ -caddy_data/ \ No newline at end of file +caddy_data/ diff --git a/docker/api.Dockerfile b/docker/api.Dockerfile index a6d6aaa1..df79ca18 100644 --- a/docker/api.Dockerfile +++ b/docker/api.Dockerfile @@ -16,4 +16,4 @@ uv sync EXPOSE 8080 -CMD ["./launch.sh"] \ No newline at end of file +CMD ["./launch.sh"] diff --git a/docker/vllm.Dockerfile b/docker/vllm.Dockerfile index c3f843c7..0b9742df 100644 --- a/docker/vllm.Dockerfile +++ b/docker/vllm.Dockerfile @@ -1,4 +1,4 @@ -FROM vllm/vllm-openai:v0.11.2 +FROM vllm/vllm-openai:v0.19.0 # # Specify model name and path during build # ARG MODEL_NAME=llama_1b_cpu diff --git a/nilai-api/alembic/README b/nilai-api/alembic/README index e0d0858f..a23d4fb5 100644 --- a/nilai-api/alembic/README +++ b/nilai-api/alembic/README @@ -1 +1 @@ -Generic single-database configuration with an async dbapi. \ No newline at end of file +Generic single-database configuration with an async dbapi. diff --git a/nilai-api/src/nilai_api/config/auth.py b/nilai-api/src/nilai_api/config/auth.py index 4e64e812..a21c03a2 100644 --- a/nilai-api/src/nilai_api/config/auth.py +++ b/nilai-api/src/nilai_api/config/auth.py @@ -4,12 +4,12 @@ class AuthConfig(BaseModel): auth_strategy: Literal["api_key", "jwt", "nuc"] = Field( - description="Authentication strategy" + default="api_key", description="Authentication strategy" ) nilauth_trusted_root_issuers: List[str] = Field( - description="Trusted root issuers for nilauth" + default_factory=list, description="Trusted root issuers for nilauth" ) - credit_api_token: str = Field(description="Credit service API token") + credit_api_token: str = Field(default="", description="Credit service API token") auth_token: Optional[str] = Field( default=None, description="Auth token for e2e tests and development" ) diff --git a/nilai-api/src/nilai_api/config/database.py b/nilai-api/src/nilai_api/config/database.py index 3e9aa761..94e1d92e 100644 --- a/nilai-api/src/nilai_api/config/database.py +++ b/nilai-api/src/nilai_api/config/database.py @@ -2,11 +2,11 @@ class DatabaseConfig(BaseModel): - user: str = Field(description="Database user") - password: str = Field(description="Database password") - host: str = Field(description="Database host") - port: int = Field(description="Database port") - db: str = Field(description="Database name") + user: str = Field(default="", description="Database user") + password: str = Field(default="", description="Database password") + host: str = Field(default="", description="Database host") + port: int = Field(default=5432, description="Database port") + db: str = Field(default="", description="Database name") class DiscoveryConfig(BaseModel): @@ -17,4 +17,6 @@ class DiscoveryConfig(BaseModel): class RedisConfig(BaseModel): - url: str = Field(description="Redis URL for rate limiting") + url: str = Field( + default="redis://localhost:6379", description="Redis URL for rate limiting" + ) diff --git a/nilai-api/src/nilai_api/config/nildb.py b/nilai-api/src/nilai_api/config/nildb.py index 7ff72cab..f4223149 100644 --- a/nilai-api/src/nilai_api/config/nildb.py +++ b/nilai-api/src/nilai_api/config/nildb.py @@ -4,11 +4,18 @@ class NilDBConfig(BaseModel): - nilchain_url: str = Field(..., description="The URL of the Nilchain") - nilauth_url: str = Field(..., description="The URL of the Nilauth") - nodes: List[str] = Field(..., description="The URLs of the Nildb nodes") - builder_private_key: str = Field(..., description="The private key of the builder") - collection: Uuid = Field(..., description="The ID of the collection") + nilchain_url: str = Field(default="", description="The URL of the Nilchain") + nilauth_url: str = Field(default="", description="The URL of the Nilauth") + nodes: List[str] = Field( + default_factory=list, description="The URLs of the Nildb nodes" + ) + builder_private_key: str = Field( + default="", description="The private key of the builder" + ) + collection: Uuid = Field( + default=Uuid("00000000-0000-0000-0000-000000000000"), + description="The ID of the collection", + ) @field_validator("nodes", mode="before") @classmethod diff --git a/nilai-models/run.sh b/nilai-models/run.sh index 72175f6e..67f72f90 100644 --- a/nilai-models/run.sh +++ b/nilai-models/run.sh @@ -30,4 +30,4 @@ main() { exit $? } -main "$@" \ No newline at end of file +main "$@" diff --git a/tests/e2e/test_chat_completions.py b/tests/e2e/test_chat_completions.py index dd362885..77f59c79 100644 --- a/tests/e2e/test_chat_completions.py +++ b/tests/e2e/test_chat_completions.py @@ -625,10 +625,9 @@ def test_chat_completion_high_temperature(client): assert response, "High temperature request should return a valid response" assert response.choices, "Response should contain choices" assert len(response.choices) > 0, "At least one choice should be present" - assert ( - response.choices[0].message.content - or response.choices[0].message.reasoning_content - ), "Response should contain content or reasoning_content" + assert response.choices[0].message.content or getattr( + response.choices[0].message, "reasoning", None + ), "Response should contain content or reasoning" def test_model_streaming_request_high_token(client): @@ -689,10 +688,8 @@ def test_web_search(client, model, high_web_search_rate_limit): assert len(response.choices) > 0, "Response should contain at least one choice" content = response.choices[0].message.content - reasoning_content = getattr(response.choices[0].message, "reasoning_content", None) - assert content or reasoning_content, ( - "Response should contain content or reasoning_content" - ) + reasoning = getattr(response.choices[0].message, "reasoning", None) + assert content or reasoning, "Response should contain content or reasoning" sources = getattr(response, "sources", None) assert sources is not None, "Sources field should not be None" diff --git a/tests/e2e/test_chat_completions_http.py b/tests/e2e/test_chat_completions_http.py index b7dffcef..fd79e8a2 100644 --- a/tests/e2e/test_chat_completions_http.py +++ b/tests/e2e/test_chat_completions_http.py @@ -791,11 +791,9 @@ def test_web_search(client, model, high_web_search_rate_limit): message = response_json["choices"][0].get("message", {}) content = message.get("content", "") - reasoning_content = message.get("reasoning_content", "") + reasoning = message.get("reasoning", "") - assert content or reasoning_content, ( - "Response should contain content or reasoning_content" - ) + assert content or reasoning, "Response should contain content or reasoning" sources = response_json.get("sources") if sources is not None: