async anthropic streaming

This commit is contained in:
Ishaan Jaff 2024-04-06 17:36:56 -07:00
parent 8e5e99533b
commit 7849c29f70

View file

@ -8710,6 +8710,8 @@ class CustomStreamWrapper:
return hold, curr_chunk return hold, curr_chunk
def handle_anthropic_chunk(self, chunk): def handle_anthropic_chunk(self, chunk):
str_line = chunk
if isinstance(chunk, bytes): # Handle binary data
str_line = chunk.decode("utf-8") # Convert bytes to string str_line = chunk.decode("utf-8") # Convert bytes to string
text = "" text = ""
is_finished = False is_finished = False
@ -9970,6 +9972,7 @@ class CustomStreamWrapper:
or self.custom_llm_provider == "custom_openai" or self.custom_llm_provider == "custom_openai"
or self.custom_llm_provider == "text-completion-openai" or self.custom_llm_provider == "text-completion-openai"
or self.custom_llm_provider == "azure_text" or self.custom_llm_provider == "azure_text"
or self.custom_llm_provider == "anthropic"
or self.custom_llm_provider == "huggingface" or self.custom_llm_provider == "huggingface"
or self.custom_llm_provider == "ollama" or self.custom_llm_provider == "ollama"
or self.custom_llm_provider == "ollama_chat" or self.custom_llm_provider == "ollama_chat"