google translate nb formatting (#12534)

This commit is contained in:
Bagatur 2023-10-29 21:27:04 -07:00 committed by GitHub
parent e05bb938de
commit b2138508cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,7 +22,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"! pip install google-cloud-translate\n" "! pip install google-cloud-translate"
] ]
}, },
{ {
@ -32,7 +32,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from langchain.schema import Document\n", "from langchain.schema import Document\n",
"from langchain.document_transformers import GoogleTranslateTransformer\n" "from langchain.document_transformers import GoogleTranslateTransformer"
] ]
}, },
{ {
@ -79,7 +79,7 @@
"\n", "\n",
"Lewis Cymbal\n", "Lewis Cymbal\n",
"CEO, Cymbal Bank\n", "CEO, Cymbal Bank\n",
"\"\"\"\n" "\"\"\""
] ]
}, },
{ {
@ -107,7 +107,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"documents = [Document(page_content=sample_text)]\n", "documents = [Document(page_content=sample_text)]\n",
"translator = GoogleTranslateTransformer(project_id=\"<YOUR_PROJECT_ID>\")\n" "translator = GoogleTranslateTransformer(project_id=\"<YOUR_PROJECT_ID>\")"
] ]
}, },
{ {
@ -138,7 +138,9 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"translated_documents = translator.transform_documents(documents, target_language_code=\"es\")\n" "translated_documents = translator.transform_documents(\n",
" documents, target_language_code=\"es\"\n",
")"
] ]
}, },
{ {
@ -187,7 +189,7 @@
"source": [ "source": [
"for doc in translated_documents:\n", "for doc in translated_documents:\n",
" print(doc.metadata)\n", " print(doc.metadata)\n",
" print(doc.page_content)\n" " print(doc.page_content)"
] ]
} }
], ],