• Stars
    star
    737
  • Rank 61,050 (Top 2 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created over 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HuggingChat Python API🤗

hugging-chat-api

English | 简体中文

HuggingChat Python API

PyPi Support_Platform Downloads

Leave a star :)

When you use this project, it means that you have agreed to the following two requirements of the HuggingChat:

  1. 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.
  2. Your conversations will be shared with model authors.

Server resources are precious, it is not recommended to request this API in a high frequency.

(Hugging Face's CTO🤗 just liked the suggestion)

Authentication (Required Now)

Get Cookies

from hugchat.login import Login

# login
sign = Login(email, passwd)
cookies = sign.login()
sign.saveCookies()

# load cookies from usercookies/<email>.json
sign = login(email, None)
cookies = sign.loadCookies() # This will detect if the JSON file exists, return cookies if it does and raise an Exception if it's not.

Usage

Basic mode

pip install hugchat
from hugchat import hugchat
from hugchat.login import Login

# Log in to huggingface and grant authorization to huggingchat
sign = Login(email, passwd)
cookies = sign.login()

# Save cookies to usercookies/<email>.json
sign.saveCookies()

# Create a ChatBot
chatbot = hugchat.ChatBot(cookies=cookies.get_dict())  # or cookie_path="usercookies/<email>.json"
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.9
  • top_p: Optional[float]. Default is 0.95
  • repetition_penalty: Optional[float]. Default is 1.2
  • top_k: Optional[int]. Default is 50
  • truncate: Optional[int]. Default is 1024
  • watermark: Optional[bool]. Default is False
  • max_new_tokens: Optional[int]. Default is 1024
  • stop: Optional[list]. Default is ["</s>"]
  • return_full_text: Optional[bool]. Default is False
  • stream: Optional[bool]. Default is True
  • use_cache: Optional[bool]. Default is False
  • is_retry: Optional[bool]. Default is False
  • retry_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.

More Repositories

1

AstrBot

QQ、QQ 频道、Telegram 上的 ChatGPT, Claude, HuggingChat 机器人,支持插件 | 原 QQChannelChatGPT
Python
535
star
2

ERNIEBot

在Python上调用文心一言
Python
26
star
3

AstrBotLauncher

Python
11
star
4

GhostJ_For_Android

A simple tool for remote control
Java
7
star
5

USTBNetUsageInfo

USTBNetUsageInfo | 北京科技大学校园网使用情况
Java
7
star
6

HuggingChatForQQBot

QQChannelChatGPT的hugchat插件
Python
5
star
7

llms

AstrBot(原 QQChannelChatGPT)接入更多大语言模型的插件。
Python
4
star
8

VideoCliper

按固定时长裁剪视频,并生成4*4预览图
Python
3
star
9

helloworld

Python
3
star
10

MCServerManager

Fetch minecraft servers' players list, avatar, gamemode and so on...
Java
3
star
11

astrbot_plugin_telegram

让 AstrBot 接入 Telegram 平台的插件
Python
3
star
12

AstrBot-docs

AstrBot 文档
JavaScript
3
star
13

noguiSimpleFIR_Game

a simple five_in_a_row game by Python. nogui
Python
2
star
14

SoPhoneInfor

Android网络数据|电池悬浮窗
Java
2
star
15

SoFloatingGame

悬浮游戏 - 在手机上通过悬浮窗玩Google dino等游戏
JavaScript
2
star
16

aidraw

Python
2
star
17

LivePreviewMessageComposer

Vue
2
star
18

SoBoard

Android剪切板记录
Java
2
star
19

Countdown

一个基于vue和vuetify开发的倒计时网页
JavaScript
2
star
20

goodplugins

Python
2
star
21

PythonCodeStatsChecker

A python codes stats checker.(get code lines、function lines and so on. Folder scan supported)
Python
2
star
22

Sodiary-FrontEnd

Vue
1
star
23

SoDiary

[Constructing] A simple vue+springboot based Blog System
Java
1
star
24

liferestart

Python
1
star
25

hexo-theme-neutron

A concise hexo theme based on the theme `Maple`
EJS
1
star
26

SoEarth---a-real-time-Earth-Wallpaper

基于向日葵8号的实时地球壁纸
Python
1
star
27

Soulter

1
star
28

soulter.github.io

My blog.
HTML
1
star
29

SoAnime

【Deprecated】基于trace.moe的以图搜番软件
Java
1
star
30

Ticketer_autoGet

Java
1
star
31

StrongerTasks

Stronger reminder run on android | 一个增强提醒待办软件
Java
1
star
32

sysstatqcbot

Python
1
star
33

SafeAndLife

Python
1
star
34

bustub-2022fall

CMU Database Bustub
C++
1
star
35

BiliMonitor

Python
1
star
36

Craftify

Minecraft Skin Generator with DCGAN
Python
1
star