Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed name, added documentation URL #123

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions aixplain/factories/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,10 @@ def onboard_model(cls, model_id: Text, image_tag: Text, image_hash: Text, api_ke
return response

@classmethod
def deploy_huggingface_model(cls, name: Text, hf_repo_id: Text, hf_token: Optional[Text] = "", api_key: Optional[Text] = None) -> Dict:
def deploy_huggingface_model(cls, hf_repo_id: Text, hf_token: Optional[Text] = "", api_key: Optional[Text] = None) -> Dict:
"""Onboards and deploys a Hugging Face large language model.

Args:
name (Text): The user's name for the model.
hf_repo_id (Text): The Hugging Face repository ID for this model ({author}/{model name}).
hf_token (Text, optional): Hugging Face access token. Defaults to None.
api_key (Text, optional): Team API key. Defaults to None.
Expand All @@ -425,11 +424,10 @@ def deploy_huggingface_model(cls, name: Text, hf_repo_id: Text, hf_token: Option
headers = {"Authorization": f"Token {config.TEAM_API_KEY}", "Content-Type": "application/json"}
body = {
"model": {
"name": name,
"description": "A user-deployed Hugging Face model",
"description": f"{supplier} {model_name} deployed from Hugging Face.",
"connectionType": ["synchronous"],
"function": "text-generation",
"documentationUrl": "aiXplain",
"documentationUrl": f"https://huggingface.co/{supplier}/{model_name}",
"sourceLanguage": "en",
},
"source": "huggingface",
Expand Down
16 changes: 8 additions & 8 deletions tests/functional/model/hf_onboarding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

def test_deploy_model():
# Start the deployment
model_name = "Test Model"
repo_id = "tiiuae/falcon-7b"
response = ModelFactory.deploy_huggingface_model(model_name, repo_id, config.HF_TOKEN)
documentation_url = "https://huggingface.co/tiiuae/falcon-7b"
response = ModelFactory.deploy_huggingface_model(repo_id, documentation_url, config.HF_TOKEN)
assert "id" in response.keys()

# Check for status
Expand All @@ -28,24 +28,24 @@ def test_deploy_model():

def test_nonexistent_model():
# Start the deployment
model_name = "Test Model"
repo_id = "nonexistent-supplier/nonexistent-model"
response = ModelFactory.deploy_huggingface_model(model_name, repo_id, config.HF_TOKEN)
documentation_url = "mock_url"
response = ModelFactory.deploy_huggingface_model(repo_id, documentation_url, config.HF_TOKEN)
assert response["statusCode"] == 400
assert response["message"] == "err.unable_to_onboard_model"

def test_size_limit():
# Start the deployment
model_name = "Test Model"
repo_id = "tiiuae/falcon-40b"
response = ModelFactory.deploy_huggingface_model(model_name, repo_id, config.HF_TOKEN)
documentation_url = "https://huggingface.co/tiiuae/falcon-40b"
response = ModelFactory.deploy_huggingface_model(repo_id, documentation_url, config.HF_TOKEN)
assert response["statusCode"] == 400
assert response["message"] == "err.unable_to_onboard_model"

def test_gated_model():
# Start the deployment
model_name = "Test Model"
repo_id = "meta-llama/Llama-2-7b-hf"
response = ModelFactory.deploy_huggingface_model(model_name, repo_id, "mock_key")
documentation_url = "https://huggingface.co/meta-llama/Llama-2-7b-hf"
response = ModelFactory.deploy_huggingface_model(repo_id, documentation_url, "mock_key")
assert response["statusCode"] == 400
assert response["message"] == "err.unable_to_onboard_model"