Spaces:
Sleeping
Sleeping
from smolagents import Tool | |
from huggingface_hub import InferenceClient | |
class SinglishTranslatorTool(Tool): | |
name = "singlish_translator" | |
description = "A tool that translates English to Singlish." | |
inputs = {'text': {'type': 'string', 'description': 'The text to translate.'}} | |
output_type = "string" | |
def __init__(self): | |
super().__init__() # Ensure Tool is properly initialized | |
self.client = InferenceClient("h2oai/danube2-singlish-finetuned") | |
self.is_initialized = True # Required by smolagents.Tool | |
def forward(self, text: str) -> str: | |
return self.client.text_generation(prompt=text) # Correct API call |