File size: 677 Bytes
01d8a88 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import os
from huggingface_hub import InferenceClient
# Load token from Hugging Face Space Secrets
HF_TOKEN = os.getenv("HF_TOKEN")
if not HF_TOKEN:
raise ValueError("HF_TOKEN is missing in Space Secrets")
# Direct inference client (NO router, NO provider)
client = InferenceClient(
model="Qwen/Qwen2.5-7B-Instruct",
token=HF_TOKEN
)
def agent(query: str) -> str:
"""
Simple stable agent function (no smolagents, no wrappers).
"""
response = client.chat_completion(
messages=[
{"role": "user", "content": query}
],
max_tokens=512,
temperature=0.1
)
return response.choices[0].message.content |