@@ -9,7 +9,9 @@ Unofficial HuggingChat Python API, extensible for chatbots etc.
99[ ![ DownloadsPW] ( https://img.shields.io/pypi/dw/hugchat?logo=download&logoColor=white )] ( https://pypi.python.org/pypi/hugchat )
1010[ ![ Status] ( https://img.shields.io/badge/status-operational-%234ea94b.svg?logo=ok&logoColor=white )] ( https://pypi.python.org/pypi/hugchat )
1111[ ![ Downloads] ( https://static.pepy.tech/badge/hugchat?logo=download&logoColor=white )] ( https://www.pepy.tech/projects/hugchat )
12-
12+ <a href =" https://discord.gg/tm5GVFpz " target =" _blank " >
13+ <img src="https://img.shields.io/discord/1082486657678311454?logo=discord&labelColor=%20%235462eb&logoColor=%20%23f5f5f5&color=%20%235462eb"
14+ alt="chat on Discord"></a>
1315
1416> ** Note**
1517>
@@ -47,9 +49,14 @@ cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)
4749# Create your ChatBot
4850chatbot = hugchat.ChatBot(cookies = cookies.get_dict()) # or cookie_path="usercookies/<email>.json"
4951
50- # Non stream response
51- query_result = chatbot.chat(" Hi!" )
52- print (query_result) # or query_result.text or query_result["text"]
52+ message_result = chatbot.chat(" Hi!" ) # note: message_result is a generator, the method will return immediately.
53+
54+ # Non stream
55+ message_str: str = message_result.wait_until_done() # you can also print(message_result) directly.
56+ # get files(such as images)
57+ file_list = message_result.get_files_created() # must call wait_until_done() first!
58+
59+ # tips: model "CohereForAI/c4ai-command-r-plus" can generate images :)
5360
5461# Stream response
5562for resp in chatbot.query(
@@ -58,7 +65,7 @@ for resp in chatbot.query(
5865):
5966 print (resp)
6067
61- # Web search (new feature)
68+ # Web search
6269query_result = chatbot.query(" Hi!" , web_search = True )
6370print (query_result)
6471for source in query_result.web_search_sources:
@@ -77,12 +84,6 @@ conversation_list = chatbot.get_conversation_list()
7784# Get the available models (not hardcore)
7885models = chatbot.get_available_llm_models()
7986
80- # Get image link.
81- # Work only for model "CohereForAI/c4ai-command-r-plus"
82- chat_result = chatbot.chat(" Draw a cat." )
83- print (chat_result.get_final_text())
84- print (chat_result.get_image_link())
85-
8687# Switch model with given index
8788chatbot.switch_llm(0 ) # Switch to the first model
8889chatbot.switch_llm(1 ) # Switch to the second model
@@ -100,12 +101,6 @@ chatbot.new_conversation(assistant=assistant, switch_to=True) # create a new con
100101chatbot.delete_all_conversations()
101102```
102103
103- The ` query() ` function receives these parameters:
104-
105- - ` text ` : Required[ str] .
106- - ` retry_count ` : Optional[ int] . Number of retries for requesting huggingchat. Default is 5
107- - ` web_search ` : Optional[ bool] . Whether to use online search.
108-
109104### CLI
110105
111106> ` version 0.0.5.2 ` or newer
0 commit comments