Spaces:
Running
Running
File size: 648 Bytes
a8a9aac 5291dbb a8a9aac c174e39 a8a9aac 31f5639 a8a9aac 203416d a8a9aac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from huggingface_hub import InferenceClient
import os
def query_model(prompt):
try:
HF_TOKEN = os.getenv("HF_TOKEN")
client = InferenceClient(
model="Qwen/Qwen2.5-7B-Instruct",
token=HF_TOKEN
)
response = client.chat_completion(
messages=[
{"role": "system", "content": "You are a professional fitness trainer."},
{"role": "user", "content": prompt}
],
max_tokens=1500,
temperature=0.7
)
return response.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}" |