HuggingChat From HuggingFace Is An Open-Source AI Chat Interface

A true differentiator for HuggingChat will be a comprehensive API implementation with conversation context management.

Cobus Greyling
5 min readMay 26, 2023


The HuggingChat GUI is stellar in so many respects, as I detail below. And as an open-sourced effort to bring a ChatGPT-like experience to all, it fills a much needed niche.

Within the GUI, conversation context is well managed within a conversation and implicit follow-up questions can be asked and HuggingChat references the conversation context to provide contextually accurate answers.

I cannot help but feel that an area of differentiation for HuggingChat lies in making a comprehensive API available. It would be ideal for the API to include features like:

  • LLM Settings, like temperature, etc.
  • Conversational context management via the API.
  • A ChatML-like implementation for managing context. Similar to what OpenAI is doing, as seen below:
pip install openai

import os
import openai
openai.api_key = "xxxxxxxxxxxxxxxxxxxxxxx"

completion = openai.ChatCompletion.create(
messages = [{"role": "system", "content" : "You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-03-02"},
{"role": "user", "content" : "How are you?"},
{"role": "assistant", "content" : "I am doing well"},
{"role": "user", "content" : "How long does light take to travel from the sun to the eart?"}]
  • An added bonus would be a feature to roll-up conversational history in the case of longer conversations to keep prompt size reasonable.
  • Consider how conversation history is incorporated via ChatML below:
[{"role": "system", "content" : "You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-03-02"},
{"role": "user", "content" : "How are you?"},
{"role": "assistant", "content" : "I am doing well"},
{"role": "user", "content" : "When was the last Formula One championship in South Africa?"},
{"role": "assistant", "content" : "The last Formula One championship race held in South Africa was on October 17, 1993."},
{"role": "user", "content" : "Who won the race in South Africa?"}]

With OpenAI releasing the API to their ChatGPT model, context management was not included, and makers will have to create their own conversation context management.

In the case of ChatGPT, in order to maintain conversational context and manage dialog state, conversational history will have to be included in the ChatML document submitted, in order to enable the model to answer contextual questions.

These contextual questions can be answered by the model by leveraging prior dialog turns.

Hence, if a HuggingChat API implementation can incorporate conversation context management it will be a sure winner.

There does not seem to be an official HuggingChat API. But I found an implementation of an API on GitHub. Below is the complete code to run the API within a notebook:

pip install hugchat
from hugchat import hugchat
chatbot = hugchat.ChatBot(cookie_path="cookies.json")
# Create a new conversation
id = chatbot.new_conversation()
# Get conversation list
conversation_list = chatbot.get_conversation_list()
print("How old is the founder of the company Space X?"))

And the response:

Elon Musk was born on June 28th, 1971, so as of today he would currently be 49 years and 3 months old. He is currently involved heavily with his car and energy companies Tesla and Neuralink. Most recently it has been made public that Neuralink plans to unveil something related to links between human brains and machines. There have been many speculations about this event but few specific details have yet been released. While there were other notable events at the end of last year including progress towards using spacex rockets for point to point travel on Earth and potentially deploying some mini satellites in orbit for global internet capabilities. When not working towards these projects most fans enjoy discussing and speculating over every detail they can learn more about regarding everything from how far along work on tunneling technologies could potentially go and new battery breakthroughs down to which colors they plan to paint their cars next! What do you think is going to happen next and why do you care? Let me know if there’s any way I can better assist given your background knowledge and goals with asking the initial question. Anything else you would like to now? I am here to provide value however I can using my current training data.

Currently this API does not include conversational context management, as the GUI does.

And already a requirement has been raised on GitHub to incorporate context management within conversation.

Below is an extract for a current workaround:


HuggingChat GUI

As with ChatGPT, HuggingChat is a personalised AI assistant with features which include:

  • Saving previous conversations
  • The ability to thumbs-up or down a response; very much like the OpenAI Playground
  • Easy sharing of a conversation is enabled; as shown at the bottom-right in the image below:
  • Within the GUI, conversational context is managed well within a conversation, and contextually implicit questions can be asked.
  • HuggingChat shows the current model which is being referenced, with example topics for conversations; as seen below.

I’m currently the Chief Evangelist @ HumanFirst. I explore and write about all things at the intersection of AI and language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces and more.



Cobus Greyling

I explore and write about all things at the intersection of AI & language; LLMs/NLP/NLU, Chat/Voicebots, CCAI.