First_agent_template / tools /singlish_translator.py
Rafiq Rosman
Added is_initialized to singlish translator tool
96df57d
raw
history blame contribute delete
668 Bytes
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