File size: 638 Bytes
e717066
df4d00f
5488267
e717066
 
 
5488267
e717066
 
 
 
 
5488267
e717066
 
ea1604a
e717066
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests
import os

# Hugging Face APIエンドポイントと認証トークン
api_url = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}

# クエリのメッセージ
payload = {
    "inputs": "Which of the depicted countries has the best food?",
    "parameters": {"max_new_tokens": 512}
}

# APIリクエスト
response = requests.post(api_url, headers=headers, json=payload)

# 結果表示
if response.status_code == 200:
    print("Response:", response.json())
else:
    print(f"Error {response.status_code}: {response.text}")