Spaces:
Sleeping
Sleeping
Update backend/main.py
Browse files- backend/main.py +7 -2
backend/main.py
CHANGED
@@ -79,13 +79,18 @@ async def answer_question(request: QARequest):
|
|
79 |
|
80 |
# 5️⃣ ترجمة المستندات
|
81 |
@app.post("/translate")
|
82 |
-
async def translate_text(
|
83 |
-
|
|
|
|
|
|
|
|
|
84 |
if isinstance(translation, list) and len(translation) > 0 and "translation_text" in translation[0]:
|
85 |
return {"translation": translation[0]["translation_text"]}
|
86 |
else:
|
87 |
return {"error": "Translation failed. No valid response."}
|
88 |
|
|
|
89 |
# 6️⃣ توليد أكواد التصور من أوامر نصية
|
90 |
@app.post("/generate_code")
|
91 |
async def generate_code(prompt: str = Form(...)):
|
|
|
79 |
|
80 |
# 5️⃣ ترجمة المستندات
|
81 |
@app.post("/translate")
|
82 |
+
async def translate_text(
|
83 |
+
text: str = Form(...),
|
84 |
+
source_lang: str = Form(...),
|
85 |
+
target_lang: str = Form(...)
|
86 |
+
):
|
87 |
+
translation = translator(text, source_lang, target_lang)
|
88 |
if isinstance(translation, list) and len(translation) > 0 and "translation_text" in translation[0]:
|
89 |
return {"translation": translation[0]["translation_text"]}
|
90 |
else:
|
91 |
return {"error": "Translation failed. No valid response."}
|
92 |
|
93 |
+
|
94 |
# 6️⃣ توليد أكواد التصور من أوامر نصية
|
95 |
@app.post("/generate_code")
|
96 |
async def generate_code(prompt: str = Form(...)):
|