Spaces:
Running
Running
Update apis/chat_api.py
Browse files- apis/chat_api.py +6 -3
apis/chat_api.py
CHANGED
@@ -148,11 +148,11 @@ class ChatAPIApp:
|
|
148 |
)
|
149 |
from_language: str = Field(
|
150 |
default="en",
|
151 |
-
description="(str) `
|
152 |
)
|
153 |
to_language: str = Field(
|
154 |
default="fa",
|
155 |
-
description="(str) `
|
156 |
)
|
157 |
input_text: str = Field(
|
158 |
default="Hello",
|
@@ -178,7 +178,10 @@ class ChatAPIApp:
|
|
178 |
read_model = AutoModelForSeq2SeqLM.from_pretrained(real_name)
|
179 |
tokenizer = AutoTokenizer.from_pretrained(real_name)
|
180 |
#translator = pipeline("translation", model=read_model, tokenizer=tokenizer, src_lang=item.from_language, tgt_lang=item.to_language)
|
181 |
-
|
|
|
|
|
|
|
182 |
result = translator(item.input_text)
|
183 |
|
184 |
item_response = {
|
|
|
148 |
)
|
149 |
from_language: str = Field(
|
150 |
default="en",
|
151 |
+
description="(str) `translate from`",
|
152 |
)
|
153 |
to_language: str = Field(
|
154 |
default="fa",
|
155 |
+
description="(str) `translate to`",
|
156 |
)
|
157 |
input_text: str = Field(
|
158 |
default="Hello",
|
|
|
178 |
read_model = AutoModelForSeq2SeqLM.from_pretrained(real_name)
|
179 |
tokenizer = AutoTokenizer.from_pretrained(real_name)
|
180 |
#translator = pipeline("translation", model=read_model, tokenizer=tokenizer, src_lang=item.from_language, tgt_lang=item.to_language)
|
181 |
+
translate_query = (
|
182 |
+
f"translation_{item.from_language}_to_{item.to_language}"
|
183 |
+
)
|
184 |
+
translator = pipeline(translate_query)
|
185 |
result = translator(item.input_text)
|
186 |
|
187 |
item_response = {
|