Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hanouticelina committed Feb 14, 2025
1 parent bbbb12d commit e679891
Show file tree
Hide file tree
Showing 5 changed files with 539 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/huggingface_hub/inference/_providers/hyperbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def _prepare_payload_as_dict(self, inputs: Any, parameters: Dict, mapped_model:
parameters["steps"] = parameters.pop("num_inference_steps")
if "guidance_scale" in parameters:
parameters["cfg_scale"] = parameters.pop("guidance_scale")
# For Hyperbolic, the width and height are required parameters
if "width" not in parameters:
parameters["width"] = 512
if "height" not in parameters:
parameters["height"] = 512
return {"prompt": inputs, "model_name": mapped_model, **parameters}

def get_response(self, response: Union[bytes, Dict]) -> Any:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
X-Amzn-Trace-Id:
- f240d30a-9b93-48f2-a781-80c8e318e585
method: GET
uri: https://huggingface.co/api/models/meta-llama/Llama-3.2-3B-Instruct?expand=inferenceProviderMapping
response:
body:
string: '{"_id":"66eaef786865fea1324edb5d","id":"meta-llama/Llama-3.2-3B-Instruct","inferenceProviderMapping":{"fireworks-ai":{"status":"staging","providerId":"accounts/fireworks/models/llama-v3p2-3b-instruct","task":"conversational"},"sambanova":{"status":"live","providerId":"Meta-Llama-3.2-3B-Instruct","task":"conversational"},"together":{"status":"live","providerId":"meta-llama/Llama-3.2-3B-Instruct-Turbo","task":"conversational"},"hf-inference":{"status":"live","providerId":"meta-llama/Llama-3.2-3B-Instruct","task":"conversational"},"nebius":{"status":"staging","providerId":"meta-llama/Llama-3.2-3B-Instruct","task":"conversational"},"novita":{"status":"staging","providerId":"meta-llama/llama-3.2-3b-instruct","task":"conversational"},"hyperbolic":{"status":"staging","providerId":"meta-llama/Llama-3.2-3B-Instruct","task":"conversational"}}}'
headers:
Access-Control-Allow-Origin:
- https://huggingface.co
Access-Control-Expose-Headers:
- X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Xet-Access-Token,X-Xet-Token-Expiration,X-Xet-Refresh-Route,X-Xet-Cas-Url,X-Xet-Hash
Connection:
- keep-alive
Content-Length:
- '845'
Content-Type:
- application/json; charset=utf-8
Date:
- Fri, 14 Feb 2025 13:27:49 GMT
ETag:
- W/"34d-CxprGZuC6rOGzn4LlkoLmsGVV/U"
Referrer-Policy:
- strict-origin-when-cross-origin
Vary:
- Origin
Via:
- 1.1 4a09ca83280b6b5f15a5c3da38e16cc4.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- hmvaCatS26JOMGFzzSri3EHEwlqcajSLEyWs_slvzIxugD1miLP5EQ==
X-Amz-Cf-Pop:
- CDG52-P4
X-Cache:
- Miss from cloudfront
X-Powered-By:
- huggingface-moon
X-Request-Id:
- Root=1-67af44d5-37910ace6d19456d739350ce;f240d30a-9b93-48f2-a781-80c8e318e585
cross-origin-opener-policy:
- same-origin
status:
code: 200
message: OK
- request:
body: '{"messages": [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is deep learning?"}], "model": "meta-llama/Llama-3.2-3B-Instruct",
"stream": false}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '194'
Content-Type:
- application/json
X-Amzn-Trace-Id:
- 0f652278-fd50-4424-a806-1ee795b0a0bb
method: POST
uri: https://router.huggingface.co/hyperbolic/v1/chat/completions
response:
body:
string: '{"id":"chat-b87e29af773c4d28acd93ab9873bf8fb","object":"chat.completion","created":1739539670,"model":"meta-llama/Llama-3.2-3B-Instruct","choices":[{"index":0,"message":{"role":"assistant","content":"Deep
learning is a subset of machine learning that involves the use of artificial
neural networks (ANNs) to analyze and interpret data. It is called \"deep\"
learning because these neural networks have multiple layers, similar to the
structure of the human brain.\n\nIn traditional machine learning, models are
typically trained on a small number of features and use a shallow architecture.
In contrast, deep learning models can learn complex patterns and relationships
in data by using a large number of layers, each of which performs a specific
task, such as:\n\n1. Feature extraction: extracting relevant features from
raw data\n2. Transformation: transforming the extracted features into a more
suitable format\n3. Classification: classifying the data into different categories\n4.
Regression: predicting a continuous value\n\nThe key characteristics of deep
learning models are:\n\n1. **Multi-layered architecture**: deep learning models
have multiple layers, which allow them to learn complex patterns and relationships
in data.\n2. **Large datasets**: deep learning models require large datasets
to learn and generalize well.\n3. **Automatic feature learning**: deep learning
models can learn features automatically from raw data, eliminating the need
for manual feature engineering.\n4. **Non-linear relationships**: deep learning
models can learn non-linear relationships between inputs and outputs, which
are common in real-world data.\n\nDeep learning models are widely used in
many applications, including:\n\n1. **Computer vision**: image recognition,
object detection, segmentation, and generation\n2. **Natural language processing**:
text classification, sentiment analysis, language translation, and text generation\n3.
**Speech recognition**: speech-to-text and text-to-speech synthesis\n4. **Robotics**:
motion planning, control, and manipulation\n5. **Healthcare**: disease diagnosis,
patient outcomes prediction, and medical image analysis\n\nSome popular deep
learning algorithms include:\n\n1. **Convolutional neural networks (CNNs)**:
used for image and video analysis\n2. **Recurrent neural networks (RNNs)**:
used for sequential data analysis, such as speech and text\n3. **Long short-term
memory (LSTM) networks**: a type of RNN used for sequential data analysis\n4.
**Generative adversarial networks (GANs)**: used for generating new data samples
that resemble existing data\n\nOverall, deep learning has revolutionized the
field of machine learning and has many applications in various industries."},"finish_reason":"stop","logprobs":null}],"usage":{"prompt_tokens":46,"total_tokens":523,"completion_tokens":477}}'
headers:
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-Repo-Commit,X-Request-Id,X-Error-Code,X-Error-Message,X-Total-Count,ETag,Link,Accept-Ranges,Content-Range,X-Xet-Access-Token,X-Xet-Token-Expiration,X-Xet-Refresh-Route,X-Xet-Cas-Url,X-Xet-Hash
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Fri, 14 Feb 2025 13:27:52 GMT
Referrer-Policy:
- strict-origin-when-cross-origin
Transfer-Encoding:
- chunked
Vary:
- Origin
Via:
- 1.1 4de8cc07f214b77e50bb78828ddb1362.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- SfQDgtXFjNo_eDyAx_jvunwoTnlnLAtgSrizQbTT8iVK3Mcrkz8YMw==
X-Amz-Cf-Pop:
- CDG55-P3
X-Cache:
- Miss from cloudfront
X-Powered-By:
- huggingface-moon
X-Request-Id:
- Root=1-67af44d5-5ac681b23efa303d07c55cc1;0f652278-fd50-4424-a806-1ee795b0a0bb
cf-cache-status:
- DYNAMIC
cf-ray:
- 911d65d73efc2009-IAD
cross-origin-opener-policy:
- same-origin
server:
- cloudflare
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit e679891

Please sign in to comment.