|
50 | 50 | ReplicateTextToSpeechTask,
|
51 | 51 | )
|
52 | 52 | from huggingface_hub.inference._providers.sambanova import SambanovaConversationalTask, SambanovaFeatureExtractionTask
|
| 53 | +from huggingface_hub.inference._providers.scaleway import ScalewayConversationalTask, ScalewayFeatureExtractionTask |
53 | 54 | from huggingface_hub.inference._providers.together import TogetherTextToImageTask
|
54 | 55 |
|
55 | 56 | from .testing_utils import assert_in_logs
|
@@ -1052,6 +1053,75 @@ def test_prepare_url_conversational(self):
|
1052 | 1053 | assert url == "https://api.novita.ai/v3/openai/chat/completions"
|
1053 | 1054 |
|
1054 | 1055 |
|
| 1056 | +class TestScalewayProvider: |
| 1057 | + def test_prepare_hf_url_conversational(self): |
| 1058 | + helper = ScalewayConversationalTask() |
| 1059 | + url = helper._prepare_url("hf_token", "username/repo_name") |
| 1060 | + assert url == "https://router.huggingface.co/scaleway/v1/chat/completions" |
| 1061 | + |
| 1062 | + def test_prepare_url_conversational(self): |
| 1063 | + helper = ScalewayConversationalTask() |
| 1064 | + url = helper._prepare_url("scw_token", "username/repo_name") |
| 1065 | + assert url == "https://api.scaleway.ai/v1/chat/completions" |
| 1066 | + |
| 1067 | + def test_prepare_payload_as_dict(self): |
| 1068 | + helper = ScalewayConversationalTask() |
| 1069 | + payload = helper._prepare_payload_as_dict( |
| 1070 | + [ |
| 1071 | + {"role": "system", "content": "You are a helpful assistant"}, |
| 1072 | + {"role": "user", "content": "Hello!"}, |
| 1073 | + ], |
| 1074 | + { |
| 1075 | + "max_tokens": 512, |
| 1076 | + "temperature": 0.15, |
| 1077 | + "top_p": 1, |
| 1078 | + "presence_penalty": 0, |
| 1079 | + "stream": True, |
| 1080 | + }, |
| 1081 | + InferenceProviderMapping( |
| 1082 | + provider="scaleway", |
| 1083 | + hf_model_id="meta-llama/Llama-3.1-8B-Instruct", |
| 1084 | + providerId="meta-llama/llama-3.1-8B-Instruct", |
| 1085 | + task="conversational", |
| 1086 | + status="live", |
| 1087 | + ), |
| 1088 | + ) |
| 1089 | + assert payload == { |
| 1090 | + "max_tokens": 512, |
| 1091 | + "messages": [ |
| 1092 | + {"content": "You are a helpful assistant", "role": "system"}, |
| 1093 | + {"role": "user", "content": "Hello!"}, |
| 1094 | + ], |
| 1095 | + "model": "meta-llama/llama-3.1-8B-Instruct", |
| 1096 | + "presence_penalty": 0, |
| 1097 | + "stream": True, |
| 1098 | + "temperature": 0.15, |
| 1099 | + "top_p": 1, |
| 1100 | + } |
| 1101 | + |
| 1102 | + def test_prepare_url_feature_extraction(self): |
| 1103 | + helper = ScalewayFeatureExtractionTask() |
| 1104 | + assert ( |
| 1105 | + helper._prepare_url("hf_token", "username/repo_name") |
| 1106 | + == "https://router.huggingface.co/scaleway/v1/embeddings" |
| 1107 | + ) |
| 1108 | + |
| 1109 | + def test_prepare_payload_as_dict_feature_extraction(self): |
| 1110 | + helper = ScalewayFeatureExtractionTask() |
| 1111 | + payload = helper._prepare_payload_as_dict( |
| 1112 | + "Example text to embed", |
| 1113 | + {"truncate": True}, |
| 1114 | + InferenceProviderMapping( |
| 1115 | + provider="scaleway", |
| 1116 | + hf_model_id="username/repo_name", |
| 1117 | + providerId="provider-id", |
| 1118 | + task="feature-extraction", |
| 1119 | + status="live", |
| 1120 | + ), |
| 1121 | + ) |
| 1122 | + assert payload == {"input": "Example text to embed", "model": "provider-id", "truncate": True} |
| 1123 | + |
| 1124 | + |
1055 | 1125 | class TestNscaleProvider:
|
1056 | 1126 | def test_prepare_route_text_to_image(self):
|
1057 | 1127 | helper = NscaleTextToImageTask()
|
|
0 commit comments