A huggingchat python api.
Project description
hugging-chat-api
English | 简体中文
HuggingChat Python API
Leave a star :)
When you use this project, it means that you have agreed to the following two requirements of the HuggingChat:
- AI is an area of active research with known problems such as biased generation and misinformation. Do not use this application for high-stakes decisions or advice.
- Your conversations will be shared with model authors.
Authentication (Required Now)
Cookies
How to Get Cookies ?
- Install the
Cookie-Editor
extension for Chrome or Firefox - Go to HuggingChat and login
- Open the extension
- Click
Export
on the bottom right, thenExport as JSON
(This saves your cookies to the clipboard) - Paste your cookies into a file
cookies.json
Usage
Basic mode
pip install hugchat
from hugchat import hugchat
chatbot = hugchat.ChatBot(cookie_path="cookies.json") # or cookies=[...]
print(chatbot.chat("HI"))
# Create a new conversation
id = chatbot.new_conversation()
chatbot.change_conversation(id)
# Get conversation list
conversation_list = chatbot.get_conversation_list()
The chat()
function receives these parameters:
text
: Required[str].temperature
: Optional[float]. Default is 0.9top_p
: Optional[float]. Default is 0.95repetition_penalty
: Optional[float]. Default is 1.2top_k
: Optional[int]. Default is 50truncate
: Optional[int]. Default is 1024watermark
: Optional[bool]. Default is Falsemax_new_tokens
: Optional[int]. Default is 1024stop
: Optional[list]. Default is [""]return_full_text
: Optional[bool]. Default is Falsestream
: Optional[bool]. Default is Trueuse_cache
: Optional[bool]. Default is Falseis_retry
: Optional[bool]. Default is Falseretry_count
: Optional[int]. Number of retries for requesting huggingchat. Default is 5
CLI mode
version 0.0.5.2
or newer
Simply run the following command in your terminal to start the CLI mode
python -m hugchat.cli
Commands in cli mode:
/new
: Create and switch to a new conversation./ids
: Shows a list of all ID numbers and ID strings in current session./switch <id>
: Switches to the ID number passed./exit
: Closes CLI environment.
Disclaimers
This is not an official Hugging Face product. This is a personal project and is not affiliated with Hugging Face in any way. Don't sue us.
Server resources are precious, it is not recommended to request this API frequently.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hugchat-0.0.6.2.tar.gz
(19.4 kB
view hashes)
Built Distribution
hugchat-0.0.6.2-py3-none-any.whl
(18.8 kB
view hashes)
Close
Hashes for hugchat-0.0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee01e3b15c2d183804a39b9f660febbaa098b379441f976ba4dc7ded2fbc1af8 |
|
MD5 | 0f9438e3d6dd42733885d8b7dcd1ab18 |
|
BLAKE2b-256 | 2dca35a6f459199200bb4edada8f1e84d75f752c21c2abed43afb716214c66fe |