Rafiq Rosman commited on
Commit
bf2d497
·
1 Parent(s): 21a3fd9

Adding singlish _translator_tool

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. tools/singlish_translator.py +15 -0
app.py CHANGED
@@ -55,7 +55,7 @@ with open("concised_prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer, image_generation_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
55
 
56
  agent = CodeAgent(
57
  model=model,
58
+ tools=[final_answer, image_generation_tool, singlish_translator_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
tools/singlish_translator.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from huggingface_hub import InferenceClient
3
+
4
+ class SinglishTranslatorTool(Tool):
5
+ name = "singlish_translator"
6
+ description = "A tool that translates English to Singlish."
7
+ inputs = {'text': {'type': 'string', 'description': 'The text to translate.'}}
8
+ output_type = "string"
9
+ model = "h2oai/danube2-singlish-finetuned"
10
+ client = InferenceClient(model)
11
+
12
+ def forward(self, text: str) -> str:
13
+ return self.client.generate(text)
14
+
15
+