diff --git a/nilai-api/src/nilai_api/auth.py b/nilai-api/src/nilai_api/auth.py index 1390f536..1e16e9a9 100644 --- a/nilai-api/src/nilai_api/auth.py +++ b/nilai-api/src/nilai_api/auth.py @@ -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( diff --git a/nilai-models/src/nilai_models/models/llama_1b_cpu/llama_1b_cpu.py b/nilai-models/src/nilai_models/models/llama_1b_cpu/llama_1b_cpu.py index bb029ff1..e133a0b1 100644 --- a/nilai-models/src/nilai_models/models/llama_1b_cpu/llama_1b_cpu.py +++ b/nilai-models/src/nilai_models/models/llama_1b_cpu/llama_1b_cpu.py @@ -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.", diff --git a/nilai-models/src/nilai_models/models/llama_8b_cpu/llama_8b_cpu.py b/nilai-models/src/nilai_models/models/llama_8b_cpu/llama_8b_cpu.py index 975f7dfa..57026944 100644 --- a/nilai-models/src/nilai_models/models/llama_8b_cpu/llama_8b_cpu.py +++ b/nilai-models/src/nilai_models/models/llama_8b_cpu/llama_8b_cpu.py @@ -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.", diff --git a/nilai-models/src/nilai_models/models/secret_llama_1b_cpu/secret_llama_1b_cpu.py b/nilai-models/src/nilai_models/models/secret_llama_1b_cpu/secret_llama_1b_cpu.py index 5a9f18e1..70f4d43e 100644 --- a/nilai-models/src/nilai_models/models/secret_llama_1b_cpu/secret_llama_1b_cpu.py +++ b/nilai-models/src/nilai_models/models/secret_llama_1b_cpu/secret_llama_1b_cpu.py @@ -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 diff --git a/packages/nilai-common/src/nilai_common/db.py b/packages/nilai-common/src/nilai_common/db.py index 70bd8fca..8f58452b 100644 --- a/packages/nilai-common/src/nilai_common/db.py +++ b/packages/nilai-common/src/nilai_common/db.py @@ -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 @@ -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( @@ -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}") @@ -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}")