MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / __call__

Method __call__

bmtools/agent/translator.py:32–48  ·  view source on GitHub ↗
(self, inputs: Dict[str, str])

Source from the content-addressed store, hash-verified

30 self.init_flag = True
31
32 def __call__(self, inputs: Dict[str, str]) -> Dict[str, str]:
33 if not self.init_flag:
34 self.init_model()
35
36 question = inputs["input"]
37 answer = inputs["output"]
38
39 src_lang = detect_lang(answer)
40 tgt_lang = detect_lang(question)
41
42 if src_lang != tgt_lang:
43 translated_answer = self.chain.run(text=answer, language=tgt_lang)
44 outputs = deepcopy(inputs)
45 outputs["output"] = translated_answer
46 return outputs
47 else:
48 return inputs
49
50 def create_openai_model(self, openai_api_key: str, model_name: str) -> OpenAI:
51 if openai_api_key is None:

Callers

nothing calls this directly

Calls 3

init_modelMethod · 0.95
detect_langFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected