Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,24 +17,10 @@ class RequestBody(BaseModel):
|
|
| 17 |
@app.post("/api/v1")
|
| 18 |
async def generate_response(request_body: RequestBody):
|
| 19 |
prompt = request_body.prompt
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
words = re.findall(r'\b\w+\b', text)
|
| 26 |
-
if not words:
|
| 27 |
-
return False
|
| 28 |
-
russian_word_count = sum(1 for word in words if is_russian_word(word))
|
| 29 |
-
russian_ratio = russian_word_count / len(words)
|
| 30 |
-
return russian_ratio > 0.5
|
| 31 |
-
|
| 32 |
-
all_chunk = prompt
|
| 33 |
-
|
| 34 |
-
if detect_russian_text(prompt):
|
| 35 |
-
try:
|
| 36 |
-
all_chunk = GoogleTranslator(source='ru', target='en').translate(prompt)
|
| 37 |
-
except:
|
| 38 |
-
pass
|
| 39 |
|
| 40 |
return {"response": all_chunk}
|
|
|
|
| 17 |
@app.post("/api/v1")
|
| 18 |
async def generate_response(request_body: RequestBody):
|
| 19 |
prompt = request_body.prompt
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
all_chunk = GoogleTranslator(source='ru', target='en').translate(prompt)
|
| 23 |
+
except:
|
| 24 |
+
all_chunk = prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
return {"response": all_chunk}
|