Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
OGIOS edited this page Sep 18, 2023 · 1 revision

It should be noticed that Sign cannot be created with variable = Sign()
you have to get it through HuggingChat which can be imported:

from hugchat_api import HuggingChat
# or
from hugchat_api.core import HuggingChat

# and then
HUG = HuggingChat()
sign = HUG.getSign(<email>, <password?>)

Usage

For API details, please see:

Login

Sign only public one way to login:

from http.cookies import SimpleCookie
cookies: SimpleCookie[str] = sign.login(<save?>, <cookie_dir_path?>)

Param save defaults to False which won't save your login cookies after the login process,
but you can still save it by calling sign.saveCookiesToDir(<cookie_dir_path?>).

If cookie_dir_path isn't provided, then the cookies will be saved to
$YOUR_SITE_PACKAGE_DIR/hugchat_api/core/usercookies/<youremail>.json

Load Cookies From JSON File

If there is a JSON file including token and hf-chat then it can be loaded in with:

from http.cookies import SimpleCookie
cookies: SimpleCookie[str] = sign.loadCookiesFromDir(<cookie_dir_path?>)

Feel free to ask any questions or share me with your thoughts!

Clone this wiki locally