HuggingChat Python API: az Ön ingyenes alternatívája

HuggingChat Python API: az Ön ingyenes alternatívája

Forrás csomópont: 2625748

 

HuggingChat Python API: az Ön ingyenes alternatívája
A képet Author with Midjourney készítette
 

You’ve seen so many alternatives to ChatGPT of late, but have you checked out HuggingChat from HuggingFace?

HuggingChat is a free and open source alternative to commercial chat offerings such as ChatGPT. In theory, the service could leverage numerous models, yet I have only seen it use LLaMa 30B SFT 6 (oasst-sft-6-láma-30b) ból ből OpenAssistant eddig.

You can find out all about OpenAssistant’s interesting efforts to build their chatbot itt. While the model may not be GPT4 level, it is definitely a capable LLM with an interesting training story that is worth checking out.

Free and open source? Sounds great. But wait… there’s more!

Can’t get access to the ChatGPT4 API? Sick of paying for it even if you can? Why not give the unofficial HuggingChat Python API próba?

No API keys. No signup. No nothin’! Just pip install hugface, then copy, paste and run the below sample script from the command line.

#!/usr/bin/env python
# -*- coding: utf-8 -*- from hugchat import hugchat # Create a chatbot connection
chatbot = hugchat.ChatBot() # New a conversation (ignore error)
id = chatbot.new_conversation()
chatbot.change_conversation(id) # Intro message
print('[[ Welcome to ChatPAL. Let's talk! ]]')
print(''q' or 'quit' to exit')
print(''c' or 'change' to change conversation')
print(''n' or 'new' to start a new conversation') while True: user_input = input('> ') if user_input.lower() == '': pass elif user_input.lower() in ['q', 'quit']: break elif user_input.lower() in ['c', 'change']: print('Choose a conversation to switch to:') print(chatbot.get_conversation_list()) elif user_input.lower() in ['n', 'new']: print('Clean slate!') id = chatbot.new_conversation() chatbot.change_conversation(id) else: print(chatbot.chat(user_input))

Run the script — ./huggingchat.py, or whatever you named the file — and get something like the following (after saying hello):

 
HuggingChat Python API: az Ön ingyenes alternatívája

HuggingChat Python API: az Ön ingyenes alternatívája
 

The barebones sample script takes input and passes it to the API, displaying the results as they are returned. The only interpretation of input by the script is to look for a keyword to quit, a keyword to start a new conversation, or a keyword to change to a pre-existing alternative conversation that you already have underway. All are self-explanatory.

For more information on the library, including the chat() function parameters, check out its GitHub repo.

There are all sorts of interesting use cases for a chatbot API, specially one that you are free to explore without a hit to your wallet. You are only limited by your imagination.

Boldog kódolást!

 
 
Matthew Mayo (@mattmayo13) egy adattudós és a KDnuggets, az adattudományi és gépi tanulás alapvető online forrásának főszerkesztője. Érdeklődési köre a természetes nyelvi feldolgozás, az algoritmusok tervezése és optimalizálása, a felügyelet nélküli tanulás, a neurális hálózatok és a gépi tanulás automatizált megközelítései. Matthew informatikus mesterfokozattal és adatbányászatból szerzett diplomát. Elérhető a kdnuggets[dot]com editor1 címen.
 

Időbélyeg:

Még több KDnuggets