import os from huggingface_hub import InferenceClient MODEL_ID = "Sedibaai/SedibaLM" HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("LEOTSA_HF_TOKEN") _client = InferenceClient(model=MODEL_ID, token=HF_TOKEN or None) def sedibalm_generate(user_text: str, max_new_tokens: int = 128) -> str: messages = [{"role": "user", "content": user_text}] try: return _client.chat_completion( messages=messages, max_new_tokens=max_new_tokens, temperature=0.7, top_p=0.8, repetition_penalty=1.3, ).choices[0].message.content.strip() except Exception as e: return f"[inference error] {type(e).__name__}: {e}"