Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter authored Jun 7, 2024
2 parents 1b090b4 + 325776e commit b4ac2e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ conversation_list = chatbot.get_conversation_list()
# Get the available models (not hardcore)
models = chatbot.get_available_llm_models()

# Get image link.
# Work only for model "CohereForAI/c4ai-command-r-plus"
chat_result = chatbot.chat("Draw a cat.")
print(chat_result.get_final_text())
print(chat_result.get_image_link())

# Switch model with given index
chatbot.switch_llm(0) # Switch to the first model
chatbot.switch_llm(1) # Switch to the second model
Expand Down
7 changes: 7 additions & 0 deletions src/hugchat/hugchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def _stream_query(
resp.encoding = 'utf-8'

if resp.status_code != 200:

retry_count -= 1
if retry_count <= 0:
raise exceptions.ChatError(
Expand All @@ -725,6 +726,12 @@ def _stream_query(
if obj.__contains__("type"):
_type = obj["type"]

if _type == "file":
_sha = obj["sha"]
_image_link = f"{self.hf_base_url}/chat/conversation/{conversation}/output/{_sha}"
yield {"type": _type, "image_link": _image_link}
continue

if _type == "finalAnswer":
final_answer = obj
break_flag = True
Expand Down

0 comments on commit b4ac2e8

Please sign in to comment.