|
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
|
@@ -1077,6 +1078,75 @@ def test_prepare_url_conversational(self):
|
1077 | 1078 | assert url == "https://api.novita.ai/v3/openai/chat/completions"
|
1078 | 1079 |
|
1079 | 1080 |
|
| 1081 | +class TestScalewayProvider: |
| 1082 | + def test_prepare_hf_url_conversational(self): |
| 1083 | + helper = ScalewayConversationalTask() |
| 1084 | + url = helper._prepare_url("hf_token", "username/repo_name") |
| 1085 | + assert url == "https://router.huggingface.co/scaleway/v1/chat/completions" |
| 1086 | + |
| 1087 | + def test_prepare_url_conversational(self): |
| 1088 | + helper = ScalewayConversationalTask() |
| 1089 | + url = helper._prepare_url("scw_token", "username/repo_name") |
| 1090 | + assert url == "https://api.scaleway.ai/v1/chat/completions" |
| 1091 | + |
| 1092 | + def test_prepare_payload_as_dict(self): |
| 1093 | + helper = ScalewayConversationalTask() |
| 1094 | + payload = helper._prepare_payload_as_dict( |
| 1095 | + [ |
| 1096 | + {"role": "system", "content": "You are a helpful assistant"}, |
| 1097 | + {"role": "user", "content": "Hello!"}, |
| 1098 | + ], |
| 1099 | + { |
| 1100 | + "max_tokens": 512, |
| 1101 | + "temperature": 0.15, |
| 1102 | + "top_p": 1, |
| 1103 | + "presence_penalty": 0, |
| 1104 | + "stream": True, |
| 1105 | + }, |
| 1106 | + InferenceProviderMapping( |
| 1107 | + provider="scaleway", |
| 1108 | + hf_model_id="meta-llama/Llama-3.1-8B-Instruct", |
| 1109 | + providerId="meta-llama/llama-3.1-8B-Instruct", |
| 1110 | + task="conversational", |
| 1111 | + status="live", |
| 1112 | + ), |
| 1113 | + ) |
| 1114 | + assert payload == { |
| 1115 | + "max_tokens": 512, |
| 1116 | + "messages": [ |
| 1117 | + {"content": "You are a helpful assistant", "role": "system"}, |
| 1118 | + {"role": "user", "content": "Hello!"}, |
| 1119 | + ], |
| 1120 | + "model": "meta-llama/llama-3.1-8B-Instruct", |
| 1121 | + "presence_penalty": 0, |
| 1122 | + "stream": True, |
| 1123 | + "temperature": 0.15, |
| 1124 | + "top_p": 1, |
| 1125 | + } |
| 1126 | + |
| 1127 | + def test_prepare_url_feature_extraction(self): |
| 1128 | + helper = ScalewayFeatureExtractionTask() |
| 1129 | + assert ( |
| 1130 | + helper._prepare_url("hf_token", "username/repo_name") |
| 1131 | + == "https://router.huggingface.co/scaleway/v1/embeddings" |
| 1132 | + ) |
| 1133 | + |
| 1134 | + def test_prepare_payload_as_dict_feature_extraction(self): |
| 1135 | + helper = ScalewayFeatureExtractionTask() |
| 1136 | + payload = helper._prepare_payload_as_dict( |
| 1137 | + "Example text to embed", |
| 1138 | + {"truncate": True}, |
| 1139 | + InferenceProviderMapping( |
| 1140 | + provider="scaleway", |
| 1141 | + hf_model_id="username/repo_name", |
| 1142 | + providerId="provider-id", |
| 1143 | + task="feature-extraction", |
| 1144 | + status="live", |
| 1145 | + ), |
| 1146 | + ) |
| 1147 | + assert payload == {"input": "Example text to embed", "model": "provider-id", "truncate": True} |
| 1148 | + |
| 1149 | + |
1080 | 1150 | class TestNscaleProvider:
|
1081 | 1151 | def test_prepare_route_text_to_image(self):
|
1082 | 1152 | helper = NscaleTextToImageTask()
|
|
0 commit comments