Spaces:
Sleeping
Sleeping
File size: 668 Bytes
bf2d497 5c4d7fa 96df57d 5c4d7fa 96df57d 5c4d7fa 96df57d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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 |