fix(document_loaders/telegram): fix pandas calls + add tests (#4806)

# Fix Telegram API loader + add tests.
I was testing this integration and it was broken with next error:
```python
message_threads = loader._get_message_threads(df)
KeyError: False
```
Also, this particular loader didn't have any tests / related group in
poetry, so I added those as well.

@hwchase17 / @eyurtsev please take a look on this fix PR.

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This commit is contained in:
Raduan Al-Shedivat
2023-05-16 23:35:25 +02:00
committed by GitHub
parent 206c87d525
commit 00c6ec8a2d
30 changed files with 137 additions and 42 deletions

View File

@@ -59,9 +59,11 @@
"id": "3e64cac2",
"metadata": {},
"source": [
"`TelegramChatApiLoader` loads data directly from any specified channel from Telegram. In order to export the data, you will need to authenticate your Telegram account. \n",
"`TelegramChatApiLoader` loads data directly from any specified chat from Telegram. In order to export the data, you will need to authenticate your Telegram account. \n",
"\n",
"You can get the API_HASH and API_ID from https://my.telegram.org/auth?to=apps\n",
"\n",
"chat_entity recommended to be the [entity](https://docs.telethon.dev/en/stable/concepts/entities.html?highlight=Entity#what-is-an-entity) of a channel.\n",
"\n"
]
},
@@ -72,10 +74,12 @@
"metadata": {},
"outputs": [],
"source": [
"loader = TelegramChatApiLoader(user_name =\"\"\\\n",
" chat_url=\"<CHAT_URL>\",\\\n",
" api_hash=\"<API HASH>\",\\\n",
" api_id=\"<API_ID>\")"
"loader = TelegramChatApiLoader(\n",
" chat_entity=\"<CHAT_URL>\", # recommended to use Entity here\n",
" api_hash=\"<API HASH >\", \n",
" api_id=\"<API_ID>\", \n",
" user_name =\"\", # needed only for caching the session.\n",
")"
]
},
{
@@ -113,10 +117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,