hf-chat

Unofficial Huggingface chat async wrapper for reverse engineered api


License
MIT
Install
pip install hf-chat==0.1.0

Documentation

Unofficial HuggingFace chat api.

Description

Hatch project Python 3.11

A simple async ready wrapper for reverse engineered API of HuggingChat.

The project has no affiliation with Hugging Face, and it is neither endorsed nor officially supported by Hugging Face. The repository owner(s) and contributors cannot be held responsible for any damages or losses resulting from the utilization of this repository or its contents. Users bear sole responsibility for their actions and any potential consequences that may ensue.

Installing

pip install hf-chat

Quickstart

import asyncio
from hf_chat import ChatCompletion

async def main():
    async with ChatCompletion("email", "password") as chat:
        await chat.create_conversation(switch_to=True)
        user_input = input('> ')
        print(await chat.ask(user_input))
        
asyncio.run(main())

Alternatively:

import asyncio
from hf_chat import ChatCompletion

async def main():
    chat = ChatCompletion("email", "password")
    try:
        chat.start()
        await chat.create_conversation(switch_to=True)
        user_input = input('> ')
        print(await chat.ask(user_input))
    finally:
        chat.close()
        
asyncio.run(main())

Inspired by Soulter/hugging-chat-api