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
10 changes: 6 additions & 4 deletions nilai-api/src/nilai_api/auth.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from fastapi import HTTPException, Security, status
from fastapi.security import APIKeyHeader
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from nilai_api.db import UserManager

UserManager.initialize_db()

api_key_header = APIKeyHeader(name="X-API-Key")
bearer_scheme = HTTPBearer()


def get_user(api_key_header: str = Security(api_key_header)):
user = UserManager.check_api_key(api_key_header)
def get_user(credentials: HTTPAuthorizationCredentials = Security(bearer_scheme)):
token = credentials.credentials
print(token)
user = UserManager.check_api_key(token)
if user:
return user
raise HTTPException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self):
# Provides comprehensive information about the model
super().__init__(
ModelMetadata(
id="bartowski/Llama-3.2-1B-Instruct-GGUF", # Unique identifier
id="Llama-3.2-1B-Instruct", # Unique identifier
name="Llama-3.2-1B-Instruct", # Human-readable name
version="1.0", # Model version
description="Llama is a large language model trained on supervised and unsupervised data.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self):
# Provides comprehensive information about the model
super().__init__(
ModelMetadata(
id="bartowski/Meta-Llama-3-8B-Instruct-GGUF", # Unique identifier
id="Llama-3.1-8B-Instruct", # Unique identifier
name="Llama-3.1-8B-Instruct", # Human-readable name
version="1.0", # Model version
description="Llama is a large language model trained on supervised and unsupervised data.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def __init__(self):
# Provides comprehensive information about the model
super().__init__(
ModelMetadata(
id="bartowski/Llama-3.2-1B-Instruct-GGUF", # Unique identifier
id="CheesyLlama", # Unique identifier
name="CheesyLlama", # Human-readable name
version="1.0", # Model version
description="Llama is a large language model trained on supervised and unsupervised data.",
description="Llama is a large language model trained on supervised and unsupervised cheese.",
author="Meta-Llama", # Model creators
license="Apache 2.0", # Usage license
source="https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF", # Model source
Expand Down
9 changes: 4 additions & 5 deletions packages/nilai-common/src/nilai_common/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def register_model(
lease = self.client.lease(self.lease_ttl)

# Prepare the key and value
key = f"{prefix}/{model_endpoint.metadata.name}"
key = f"{prefix}/{model_endpoint.metadata.id}"
value = model_endpoint.model_dump_json()

# Put the key-value pair with the lease
Expand Down Expand Up @@ -71,10 +71,9 @@ async def discover_models(
):
continue

discovered_models[model_endpoint.metadata.name] = model_endpoint
discovered_models[model_endpoint.metadata.id] = model_endpoint
except Exception as e:
print(f"Error parsing model endpoint: {e}")

return discovered_models

async def get_model(
Expand Down Expand Up @@ -149,7 +148,7 @@ async def main():
)
print("FOUND: ", len(discovered_models))
for model in discovered_models.values():
print(f"Discovered Model: {model.metadata.name}")
print(f"Discovered Model: {model.metadata.id}")
print(f"URL: {model.url}")
print(f"Supported Features: {model.metadata.supported_features}")

Expand All @@ -161,7 +160,7 @@ async def main():
)
print("FOUND: ", len(discovered_models))
for model in discovered_models.values():
print(f"Discovered Model: {model.metadata.name}")
print(f"Discovered Model: {model.metadata.id}")
print(f"URL: {model.url}")
print(f"Supported Features: {model.metadata.supported_features}")

Expand Down