Spaces:
Runtime error
Runtime error
no translate
Browse files- bmtools/agent/translator.py +18 -17
bmtools/agent/translator.py
CHANGED
@@ -31,23 +31,24 @@ class Translator:
|
|
31 |
self.chain = LLMChain(llm=llm, prompt=prompt)
|
32 |
|
33 |
def __call__(self, inputs: Dict[str, str]) -> Dict[str, str]:
|
34 |
-
if not self.is_create:
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
question = inputs["input"]
|
39 |
-
answer = inputs["output"]
|
40 |
-
|
41 |
-
src_lang = detect_lang(answer)
|
42 |
-
tgt_lang = detect_lang(question)
|
43 |
-
|
44 |
-
if src_lang != tgt_lang:
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
else:
|
50 |
-
|
|
|
51 |
|
52 |
def create_openai_model(self, openai_api_key: str, model_name: str) -> OpenAI:
|
53 |
if openai_api_key is None:
|
|
|
31 |
self.chain = LLMChain(llm=llm, prompt=prompt)
|
32 |
|
33 |
def __call__(self, inputs: Dict[str, str]) -> Dict[str, str]:
|
34 |
+
# if not self.is_create:
|
35 |
+
# self.create_chain()
|
36 |
+
# self.is_create = True
|
37 |
+
#
|
38 |
+
# question = inputs["input"]
|
39 |
+
# answer = inputs["output"]
|
40 |
+
#
|
41 |
+
# src_lang = detect_lang(answer)
|
42 |
+
# tgt_lang = detect_lang(question)
|
43 |
+
#
|
44 |
+
# if src_lang != tgt_lang:
|
45 |
+
# translated_answer = self.chain.run(text=answer, language=tgt_lang)
|
46 |
+
# outputs = deepcopy(inputs)
|
47 |
+
# outputs["output"] = translated_answer
|
48 |
+
# return outputs
|
49 |
+
# else:
|
50 |
+
# return inputs
|
51 |
+
return inputs
|
52 |
|
53 |
def create_openai_model(self, openai_api_key: str, model_name: str) -> OpenAI:
|
54 |
if openai_api_key is None:
|