初始化项目,由ModelHub XC社区提供模型
Model: mideind/icelandic-gpt-sw3-6.7b-gec Source: Original Platform
This commit is contained in:
34
run_model.py
Normal file
34
run_model.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
Script for running the model using the Hugging Face endpoint. An authorized Hugging Face API key is required.
|
||||
"""
|
||||
|
||||
import requests
|
||||
import os
|
||||
|
||||
API_URL = "https://otaf5w2ge8huxngl.eu-west-1.aws.endpoints.huggingface.cloud"
|
||||
# Set your Hugging Face API key as an environment variable
|
||||
api_key = os.environ.get("HF_API_KEY")
|
||||
headers = {
|
||||
"Accept": "application/json",
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def query(payload):
|
||||
response = requests.post(API_URL, headers=headers, json=payload)
|
||||
return response.json()
|
||||
|
||||
|
||||
output = query(
|
||||
{
|
||||
"inputs": "", # Can be left empty.
|
||||
"input_a": "<text A>", # Required for all tasks.
|
||||
"input_b": "<text B>", # Required for task 2 but not for task 1 or 3.
|
||||
"task": 1 | 2 | 3, # Choose the task number.
|
||||
"parameters": {
|
||||
# Can be left empty
|
||||
},
|
||||
}
|
||||
)
|
||||
print(output)
|
||||
Reference in New Issue
Block a user